From 6b2c648878b8df538d719c06394bc430cc3ed48c Mon Sep 17 00:00:00 2001 From: Sam Amis <30879203+SameAsMuli@users.noreply.github.com> Date: Sat, 22 Jul 2023 02:15:14 -0500 Subject: [PATCH] feat(telescope): allow word and selection searches (#1096) 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 1fad510c..d073dc58 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -119,8 +119,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",