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.
This commit is contained in:
Adrian Wilkins 2024-09-11 00:38:11 +01:00
parent 12818a6cb4
commit 187303a659
2 changed files with 14 additions and 0 deletions

View file

@ -220,6 +220,13 @@ return {
{ "<leader>fg", "<cmd>FzfLua git_files<cr>", desc = "Find Files (git-files)" },
{ "<leader>fr", "<cmd>FzfLua oldfiles<cr>", desc = "Recent" },
{ "<leader>fR", LazyVim.pick("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" },
{
"<leader>fw",
function()
LazyVim.pick("files", { query = vim.fn.expand("<cword>") })()
end,
desc = "Find Files (Current word)",
},
-- git
{ "<leader>gc", "<cmd>FzfLua git_commits<CR>", desc = "Commits" },
{ "<leader>gs", "<cmd>FzfLua git_status<CR>", desc = "Status" },

View file

@ -101,6 +101,13 @@ return {
{ "<leader>fg", "<cmd>Telescope git_files<cr>", desc = "Find Files (git-files)" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
{ "<leader>fR", LazyVim.pick("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" },
{
"<leader>fw",
function()
LazyVim.pick("files", { default_text = vim.fn.expand("<cword>") })()
end,
desc = "Find Files (Current word)",
},
-- git
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "Commits" },
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "Status" },