Highlight the matched part in :ltag

Sat, 11 Mar 2023 20:58:42 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 11 Mar 2023 20:58:42 -0500
changeset 1077
5439ee582f9b
parent 1076
15007f695dfb
child 1078
aa4c1aa529a5

Highlight the matched part in :ltag

.config/nvim/lua/config/autocmds.lua file | annotate | diff | comparison | revisions
--- a/.config/nvim/lua/config/autocmds.lua
+++ b/.config/nvim/lua/config/autocmds.lua
@@ -70,7 +70,7 @@ autocmd("BufReadPost", "*", {
 -- >> simple highlight conflict markers
 autocmd("BufReadPost", "*", {
   callback = function(_)
-    fn.matchadd("Error", [[^\([<>|]\)\{7} \@=\|^=\{7}$]])
+    fn.matchadd("Error", [[\m^\([<>|]\)\{7} \@=\|^=\{7}$]])
   end,
 })
 
@@ -79,7 +79,13 @@ autocmd("BufReadPost", "quickfix", {
   callback = function(ctx)
     -- simplify noisy :ltag output
     if string.match(vim.w.quickfix_title, "^ltag") then
-      fn.matchadd("Conceal", [[|\zs\^\\V\|\\$|.*]])
+      -- Hide ctags regex anchors
+      fn.matchadd("Conceal", [[\m|\zs\^\\V\|\\$\ze|]])
+
+      -- highlight match in line. if tagname begins with / the rest is a \V
+      -- regex. match must be between vertical bars, so its the 2nd column.
+      local tagmatch = string.gsub(vim.fn.gettagstack().items[1].tagname, "^/", "\\V", 1)
+      fn.matchadd("Underlined", [[\m|.*\zs]] .. tagmatch .. [[\m\ze.*|]])
     end
 
     -- easy close

mercurial