Merge branch 'main' into RenameNote

This commit is contained in:
lambtho12
2022-01-20 09:12:57 +01:00
2 changed files with 27 additions and 9 deletions

View File

@@ -60,7 +60,7 @@ local function yaml_to_tags(line, entry, ret)
local i = 1
local j
local prev_i
local prev_i = 1
local tag
while true do
i, j = line:find("%s*.*%s*,", i)
@@ -73,6 +73,9 @@ local function yaml_to_tags(line, entry, ret)
end
local new_entry = {}
-- strip trailing ]
tag = tag:gsub("]", "")
new_entry.t = tag
new_entry.l = entry.l
new_entry.fn = entry.fn
@@ -112,9 +115,14 @@ M.do_find_all_tags = function(opts)
args = args,
enable_recording = true,
on_exit = function(j, return_val)
if return_val == 0 then
for _, line in pairs(j:result()) do
parse_entry(opts, line, ret)
end
else
print("rg return value: " .. tostring(return_val))
print("stderr: ", vim.inspect(j:stderr_result()))
end
end,
on_stderr = function(err, data, _)
print("error: " .. tostring(err) .. "data: " .. data)

View File

@@ -191,7 +191,12 @@ local function global_dir_check()
ret = ret and check_dir_and_ask(M.Cfg.dailies, "dailies")
ret = ret and check_dir_and_ask(M.Cfg.weeklies, "weeklies")
ret = ret and check_dir_and_ask(M.Cfg.templates, "templates")
ret = ret and check_dir_and_ask(M.Cfg.image_subdir, "image_subdir")
local img_dir = M.Cfg.home
if M.Cfg.image_subdir then
img_dir = img_dir .. "/" .. M.Cfg.image_subdir
end
ret = ret and check_dir_and_ask(img_dir, "image_subdir")
return ret
end
@@ -2200,6 +2205,8 @@ local function FollowLink(opts)
return rawget(t, rawget(lookup_keys, k))
end,
}
--
if opts.show_link_counts then
mt_vimgrep_entry.display = make_display
else
@@ -2261,10 +2268,11 @@ local function FollowLink(opts)
)
-- builtin.live_grep({
pickers.new({
local picker = pickers.new({
cwd = cwd,
prompt_title = "Notes referencing `" .. title .. "`",
default_text = search_pattern,
initial_mode = "insert",
-- link to specific file (a daily file): [[2021-02-22]]
-- link to heading in specific file (a daily file): [[2021-02-22#Touchpoint]]
-- link to heading globally [[#Touchpoint]]
@@ -2283,7 +2291,8 @@ local function FollowLink(opts)
map("n", "<c-cr>", picker_actions.paste_link(opts))
return true
end,
}):find()
})
picker:find()
end
end
@@ -2516,16 +2525,17 @@ local function FindAllTags(opts)
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr, map)
actions.select_default:replace(function()
actions._close(prompt_bufnr, true)
-- actions for insert tag, default action: search for tag
local selection = action_state.get_selected_entry().value.tag
local follow_opts = {
follow_tag = selection,
show_link_counts = true,
}
actions._close(prompt_bufnr, false)
vim.schedule(function()
FollowLink(follow_opts)
end)
end)
map("i", "<c-y>", picker_actions.yank_tag(opts))
map("i", "<c-i>", picker_actions.paste_tag(opts))
map("n", "<c-y>", picker_actions.yank_tag(opts))