From 5d65a95123bd195bbbe86fec4d6d2370126faeac Mon Sep 17 00:00:00 2001 From: Sam Amis Date: Tue, 11 Jul 2023 23:00:06 +0100 Subject: [PATCH] feat(telescope): allow word and selection searches Changes the current normal-mode mappings sw / sW to only display matches surrounded by word boundaries. Also adds the equivalent visual-mode mappings to allow searching for the current selection. Selection searching does not consider word boundaries, so highlighting a single word and searching for it will produce the same results as the word-under-cursor searching did before this change. This allows the user to easily choose whether or not to include word boundaries in their search. --- lua/lazyvim/plugins/editor.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 119bf6c1..d69293a3 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -128,8 +128,10 @@ return { { "sm", "Telescope marks", desc = "Jump to Mark" }, { "so", "Telescope vim_options", desc = "Options" }, { "sR", "Telescope resume", desc = "Resume" }, - { "sw", Util.telescope("grep_string"), desc = "Word (root dir)" }, - { "sW", Util.telescope("grep_string", { cwd = false }), desc = "Word (cwd)" }, + { "sw", Util.telescope("grep_string", { word_match = "-w" }), desc = "Word (root dir)" }, + { "sW", Util.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" }, + { "sw", Util.telescope("grep_string"), mode = "v", desc = "Selection (root dir)" }, + { "sW", Util.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" }, { "uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" }, { "ss",