diff --git a/lazy-lock.json b/lazy-lock.json index ab3e1c38..67f94b1b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -5,6 +5,7 @@ "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, + "fzf-lua": { "branch": "main", "commit": "6d1d81a5c7936d82a47a41a521958e482e499fde" }, "gitsigns.nvim": { "branch": "main", "commit": "8b729e489f1475615dc6c9737da917b3bc163605" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, @@ -25,9 +26,6 @@ "oil.nvim": { "branch": "master", "commit": "685cdb4ffa74473d75a1b97451f8654ceeab0f4a" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, - "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, diff --git a/lua/kickstart/plugins/fzf-lua.lua b/lua/kickstart/plugins/fzf-lua.lua new file mode 100644 index 00000000..d03ec330 --- /dev/null +++ b/lua/kickstart/plugins/fzf-lua.lua @@ -0,0 +1,63 @@ +return { + 'ibhagwan/fzf-lua', + -- optional for icon support + dependencies = { 'nvim-tree/nvim-web-devicons' }, + -- or if using mini.icons/mini.nvim + -- dependencies = { "echasnovski/mini.icons" }, + opts = {}, + config = function() + require('fzf-lua').setup { + defaults = { + git_icons = false, + file_icons = false, + color_icons = false, + }, + } + + local get_open_filelist = function(cwd) + local bufnrs = filter(function(b) + if 1 ~= vim.fn.buflisted(b) then + return false + end + return true + end, vim.api.nvim_list_bufs()) + if not next(bufnrs) then + return + end + + local filelist = {} + for _, bufnr in ipairs(bufnrs) do + local file = vim.api.nvim_buf_get_name(bufnr) + table.insert(filelist, Path:new(file):make_relative(cwd)) + end + return filelist + end + + local builtin = require 'fzf-lua' + vim.keymap.set('n', 'sh', builtin.helptags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect FzfLua' }) + vim.keymap.set('n', 'sw', builtin.grep_cword, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sw', builtin.grep_cWORD, { desc = '[S]earch current [W]ORD' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by Live[G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics_document, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set('n', '/', builtin.lgrep_curbuf, { desc = '[/] Fuzzily search in current buffer' }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', 's/', function() + require('fzf-lua').fzf_live(get_open_filelist(vim.fn.getcwd())) + end, { desc = '[S]earch [/] in Open Files' }) + + -- Shortcut for searching your Neovim configuration files + vim.keymap.set('n', 'sn', function() + builtin.files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[S]earch [N]eovim files' }) + end, +} diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 6532757d..594b1701 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -81,16 +81,19 @@ return { map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) -- Find references for the word under your cursor. - map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + -- map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + map('grr', require('fzf-lua').lsp_references, '[G]oto [R]eferences') -- Jump to the implementation of the word under your cursor. -- Useful when your language has ways of declaring types without an actual implementation. - map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + -- map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + map('gri', require('fzf-lua').lsp_implementations, '[G]oto [I]mplementation') -- Jump to the definition of the word under your cursor. -- This is where a variable was first declared, or where a function is defined, etc. -- To jump back, press . - map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + -- map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + map('grd', require('fzf-lua').lsp_definitions, '[G]oto [D]efinition') -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header. @@ -98,16 +101,19 @@ return { -- Fuzzy find all the symbols in your current document. -- Symbols are things like variables, functions, types, etc. - map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') + -- map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') + map('gO', require('fzf-lua').lsp_document_symbols, 'Open Document Symbols') -- Fuzzy find all the symbols in your current workspace. -- Similar to document symbols, except searches over your entire project. - map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') + -- map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') + map('gW', require('fzf-lua').lsp_workspace_symbols, 'Open Workspace Symbols') -- Jump to the type of the word under your cursor. -- Useful when you're not sure what type a variable is and you want to see -- the definition of its *type*, not where it was *defined*. - map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + -- map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + map('grt', require('fzf-lua').lsp_typedefs, '[G]oto [T]ype Definition') -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) ---@param client vim.lsp.Client diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index 87604e3a..ac3e8828 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -24,7 +24,8 @@ require('lazy').setup({ -- include a plugin definition from file lua/path/name.lua require 'kickstart/plugins/gitsigns', require 'kickstart/plugins/which-key', - require 'kickstart/plugins/telescope', + -- require 'kickstart/plugins/telescope', + require 'kickstart/plugins/fzf-lua', require 'kickstart/plugins/lspconfig', require 'kickstart/plugins/conform', require 'kickstart/plugins/blink-cmp',