Cool tips you want to share #15
Replies: 7 comments 16 replies
-
Manually insert image nameConfigrequire'clipboard-image'.setup {
default = {
img_name = function ()
vim.fn.inputsave()
local name = vim.fn.input('Name: ')
vim.fn.inputrestore()
return name
end,
}
} |
Beta Was this translation helpful? Give feedback.
-
lua <<LUA
--
require'clipboard-image'.setup {
-- Default configuration for all typefile
default = {
img_dir = "img",
img_dir_txt = "img",
img_name = function () return os.date('%Y-%m-%d-%H-%M-%S') end,
affix = "![](/%s)",
img_handler = function (img)
local script = string.format('~/bin/imgup %s &', img.path)
os.execute(script)
end
},
-- You can create configuration for ceartain filetype by creating another field (markdown, in this case)
-- If you're uncertain what to name your field to, you can run `:set filetype?`
-- Missing options from `markdown` field will be replaced by options from `default` field
markdown = {
img_dir = "img",
img_dir_txt = "img",
affix = "![](/%s)"
}
}
LUA
command! -nargs=* PasteImage call luaeval('
\ require"clipboard-image.paste".paste_img({
\ img_dir = "~/Assets/"..(_A[1] and _A[1] or os.date("/%Y/%m")),
\ img_dir_txt = (_A[1] and _A[1] or os.date("/%Y/%m")),
\ img_name = os.date("%d%H%M%S")..(_A[2] or "")
\ })
\ ', split('<args>'))
noremap <Leader>P :<C-U><C-R>="PasteImage "<CR> |
Beta Was this translation helpful? Give feedback.
-
Image directory relative to current fileDemoClip-image-relative-dir.mp4Configrequire'clipboard-image'.setup {
default = {
img_dir = {"%:p:h", "img"}
}
}
|
Beta Was this translation helpful? Give feedback.
-
Insert alt-text with
|
Beta Was this translation helpful? Give feedback.
-
Use word under cursor as image's nameThis tip by @gokulmaxi from #14 Configrequire'clipboard-image'.setup {
tex = {
img_name = function()
local cword = vim.fn.expand('<cword>')
vim.fn.feedkeys("diw")
return cword
end,
}
} |
Beta Was this translation helpful? Give feedback.
-
Copy the URL instead of the actual imageDemoScreencast.from.05-07-2022.09.39.47.PM.mp4Configlocal function paste_url(url)
url = url.args
local utils = require "clipboard-image.utils"
local conf_utils = require "clipboard-image.config"
local conf_toload = conf_utils.get_usable_config()
local conf = conf_utils.load_config(conf_toload)
utils.insert_txt(conf.affix, url)
end
-- Now let's create the command (works on neovim 0.7+)
local create_command = vim.api.nvim_create_user_command
create_command("PasteImgUrl", paste_url, { nargs=1 }) |
Beta Was this translation helpful? Give feedback.
-
Unfortunately I did not.
May have been possible, but I ran out of time to spend on it.
…On Fri, Jul 7, 2023, at 03:15, Ayman wrote:
@erwin <https://github.com/erwin> Did you manage to get it working with `vim.ui.input` and `dressing.nvim`?
—
Reply to this email directly, view it on GitHub <#15 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACX77CKY6TER6OWRGZTK24TXO4FEJANCNFSM5HZAASDQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Sharing is nice, you can show some of your trick/hack of this plugin here
Beta Was this translation helpful? Give feedback.
All reactions