Skip to content

Commit

Permalink
feat: tags_grep_{cword|cWORD} to match whole words
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Dec 26, 2023
1 parent a2271a2 commit 15734a5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/fzf-lua/providers/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,16 @@ end

M.grep_cword = function(opts)
if not opts then opts = {} end
opts.search = vim.fn.expand("<cword>")
opts.no_esc = true
opts.search = [[\b]] .. utils.rg_escape(vim.fn.expand("<cword>")) .. [[\b]]
return M.grep(opts)
end

M.grep_cWORD = function(opts)
if not opts then opts = {} end
opts.search = vim.fn.expand("<cWORD>")
opts.no_esc = true
-- since we're searching a tags file also search for surrounding literals ^ $
opts.search = [[(^|\^|\s)]] .. utils.rg_escape(vim.fn.expand("<cWORD>")) .. [[($|\$|\s)]]
return M.grep(opts)
end

Expand Down

0 comments on commit 15734a5

Please sign in to comment.