From 15734a586e03aa93465770f6396d661cb1e37137 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Mon, 25 Dec 2023 17:58:23 -0800 Subject: [PATCH] feat: tags_grep_{cword|cWORD} to match whole words --- lua/fzf-lua/providers/tags.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/fzf-lua/providers/tags.lua b/lua/fzf-lua/providers/tags.lua index 5dca6340f..edda3b38d 100644 --- a/lua/fzf-lua/providers/tags.lua +++ b/lua/fzf-lua/providers/tags.lua @@ -233,13 +233,16 @@ end M.grep_cword = function(opts) if not opts then opts = {} end - opts.search = vim.fn.expand("") + opts.no_esc = true + opts.search = [[\b]] .. utils.rg_escape(vim.fn.expand("")) .. [[\b]] return M.grep(opts) end M.grep_cWORD = function(opts) if not opts then opts = {} end - opts.search = vim.fn.expand("") + 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("")) .. [[($|\$|\s)]] return M.grep(opts) end