diff --git a/.config/nvim/plugin/telescope.lua b/.config/nvim/plugin/telescope.lua index 21aaef03..5cf24d54 100644 --- a/.config/nvim/plugin/telescope.lua +++ b/.config/nvim/plugin/telescope.lua @@ -61,24 +61,30 @@ telescope.setup { -- Enable telescope fzf native, if installed pcall(require("telescope").load_extension, "fzf") -local function find_undercursor_in_buffer() - builtin["current_buffer_fuzzy_find"] { - layout_config = { height = 0.8 }, -- Already have word, no need to think - default_text = vim.fn.expand(""), - initial_mode = "normal", - } +local function find_undercursor_in_buffer(prefix) + return function() + builtin["current_buffer_fuzzy_find"] { + layout_config = { height = 0.8 }, -- Already have word, no need to think + default_text = prefix .. vim.fn.expand(""), + initial_mode = "normal", + } + end end -local function grep_undercursor() - builtin["live_grep"] { - layout_config = { height = 0.8 }, -- Already have word, no need to think - default_text = vim.fn.expand(""), - initial_mode = "normal", - } +local function grep_undercursor(prefix) + return function() + builtin["live_grep"] { + layout_config = { height = 0.8 }, -- Already have word, no need to think + default_text = prefix .. vim.fn.expand(""), + initial_mode = "normal", + } + end end vim.keymap.set("n", "/", builtin["current_buffer_fuzzy_find"]) -vim.keymap.set("n", "w", find_undercursor_in_buffer) -vim.keymap.set("n", "W", grep_undercursor) +vim.keymap.set("n", "w", find_undercursor_in_buffer("")) +vim.keymap.set("n", "W", grep_undercursor("")) +vim.keymap.set("n", "^w", find_undercursor_in_buffer("^")) +vim.keymap.set("n", "^W", grep_undercursor("^")) vim.keymap.set("n", "sf", builtin["find_files"]) vim.keymap.set("n", "sg", builtin["live_grep"])