diff --git a/lua/taglinks/taglinks.lua b/lua/taglinks/taglinks.lua index b27a7cc..4646fb0 100644 --- a/lua/taglinks/taglinks.lua +++ b/lua/taglinks/taglinks.lua @@ -10,6 +10,7 @@ M.is_tag_or_link_at = function(line, col, opts) local seen_bracket = false local seen_parenthesis = false + local seen_hashtag = false local cannot_be_tag = false while col >= 1 do @@ -41,7 +42,11 @@ M.is_tag_or_link_at = function(line, col, opts) end end else - if char == "#" and opts.tag_notation == "#tag" then + if char == "#" then + seen_hashtag = true + end + -- Tags should have a space before #, if not we are likely in a link + if char == " " and seen_hashtag and opts.tag_notation == "#tag" then if not cannot_be_tag then return "tag", col end