From abe8e8b441070cf5da76523d3a68dbc4ac7d24b1 Mon Sep 17 00:00:00 2001 From: lambtho12 Date: Wed, 18 May 2022 13:19:16 +0200 Subject: [PATCH] fix: do not look for tags in template dir --- lua/taglinks/tagutils.lua | 19 ++++++++++++++++++- lua/telekasten.lua | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lua/taglinks/tagutils.lua b/lua/taglinks/tagutils.lua index a5b0df3..e986d8e 100644 --- a/lua/taglinks/tagutils.lua +++ b/lua/taglinks/tagutils.lua @@ -10,6 +10,14 @@ local yaml_re = local function command_find_all_tags(opts) opts = opts or {} opts.cwd = opts.cwd or "." + opts.templateDir = opts.templateDir or "" + + -- do not list tags in the template directory + local globArg = "" + if opts.templateDir ~= "" then + globArg = "--glob=!" .. "**/" .. opts.templateDir .. "/*.md" + end + local re = hashtag_re if opts.tag_notation == ":tag:" then @@ -20,7 +28,16 @@ local function command_find_all_tags(opts) re = yaml_re end - return "rg", { "--vimgrep", "--pcre2", "-o", re, "--", opts.cwd } + return "rg", + { + "--vimgrep", + "--pcre2", + globArg, + "-o", + re, + "--", + opts.cwd, + } end -- strips away leading ' or " , then trims whitespace diff --git a/lua/telekasten.lua b/lua/telekasten.lua index f791eab..65ac464 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -2720,6 +2720,7 @@ local function FindAllTags(opts) local i = opts.i opts.cwd = M.Cfg.home opts.tag_notation = M.Cfg.tag_notation + opts.templateDir = Path:new(M.Cfg.templates):make_relative(M.Cfg.home) if not global_dir_check() then return