mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
Merge branch 'main' into 133-template_tags
This commit is contained in:
@@ -191,24 +191,20 @@ local function random_variable(length)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_uuid(opts)
|
local function get_uuid(opts)
|
||||||
opts.prefix_title_by_uuid = opts.prefix_title_by_uuid
|
|
||||||
or M.Cfg.prefix_title_by_uuid
|
|
||||||
opts.uuid_type = opts.uuid_type or M.Cfg.uuid_type
|
opts.uuid_type = opts.uuid_type or M.Cfg.uuid_type
|
||||||
|
|
||||||
local uuid
|
local uuid
|
||||||
if opts.prefix_title_by_uuid then
|
if opts.uuid_type ~= "rand" then
|
||||||
if opts.uuid_type ~= "rand" then
|
uuid = os.date(opts.uuid_type)
|
||||||
uuid = os.date(opts.uuid_type)
|
else
|
||||||
else
|
uuid = random_variable(6)
|
||||||
uuid = random_variable(6)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return uuid
|
return uuid
|
||||||
end
|
end
|
||||||
|
|
||||||
local function concat_uuid_title(uuid, title)
|
local function concat_uuid_title(uuid, title)
|
||||||
local sep = M.Cfg.uuid_sep or "-"
|
local sep = M.Cfg.uuid_sep or "-"
|
||||||
if uuid == nil then
|
if uuid == nil or not M.Cfg.prefix_title_by_uuid then
|
||||||
return title
|
return title
|
||||||
else
|
else
|
||||||
return uuid .. sep .. title
|
return uuid .. sep .. title
|
||||||
@@ -458,7 +454,7 @@ local function imgFromClipboard()
|
|||||||
local pngname = "pasted_img_" .. os.date("%Y%m%d%H%M%S") .. ".png"
|
local pngname = "pasted_img_" .. os.date("%Y%m%d%H%M%S") .. ".png"
|
||||||
local pngdir = M.Cfg.image_subdir and M.Cfg.image_subdir or M.Cfg.home
|
local pngdir = M.Cfg.image_subdir and M.Cfg.image_subdir or M.Cfg.home
|
||||||
local png = pngdir .. "/" .. pngname
|
local png = pngdir .. "/" .. pngname
|
||||||
local relpath = make_relative_path(vim.fn.expand("%"), png, "/")
|
local relpath = make_relative_path(vim.fn.expand("%:p"), png, "/")
|
||||||
|
|
||||||
local result = os.execute(get_paste_command(pngdir, pngname))
|
local result = os.execute(get_paste_command(pngdir, pngname))
|
||||||
if result > 0 then
|
if result > 0 then
|
||||||
@@ -1269,7 +1265,7 @@ function picker_actions.paste_img_link(opts)
|
|||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
local fn = selection.value
|
local fn = selection.value
|
||||||
fn = fn:gsub(escape(M.Cfg.home .. "/"), "")
|
fn = make_relative_path(vim.fn.expand("%:p"), fn, "/")
|
||||||
local imglink = ""
|
local imglink = ""
|
||||||
vim.api.nvim_put({ imglink }, "", true, true)
|
vim.api.nvim_put({ imglink }, "", true, true)
|
||||||
if opts.insert_after_inserting or opts.i then
|
if opts.insert_after_inserting or opts.i then
|
||||||
@@ -1286,7 +1282,7 @@ function picker_actions.yank_img_link(opts)
|
|||||||
end
|
end
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
local fn = selection.value
|
local fn = selection.value
|
||||||
fn = fn:gsub(escape(M.Cfg.home .. "/"), "")
|
fn = make_relative_path(vim.fn.expand("%:p"), fn, "/")
|
||||||
local imglink = ""
|
local imglink = ""
|
||||||
vim.fn.setreg('"', imglink)
|
vim.fn.setreg('"', imglink)
|
||||||
print("yanked " .. imglink)
|
print("yanked " .. imglink)
|
||||||
@@ -1857,7 +1853,7 @@ local function InsertImgLink(opts)
|
|||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
local fn = selection.value
|
local fn = selection.value
|
||||||
fn = fn:gsub(escape(M.Cfg.home .. "/"), "")
|
fn = make_relative_path(vim.fn.expand("%:p"), fn, "/")
|
||||||
vim.api.nvim_put({ "" }, "", true, true)
|
vim.api.nvim_put({ "" }, "", true, true)
|
||||||
if opts.i then
|
if opts.i then
|
||||||
vim.api.nvim_feedkeys("A", "m", false)
|
vim.api.nvim_feedkeys("A", "m", false)
|
||||||
|
|||||||
Reference in New Issue
Block a user