From 187303a6594aa7ece7cfe68c6a1d05dd93cc75c8 Mon Sep 17 00:00:00 2001 From: Adrian Wilkins Date: Wed, 11 Sep 2024 00:38:11 +0100 Subject: [PATCH] Add a "find files based on current word" command For both `fzf-lua` and `telescope` Rationale : I often find myself wanting to go to a file name that contains the word under the cursor. Not sure if `cWORD` is also a useful pick. --- lua/lazyvim/plugins/extras/editor/fzf.lua | 7 +++++++ lua/lazyvim/plugins/extras/editor/telescope.lua | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lua/lazyvim/plugins/extras/editor/fzf.lua b/lua/lazyvim/plugins/extras/editor/fzf.lua index e23af81b..b2c57c4e 100644 --- a/lua/lazyvim/plugins/extras/editor/fzf.lua +++ b/lua/lazyvim/plugins/extras/editor/fzf.lua @@ -220,6 +220,13 @@ return { { "fg", "FzfLua git_files", desc = "Find Files (git-files)" }, { "fr", "FzfLua oldfiles", desc = "Recent" }, { "fR", LazyVim.pick("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" }, + { + "fw", + function() + LazyVim.pick("files", { query = vim.fn.expand("") })() + end, + desc = "Find Files (Current word)", + }, -- git { "gc", "FzfLua git_commits", desc = "Commits" }, { "gs", "FzfLua git_status", desc = "Status" }, diff --git a/lua/lazyvim/plugins/extras/editor/telescope.lua b/lua/lazyvim/plugins/extras/editor/telescope.lua index 11cfef1b..cb4906da 100644 --- a/lua/lazyvim/plugins/extras/editor/telescope.lua +++ b/lua/lazyvim/plugins/extras/editor/telescope.lua @@ -101,6 +101,13 @@ return { { "fg", "Telescope git_files", desc = "Find Files (git-files)" }, { "fr", "Telescope oldfiles", desc = "Recent" }, { "fR", LazyVim.pick("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" }, + { + "fw", + function() + LazyVim.pick("files", { default_text = vim.fn.expand("") })() + end, + desc = "Find Files (Current word)", + }, -- git { "gc", "Telescope git_commits", desc = "Commits" }, { "gs", "Telescope git_status", desc = "Status" },