diff --git a/lua/taglinks/tagutils.lua b/lua/taglinks/tagutils.lua index abcf22f..c582f08 100644 --- a/lua/taglinks/tagutils.lua +++ b/lua/taglinks/tagutils.lua @@ -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,8 +115,13 @@ M.do_find_all_tags = function(opts) args = args, enable_recording = true, on_exit = function(j, return_val) - for _, line in pairs(j:result()) do - parse_entry(opts, line, ret) + 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, _) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index e5db71c..a55d17d 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -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", "", picker_actions.paste_link(opts)) return true end, - }):find() + }) + picker:find() end end @@ -2516,15 +2525,16 @@ 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, } - FollowLink(follow_opts) + actions._close(prompt_bufnr, false) + vim.schedule(function() + FollowLink(follow_opts) + end) end) map("i", "", picker_actions.yank_tag(opts)) map("i", "", picker_actions.paste_tag(opts))