mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
Add with live grep option to insert link function and find notes function (closes #188)
* add with_live_grep option to InsertLink function * add with_live_grep option to FindNotes function * update documents
This commit is contained in:
committed by
GitHub
parent
04deff8579
commit
9de25d1657
@@ -1442,38 +1442,48 @@ local function InsertLink(opts)
|
||||
return
|
||||
end
|
||||
|
||||
find_files_sorted({
|
||||
prompt_title = "Insert link to note",
|
||||
cwd = M.Cfg.home,
|
||||
attach_mappings = function(prompt_bufnr, map)
|
||||
actions.select_default:replace(function()
|
||||
actions.close(prompt_bufnr)
|
||||
local selection = action_state.get_selected_entry()
|
||||
local pinfo = Pinfo:new({
|
||||
filepath = selection.value,
|
||||
opts,
|
||||
})
|
||||
vim.api.nvim_put(
|
||||
{ "[[" .. pinfo.title .. "]]" },
|
||||
"",
|
||||
true,
|
||||
true
|
||||
)
|
||||
if opts.i then
|
||||
vim.api.nvim_feedkeys("A", "m", false)
|
||||
end
|
||||
end)
|
||||
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||
return true
|
||||
end,
|
||||
find_command = M.Cfg.find_command,
|
||||
sort = M.Cfg.sort,
|
||||
})
|
||||
local cwd = M.Cfg.home
|
||||
local find_command = M.Cfg.find_command
|
||||
local sort = M.Cfg.sort
|
||||
local attach_mappings = function(prompt_bufnr, map)
|
||||
actions.select_default:replace(function()
|
||||
actions.close(prompt_bufnr)
|
||||
local selection = action_state.get_selected_entry()
|
||||
local pinfo = Pinfo:new({
|
||||
filepath = selection.filename,
|
||||
opts,
|
||||
})
|
||||
vim.api.nvim_put({ "[[" .. pinfo.title .. "]]" }, "", true, true)
|
||||
if opts.i then
|
||||
vim.api.nvim_feedkeys("A", "m", false)
|
||||
end
|
||||
end)
|
||||
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||
return true
|
||||
end
|
||||
|
||||
if opts.with_live_grep then
|
||||
builtin.live_grep({
|
||||
prompt_title = "Insert link to note with live grep",
|
||||
cwd = cwd,
|
||||
attach_mappings = attach_mappings,
|
||||
find_command = find_command,
|
||||
sort = sort,
|
||||
})
|
||||
else
|
||||
find_files_sorted({
|
||||
prompt_title = "Insert link to note",
|
||||
cwd = cwd,
|
||||
attach_mappings = attach_mappings,
|
||||
find_command = find_command,
|
||||
sort = sort,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- local function check_for_link_or_tag()
|
||||
@@ -1845,22 +1855,37 @@ local function FindNotes(opts)
|
||||
return
|
||||
end
|
||||
|
||||
find_files_sorted({
|
||||
prompt_title = "Find notes by name",
|
||||
cwd = M.Cfg.home,
|
||||
find_command = M.Cfg.find_command,
|
||||
attach_mappings = function(_, map)
|
||||
actions.select_default:replace(picker_actions.select_default)
|
||||
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||
return true
|
||||
end,
|
||||
sort = M.Cfg.sort,
|
||||
})
|
||||
local cwd = M.Cfg.home
|
||||
local find_command = M.Cfg.find_command
|
||||
local sort = M.Cfg.sort
|
||||
local attach_mappings = function(_, map)
|
||||
actions.select_default:replace(picker_actions.select_default)
|
||||
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||
return true
|
||||
end
|
||||
|
||||
if opts.with_live_grep then
|
||||
builtin.live_grep({
|
||||
prompt_title = "Find notes by live grep",
|
||||
cwd = cwd,
|
||||
find_command = find_command,
|
||||
attach_mappings = attach_mappings,
|
||||
sort = sort,
|
||||
})
|
||||
else
|
||||
find_files_sorted({
|
||||
prompt_title = "Find notes by name",
|
||||
cwd = cwd,
|
||||
find_command = find_command,
|
||||
attach_mappings = attach_mappings,
|
||||
sort = sort,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user