From c9a390f19cb6c390796258f9bef8c29839287f5c Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Thu, 26 Dec 2024 20:33:55 +0100 Subject: [PATCH] nvim: switch from telescope to fzf-lua --- home/config/nvim/nifoc/keymap.fnl | 59 ++++++++++--------------- home/config/nvim/nifoc/statusline.fnl | 9 ++-- home/config/nvim/nifoc/telescope.fnl | 27 ----------- home/config/nvim/plugins/fzf.fnl | 17 +++++++ home/config/nvim/plugins/heirline.fnl | 8 ++-- home/config/nvim/plugins/illuminate.fnl | 3 +- home/config/nvim/plugins/telescope.fnl | 50 --------------------- home/programs/nvim/default.nix | 14 +++--- home/programs/nvim/plugins.nix | 54 ++++++---------------- home/programs/nvim/plugins.yaml | 6 +-- 10 files changed, 72 insertions(+), 175 deletions(-) delete mode 100644 home/config/nvim/nifoc/telescope.fnl create mode 100644 home/config/nvim/plugins/fzf.fnl delete mode 100644 home/config/nvim/plugins/telescope.fnl diff --git a/home/config/nvim/nifoc/keymap.fnl b/home/config/nvim/nifoc/keymap.fnl index 9cd31b1..64f7df9 100644 --- a/home/config/nvim/nifoc/keymap.fnl +++ b/home/config/nvim/nifoc/keymap.fnl @@ -1,11 +1,14 @@ (let [mod {} keymap vim.keymap substitute (require :substitute) - telescope-builtin (require :telescope.builtin) - telescope-themes (require :telescope.themes) - telescope-nifoc (require :nifoc.telescope) - telescope-ivy (telescope-themes.get_ivy) - telescope-dropdown (telescope-themes.get_dropdown) + fzf (require :fzf-lua) + fzf-layout-bottom {:winopts_fn #(let [height (math.floor (* vim.o.lines + 0.4))] + {:split (.. "belowright new | resize " + (tostring height))})} + fzf-layout-dropdown {:winopts {:height 0.4 + :width 0.6 + :preview {:hidden :hidden}}} npairs (require :nvim-autopairs) hover (require :hover) gitsigns (require :gitsigns) @@ -17,30 +20,21 @@ (fn mod.setup [] (keymap.set :n : : {:noremap true}) ;; Leader Mappings - (keymap.set :n :o telescope-nifoc.find-files {:desc "Find Files"}) - (keymap.set :n :s #(telescope-builtin.live_grep telescope-ivy) + (keymap.set :n :o fzf.files {:desc "Find Files"}) + (keymap.set :n :s #(fzf.live_grep fzf-layout-bottom) {:desc "Live Grep"}) (keymap.set :n :fn :enew {:desc "New File"}) (keymap.set :n :u "UrlView buffer" {:desc "Open UrlView"}) - (keymap.set :n :ut "Telescope undo" - {:desc "Toggle Undotree"}) (keymap.set :n :c repl.open-shell {:desc "Open Shell"}) (keymap.set :n :r repl.open-repl {:desc "Open REPL"}) - (keymap.set :n :bl #(telescope-builtin.buffers telescope-dropdown) - {:desc "List Buffers"}) - (keymap.set :n :bf - #(telescope-builtin.current_buffer_fuzzy_find telescope-dropdown) - {:desc "Find In Buffer"}) - (keymap.set :n :bt - #(telescope-builtin.treesitter telescope-dropdown) - {:desc "Find via Treesitter"}) - (keymap.set :n :pt :TodoTelescope {:desc "TODO Comments"}) + (keymap.set :n :bl fzf.buffers {:desc "List Buffers"}) + (keymap.set :n :bf fzf.grep_curbuf {:desc "Find In Buffer"}) + (keymap.set :n :bt fzf.treesitter {:desc "Find via Treesitter"}) (keymap.set :n :g #(neogit.open {:kind :split}) {:desc "Open Neogit"}) (keymap.set :n :vs #(neogit.open {:kind :split}) {:desc "VCS Status"}) - (keymap.set :n :vb - #(telescope-builtin.git_branches telescope-dropdown) + (keymap.set :n :vb #(fzf.git_branches fzf-layout-dropdown) {:desc "List VCS Branches"}) (keymap.set :n :vl #(gitsigns.blame_line {:full true}) {:desc "Blame Line"}) @@ -49,11 +43,10 @@ (keymap.set :n :vvm #(repo.open-merge-request) {:desc "Open MR"}) (keymap.set :n :vvc #(repo.open-ci) {:desc "Open CI"}) (keymap.set :n :vtc #(repo.run-ci) {:desc "Trigger CI"}) - (keymap.set :n :lk telescope-builtin.keymaps - {:desc "Show Keymappings"}) - (keymap.set :n :ld #(telescope-builtin.diagnostics telescope-ivy) + (keymap.set :n :lk fzf.keymaps {:desc "Show Keymappings"}) + (keymap.set :n :ld #(fzf.diagnostics_document fzf-layout-bottom) {:desc "Show Diagnostics"}) - (keymap.set :n :lt "TodoTelescope theme=ivy" + (keymap.set :n :lt :TodoFzfLua {:desc "Show Todo Comments"}) (keymap.set :n :dli :LspInfo {:desc "LSP Info"}) (keymap.set :n :dlr :LspRestart {:desc "Restart LSP"}) @@ -104,27 +97,21 @@ {1 :d :group :debug}])) (fn mod.lsp-attach [_client bufnr] - (keymap.set :n :t - #(telescope-builtin.lsp_document_symbols telescope-dropdown) + (keymap.set :n :t #(fzf.lsp_document_symbols fzf-layout-dropdown) {:buffer bufnr :desc "LSP Document Symbols"}) - (keymap.set :n :tw - #(telescope-builtin.lsp_dynamic_workspace_symbols telescope-dropdown) + (keymap.set :n :tw #(fzf.lsp_workspace_symbols fzf-layout-dropdown) {:buffer bufnr :desc "LSP Workspace Symbols"}) (keymap.set :n :th #(vim.lsp.inlay_hint.enable (not (vim.lsp.inlay_hint.is_enabled bufnr)) {: bufnr}) {:buffer bufnr :desc "Toggle Inlay Hints"}) - (keymap.set :n :lca - #(telescope-builtin.lsp_code_actions telescope-dropdown) + (keymap.set :n :lca fzf.lsp_code_actions {:buffer bufnr :desc "LSP Code Action"}) - (keymap.set :n :lfr - #(telescope-builtin.lsp_references telescope-dropdown) + (keymap.set :n :lfr fzf.lsp_references {:buffer bufnr :desc "Find References"}) - (keymap.set :n :lfd - #(telescope-builtin.lsp_definitions telescope-dropdown) + (keymap.set :n :lfd fzf.lsp_definitions {:buffer bufnr :desc "Find Definitions"}) - (keymap.set :n :lfi - #(telescope-builtin.lsp_implementations telescope-dropdown) + (keymap.set :n :lfi fzf.lsp_implementations {:buffer bufnr :desc "Find Implementations"})) (fn mod.terminal-open [bufnr] diff --git a/home/config/nvim/nifoc/statusline.fnl b/home/config/nvim/nifoc/statusline.fnl index 52547ec..4c32ad6 100644 --- a/home/config/nvim/nifoc/statusline.fnl +++ b/home/config/nvim/nifoc/statusline.fnl @@ -11,8 +11,11 @@ nifoc-treesitter (require :nifoc.treesitter) navic (require :nvim-navic) neogit (require :neogit) - telescope-builtin (require :telescope.builtin) - telescope-themes (require :telescope.themes)] + fzf (require :fzf-lua) + fzf-layout-bottom {:winopts_fn #(let [height (math.floor (* vim.o.lines + 0.4))] + {:split (.. "belowright new | resize " + (tostring height))})}] (fn buffer-variable-exists? [key] (not= (. vim :b key) nil)) @@ -207,7 +210,7 @@ self.hints])))) :update [:DiagnosticChanged :BufEnter] :on_click {:name :heirline_diagnostics_list - :callback #(telescope-builtin.diagnostics (telescope-themes.get_ivy {:bufnr 0}))} + :callback #(fzf.diagnostics_document fzf-layout-bottom)} 1 mod.space-if-count 2 {:provider (fn [self] (let [spacer (if (or (> self.warnings 0) diff --git a/home/config/nvim/nifoc/telescope.fnl b/home/config/nvim/nifoc/telescope.fnl deleted file mode 100644 index d9f55fd..0000000 --- a/home/config/nvim/nifoc/telescope.fnl +++ /dev/null @@ -1,27 +0,0 @@ -(let [mod {} - builtin (require :telescope.builtin) - themes (require :telescope.themes)] - (fn mod.find-files [] - (let [find-opts (themes.get_ivy {:find_command [:fd - :--type - :file - :--hidden - :--ignore-vcs - :-L - :--color - :never - :--exclude - :.git - :--exclude - :node_modules - :--exclude - :.direnv]})] - (builtin.find_files find-opts))) - - (fn mod.project-files [] - (let [git-opts (themes.get_ivy) - ok? (pcall builtin.git_files git-opts)] - (when (not ok?) - (mod.find-files)))) - - mod) diff --git a/home/config/nvim/plugins/fzf.fnl b/home/config/nvim/plugins/fzf.fnl new file mode 100644 index 0000000..b1ab986 --- /dev/null +++ b/home/config/nvim/plugins/fzf.fnl @@ -0,0 +1,17 @@ +(let [fzf (require :fzf-lua)] + (fzf.setup {:files {:cwd_prompt false :prompt "Files❯ "} + :grep {:prompt "Grep❯ "} + :grep_curbuf {:prompt "BGrep❯ "} + :buffers {:prompt "Buffers❯ "} + :treesitter {:prompt "Tree-sitter❯ "} + :lsp {:prompt_postfix "❯ " + :symbols {:prompt_postfix "❯ "} + :code_actions {:prompt "CodeActions❯ "} + :diagnostics {:prompt "Diagnostics❯ "} + :keymaps {:prompt "Keymaps❯ "}} + :winopts {:backdrop false} + :previewers {:builtin {:extensions {:gif :chafa + :jpg :chafa + :png :chafa}}} + :fzf_colors true}) + (fzf.register_ui_select)) diff --git a/home/config/nvim/plugins/heirline.fnl b/home/config/nvim/plugins/heirline.fnl index 45b2881..d4746c0 100644 --- a/home/config/nvim/plugins/heirline.fnl +++ b/home/config/nvim/plugins/heirline.fnl @@ -20,10 +20,10 @@ ns.position ns.search-count ns.command]) - (local telescope-statusline + (local fzf-statusline {:condition (fn [] - (conditions.buffer_matches {:filetype [:TelescopePrompt]})) - 1 (ns.custom-mode :Telescope :black :green)}) + (conditions.buffer_matches {:filetype [:fzf]})) + 1 (ns.custom-mode :FZF :black :green)}) (local neogit-statusline {:condition (fn [] (conditions.buffer_matches {:filetype [:NeogitBranchDescription :NeogitCommitMessage @@ -44,7 +44,7 @@ 5 (ns.shell-mode :black :purple)}) (local statusline {:hl ns.default-hl :fallthrough false - 1 telescope-statusline + 1 fzf-statusline 2 neogit-statusline 3 shell-statusline 4 default-statusline}) diff --git a/home/config/nvim/plugins/illuminate.fnl b/home/config/nvim/plugins/illuminate.fnl index d1eb9a4..028508d 100644 --- a/home/config/nvim/plugins/illuminate.fnl +++ b/home/config/nvim/plugins/illuminate.fnl @@ -1,3 +1,2 @@ (let [illuminate (require :illuminate)] - (illuminate.configure {:filetypes_denylist [:TelescopePrompt :netrw]})) - + (illuminate.configure {:filetypes_denylist [:TelescopePrompt :netrw :fzf]})) diff --git a/home/config/nvim/plugins/telescope.fnl b/home/config/nvim/plugins/telescope.fnl deleted file mode 100644 index d4715e9..0000000 --- a/home/config/nvim/plugins/telescope.fnl +++ /dev/null @@ -1,50 +0,0 @@ -(let [telescope (require :telescope) - actions (require :telescope.actions) - themes (require :telescope.themes)] - (telescope.setup {:defaults {; Display - :prompt_prefix " " - :selection_caret " " - :set_env {:COLORTERM :truecolor} - :path_display [:truncate :absolute] - ; Layout - :layout_strategy :horizontal - :layout_config {:horizontal {:preview_width 0.5}} - ; Mappings - :mappings {:i {: actions.close}} - ; Arguments - :vimgrep_arguments [:rg - :--hidden - :--ignore-vcs - :-g - :!.git/* - :--color=never - :--no-heading - :--with-filename - :--line-number - :--column - :--smart-case - :--trim]} - :extensions {:ui-select [(themes.get_dropdown {})] - :zf-native {:file {:enable true - :highlight_results true - :match_filename true} - :generic {:enable true - :highlight_results true - :match_filename false}}}}) - (telescope.load_extension :zf-native) - (telescope.load_extension :ui-select) - (telescope.load_extension :yank_history) - (telescope.load_extension :undo) - (let [augroup (vim.api.nvim_create_augroup :NifocTelescope {:clear true}) - aucmd vim.api.nvim_create_autocmd] - (aucmd :FileType {:pattern :TelescopePrompt - :callback #(set vim.opt_local.cursorline false) - :group augroup}) - (aucmd :User {:pattern :TelescopePreviewerLoaded - :command "let w:is_telescope=v:true" - :group augroup}) - (aucmd :BufWinEnter {:callback #(when vim.w.is_telescope - (set vim.opt_local.number true) - (set vim.opt_local.relativenumber false) - (set vim.opt_local.wrap true)) - :group augroup}))) diff --git a/home/programs/nvim/default.nix b/home/programs/nvim/default.nix index 80ec413..2dbc16d 100644 --- a/home/programs/nvim/default.nix +++ b/home/programs/nvim/default.nix @@ -21,11 +21,14 @@ in stdenv.cc git + delta nodejs tree-sitter fd ripgrep universal-ctags + fzf + chafa # LSP bash-language-server @@ -131,18 +134,13 @@ in type = "fennel"; } - # Telescope + # Finder { - plugin = telescope-nvim; - config = builtins.readFile ../../config/nvim/plugins/telescope.fnl; + plugin = fzf-lua; + config = builtins.readFile ../../config/nvim/plugins/fzf.fnl; type = "fennel"; } - pkgs.vimPlugins.telescope-zf-native-nvim - - telescope-ui-select-nvim - telescope-undo-nvim - # LSP { plugin = nvim-lspconfig; diff --git a/home/programs/nvim/plugins.nix b/home/programs/nvim/plugins.nix index bbc7103..4aaefd2 100644 --- a/home/programs/nvim/plugins.nix +++ b/home/programs/nvim/plugins.nix @@ -36,12 +36,12 @@ in }; nvim-web-devicons = buildVimPlugin { pname = "nvim-web-devicons"; - version = "2024-12-24"; + version = "2024-12-26"; src = fetchFromGitHub { owner = "kyazdani42"; repo = "nvim-web-devicons"; - rev = "c1a86a2c386c55efc02fa2ec2c3a914af653d954"; - sha256 = "09xqzjsaklic12av1x79blvyjfi3falrxc1q4mnwpyb0f0angv05"; + rev = "63f552a7f59badc6e6b6d22e603150f0d5abebb7"; + sha256 = "04yr85zz9b04lgxl9gfda52l0p82a1lc891s921mll3bx48i1xb2"; fetchSubmodules = false; }; @@ -148,12 +148,12 @@ in }; nvim-treesitter = buildVimPlugin { pname = "nvim-treesitter"; - version = "2024-12-25"; + version = "2024-12-26"; src = fetchFromGitHub { owner = "nvim-treesitter"; repo = "nvim-treesitter"; - rev = "ac6a72a6f83218216948e898362f09029b8035dc"; - sha256 = "0mrp9w7q60g43yd3f6ryrva06siy9bh4nxjlsjz0bsnssr70yhgm"; + rev = "17678b00fa5c2712890a0ec2e269d0a4de1207df"; + sha256 = "0d6fw1205bhlaxi0kzbl9gn4vgnyca2qxbnch21hz2mbm2wlq8qm"; fetchSubmodules = false; }; @@ -188,42 +188,14 @@ in doCheck = false; doInstallCheck = false; }; - telescope-nvim = buildVimPlugin { - pname = "telescope.nvim"; - version = "2024-11-29"; + fzf-lua = buildVimPlugin { + pname = "fzf-lua"; + version = "2024-12-26"; src = fetchFromGitHub { - owner = "nvim-telescope"; - repo = "telescope.nvim"; - rev = "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc"; - sha256 = "0bkpys6dj01x6ycylmf6vrd2mqjibmny9a2hxxrqn0jqqvagm5ly"; - fetchSubmodules = false; - - }; - doCheck = false; - doInstallCheck = false; - }; - telescope-ui-select-nvim = buildVimPlugin { - pname = "telescope-ui-select.nvim"; - version = "2023-12-04"; - src = fetchFromGitHub { - owner = "nvim-telescope"; - repo = "telescope-ui-select.nvim"; - rev = "6e51d7da30bd139a6950adf2a47fda6df9fa06d2"; - sha256 = "1cgi4kmq99ssx97nnriff5674cjfvc3qsw62nx3iz0xqc6d4s631"; - fetchSubmodules = false; - - }; - doCheck = false; - doInstallCheck = false; - }; - telescope-undo-nvim = buildVimPlugin { - pname = "telescope-undo.nvim"; - version = "2024-11-05"; - src = fetchFromGitHub { - owner = "debugloop"; - repo = "telescope-undo.nvim"; - rev = "2971cc9f193ec09e0c5de3563f99cbea16b63f10"; - sha256 = "0cg4w40wmr1k2l5zb25zffpp990wsmi6kq39fvfzy4ay2wx56zgs"; + owner = "ibhagwan"; + repo = "fzf-lua"; + rev = "76e25abc4bbaab243b52fad7f7d4262e76254fd3"; + sha256 = "0prii8hv8jli4p69mjqjma650q906f187i6zvk2g9i4kdvzzqpj6"; fetchSubmodules = false; }; diff --git a/home/programs/nvim/plugins.yaml b/home/programs/nvim/plugins.yaml index f41254e..e65dee2 100644 --- a/home/programs/nvim/plugins.yaml +++ b/home/programs/nvim/plugins.yaml @@ -15,10 +15,8 @@ - src: nvim-treesitter/nvim-treesitter - src: HiPhish/rainbow-delimiters.nvim - src: folke/todo-comments.nvim -# Telescope -- src: nvim-telescope/telescope.nvim -- src: nvim-telescope/telescope-ui-select.nvim -- src: debugloop/telescope-undo.nvim +# Finder +- src: ibhagwan/fzf-lua # LSP - src: neovim/nvim-lspconfig - src: mfussenegger/nvim-jdtls