From d88c03f005bdb0c1fa6a893f674a8de56351f807 Mon Sep 17 00:00:00 2001 From: iofq Date: Sun, 2 Feb 2025 22:38:46 -0600 Subject: [PATCH] add copilot, snacks --- flake.lock | 156 +++++--------------------------- flake.nix | 5 +- nix/mkNeovim.nix | 2 +- nix/neovim-overlay.nix | 53 +++-------- nvim/lua/plugins/ai.lua | 75 +++++++++++++++ nvim/lua/plugins/completion.lua | 143 +++++++++++++++++++---------- nvim/lua/plugins/lsp.lua | 63 +++++-------- nvim/lua/plugins/mini.lua | 15 --- nvim/lua/plugins/misc.lua | 47 ++++------ nvim/lua/plugins/snacks.lua | 76 ++++++++++++++++ nvim/lua/plugins/telescope.lua | 140 ---------------------------- 11 files changed, 325 insertions(+), 450 deletions(-) create mode 100644 nvim/lua/plugins/ai.lua create mode 100644 nvim/lua/plugins/snacks.lua delete mode 100644 nvim/lua/plugins/telescope.lua diff --git a/flake.lock b/flake.lock index b1e9731..4c4391a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,47 +1,5 @@ { "nodes": { - "blink": { - "inputs": { - "fenix": "fenix", - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1738451960, - "narHash": "sha256-6NgB253rpCaNlNabbZRYIC/x1ZOlm41ZMvQOSNhgef8=", - "owner": "Saghen", - "repo": "blink.cmp", - "rev": "cc34be8ff1145264811e59b017f59676ad81000e", - "type": "github" - }, - "original": { - "owner": "Saghen", - "repo": "blink.cmp", - "type": "github" - } - }, - "fenix": { - "inputs": { - "nixpkgs": [ - "blink", - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1734676450, - "narHash": "sha256-iwcxhTVe4h5TqW0HsNiOQP27eMBmbBshF+q2UjEy5aU=", - "owner": "nix-community", - "repo": "fenix", - "rev": "46e19fa0eb3260b2c3ee5b2cf89e73343c1296ab", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -62,24 +20,6 @@ "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, - "locked": { - "lastModified": 1733312601, - "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_2": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib_2" - }, "locked": { "lastModified": 1717285511, "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", @@ -114,7 +54,7 @@ }, "gen-luarc": { "inputs": { - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts", "git-hooks": "git-hooks", "luvit-meta": "luvit-meta", "nixpkgs": [ @@ -199,33 +139,21 @@ }, "nixpkgs": { "locked": { - "lastModified": 1736166416, - "narHash": "sha256-U47xeACNBpkSO6IcCm0XvahsVXpJXzjPIQG7TZlOToU=", - "owner": "nixos", + "lastModified": 1738410390, + "narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "b30f97d8c32d804d2d832ee837d0f1ca0695faa5", + "rev": "3a228057f5b619feb3186e986dbe76278d707b6e", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", + "owner": "NixOS", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-lib": { - "locked": { - "lastModified": 1733096140, - "narHash": "sha256-1qRH7uAUsyQI7R1Uwl4T+XvdNv778H0Nb5njNrqvylY=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" - } - }, - "nixpkgs-lib_2": { "locked": { "lastModified": 1717284937, "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=", @@ -237,6 +165,22 @@ "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" } }, + "nixpkgs-master": { + "locked": { + "lastModified": 1738490265, + "narHash": "sha256-lYo2OmtQ8Mz8BpmUQT93P8guOLnfGEwXbY55Eb55Thg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7e26be4395f18f0aaaab3d704a55791f19764edd", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1720386169, @@ -253,46 +197,12 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1738410390, - "narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "3a228057f5b619feb3186e986dbe76278d707b6e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { - "blink": "blink", "flake-utils": "flake-utils", "gen-luarc": "gen-luarc", - "nixpkgs": "nixpkgs_2", - "workspace-diagnostics-nvim": "workspace-diagnostics-nvim" - } - }, - "rust-analyzer-src": { - "flake": false, - "locked": { - "lastModified": 1734622712, - "narHash": "sha256-2Oc2LbFypF1EG3zTVIVcuT5XFJ7R3oAwu2tS8B0qQ0I=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "fe027d79d22f2a7645da4143f5cc0f5f56239b97", - "type": "github" - }, - "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", - "type": "github" + "nixpkgs": "nixpkgs", + "nixpkgs-master": "nixpkgs-master" } }, "systems": { @@ -309,22 +219,6 @@ "repo": "default", "type": "github" } - }, - "workspace-diagnostics-nvim": { - "flake": false, - "locked": { - "lastModified": 1723294887, - "narHash": "sha256-lBj4KUPmmhtpffYky/HpaTwY++d/Q9socp/Ys+4VeX0=", - "owner": "artemave", - "repo": "workspace-diagnostics.nvim", - "rev": "573ff93c47898967efdfbc6587a1a39e3c2d365e", - "type": "github" - }, - "original": { - "owner": "artemave", - "repo": "workspace-diagnostics.nvim", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index c48db06..1bec7e0 100644 --- a/flake.nix +++ b/flake.nix @@ -3,15 +3,12 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs-master.url = "github:NixOS/nixpkgs/master"; flake-utils.url = "github:numtide/flake-utils"; gen-luarc = { url = "github:mrcjkb/nix-gen-luarc-json"; inputs.nixpkgs.follows = "nixpkgs"; }; - workspace-diagnostics-nvim = { - url = "github:artemave/workspace-diagnostics.nvim"; - flake = false; - }; }; outputs = inputs @ { diff --git a/nix/mkNeovim.nix b/nix/mkNeovim.nix index 95975ff..02725a1 100644 --- a/nix/mkNeovim.nix +++ b/nix/mkNeovim.nix @@ -28,7 +28,7 @@ with lib; extraPython3Packages ? p: [], # Additional python 3 packages withPython3 ? false, # Build Neovim with Python 3 support? withRuby ? false, # Build Neovim with Ruby support? - withNodeJs ? false, # Build Neovim with NodeJS support? + withNodeJs ? true, # Build Neovim with NodeJS support? withSqlite ? true, # Add sqlite? This is a dependency for some plugins # You probably don't want to create vi or vim aliases # if the appName is something different than "nvim" diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 16b0179..aaf9213 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -10,32 +10,28 @@ with final.pkgs.lib; let inherit pname src; version = src.lastModifiedDate; }; - workspace-diagnostics-nvim = mkNvimPlugin inputs.workspace-diagnostics-nvim "workspace-diagnostics.nvim"; - mkNeovim = pkgs.callPackage ./mkNeovim.nix { inherit pkgs-wrapNeovim; }; all-plugins = with pkgs.vimPlugins; [ aerial-nvim - cmp-buffer - cmp-cmdline - cmp-nvim-lsp - cmp-path - cmp-treesitter - cmp_luasnip + avante-nvim + inputs.nixpkgs-master.legacyPackages.${pkgs.system}.vimPlugins.blink-cmp + blink-cmp-copilot + blink-compat + blink-ripgrep-nvim + copilot-lua diffview-nvim eyeliner-nvim friendly-snippets gitsigns-nvim lazy-nvim luasnip - markview-nvim mini-nvim neogen neogit none-ls-nvim nightfox-nvim nvim-autopairs - nvim-cmp nvim-dap nvim-dap-go nvim-dap-ui @@ -43,41 +39,13 @@ with final.pkgs.lib; let nvim-nio nvim-treesitter-context nvim-treesitter-textobjects - (nvim-treesitter.withPlugins(p: with p; [ - tree-sitter-bash - tree-sitter-c - tree-sitter-comment - tree-sitter-css - tree-sitter-dockerfile - tree-sitter-embedded-template - tree-sitter-go - tree-sitter-gomod - tree-sitter-hcl - tree-sitter-html - tree-sitter-javascript - tree-sitter-json - tree-sitter-lua - tree-sitter-make - tree-sitter-markdown - tree-sitter-markdown-inline - tree-sitter-nix - tree-sitter-php - tree-sitter-python - tree-sitter-regex - tree-sitter-ruby - tree-sitter-sql - tree-sitter-toml - tree-sitter-typescript - tree-sitter-yaml - ])) + nvim-treesitter.withAllGrammars + render-markdown-nvim scope-nvim - telescope-fzf-native-nvim - telescope-nvim - toggleterm-nvim + snacks-nvim trouble-nvim undotree yanky-nvim - workspace-diagnostics-nvim ]; basePackages = with pkgs; [ @@ -93,8 +61,9 @@ with final.pkgs.lib; let gopls lua-language-server nil - python312Packages.jedi-language-server phpactor + python312Packages.jedi-language-server + ruby-lsp # debuggers delve diff --git a/nvim/lua/plugins/ai.lua b/nvim/lua/plugins/ai.lua new file mode 100644 index 0000000..3a48c16 --- /dev/null +++ b/nvim/lua/plugins/ai.lua @@ -0,0 +1,75 @@ +return { + { + "zbirenbaum/copilot.lua", + cmd = "Copilot", + event = "InsertEnter", + opts = { + panel = { enabled = false }, + suggestion = { + enabled = true, + keymap = { + accept = "", + next = "", + dismiss = "", + }, + }, + completion = { + documentation = { + auto_show = true, + }, + list = { + selection = { + preselect = false, + auto_insert = true, + } + }, + accept = { + auto_brackets = { + enabled = true + } + }, + }, + filetypes = { + go = true, + lua = true, + php = true, + python = true, + ruby = true, + sh = true, + puppet = true, + yaml = true, + markdown = true, + ["."] = false, + } + } + }, + { + "yetone/avante.nvim", + event = "VeryLazy", + lazy = false, + dependencies = { + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + "folke/snacks.nvim", + "zbirenbaum/copilot.lua", + { + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { "markdown", "Avante" }, + }, + ft = { "markdown", "Avante" }, + }, + }, + opts = { + provider = "copilot", + auto_suggestions_provider = "copilot", + behavior = { + auto_suggestions = false, -- TODO + }, + file_selector = { + provider = "native", -- TODO snacks once it's ready + } + } + } +} diff --git a/nvim/lua/plugins/completion.lua b/nvim/lua/plugins/completion.lua index 50935b5..94e8136 100644 --- a/nvim/lua/plugins/completion.lua +++ b/nvim/lua/plugins/completion.lua @@ -1,60 +1,105 @@ return { { - 'hrsh7th/nvim-cmp', - event = 'VeryLazy', + 'saghen/blink.cmp', dependencies = { - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-cmdline', - 'hrsh7th/cmp-path', - 'hrsh7th/cmp-nvim-lsp', - 'ray-x/cmp-treesitter', - 'L3MON4D3/luasnip', - 'saadparwaiz1/cmp_luasnip', + "yetone/avante.nvim", + 'saghen/blink.compat', + 'rafamadriz/friendly-snippets', + 'giuxtaposition/blink-cmp-copilot', + 'mikavilpas/blink-ripgrep.nvim' }, - config = function() - local cmp = require('cmp') - cmp.setup { - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, - [''] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, - [''] = cmp.mapping.confirm { - select = true, - behavior = cmp.SelectBehavior.Insert - }, - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp', keyword_length = 1 }, - { name = 'luasnip' }, - { name = 'buffer' }, - { name = 'path' }, - { name = 'treesitter', keyword_length = 3 }, - }), - } - - cmp.setup.cmdline({ '/', '?' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' }, - }, + config = function(_, opts) + require('blink.cmp').setup(opts) + vim.api.nvim_create_autocmd('User', { + pattern = 'BlinkCmpMenuOpen', + callback = function() + require("copilot.suggestion").dismiss() + vim.b.copilot_suggestion_hidden = true + end, }) - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' }, - { name = 'buffer' }, - { name = 'cmdline' }, - }), - matching = { disallow_symbol_nonprefix_matching = false }, + vim.api.nvim_create_autocmd('User', { + pattern = 'BlinkCmpMenuClose', + callback = function() + vim.b.copilot_suggestion_hidden = false + end, }) end, + opts = { + sources = { + default = { + "lsp", + "path", + "snippets", + "buffer", + "ripgrep", + "avante_commands", + "avante_mentions", + "avante_files" + }, + providers = { + ripgrep = { + module = "blink-ripgrep", + name = "rg", + score_offset = -10, + }, + avante_commands = { + name = "avante_commands", + module = "blink.compat.source", + score_offset = 90, + opts = {}, + }, + avante_files = { + name = "avante_files", + module = "blink.compat.source", + score_offset = 100, + opts = {}, + }, + avante_mentions = { + name = "avante_mentions", + module = "blink.compat.source", + score_offset = 1000, + opts = {}, + } + } + }, + keymap = { + [""] = { "show", "select_and_accept" } + }, + completion = { + documentation = { + auto_show = true, + auto_show_delay_ms = 100 + }, + list = { + selection = { + preselect = false, + auto_insert = true, + } + }, + accept = { + auto_brackets = { + enabled = true + } + }, + menu = { + draw = { + treesitter = { "lsp" }, + columns = { + { "label", "label_description", gap = 1 }, + { "source_name", "kind", gap = 1 } + }, + } + }, + trigger = { + show_on_keyword = false, + } + }, + appearance = { + use_nvim_cmp_as_default = true, + }, + signature = { enabled = true } + } }, { 'L3MON4D3/luasnip', diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index f499f4a..e42d743 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -2,45 +2,27 @@ return { { 'folke/trouble.nvim', event = 'VeryLazy', - dependencies = { - 'artemave/workspace-diagnostics.nvim', - }, - config = function() - require('trouble').setup() - vim.keymap.set( - 'n', + config = true, + keys = { + { 'de', 'Trouble diagnostics toggle focus=true', { noremap = true, desc = 'Trouble diagnostics' } - ) - vim.keymap.set( - 'n', - 'dE', - 'Trouble diagnostics toggle focus=true filter.buf=0', - { noremap = true, desc = 'Trouble diagnostics (currrent buffer)' } - ) - vim.keymap.set('n', 'dw', function() - for _, client in ipairs(vim.lsp.get_clients { bufnr = 0 }) do - require('workspace-diagnostics').populate_workspace_diagnostics(client, 0) - end - end, { noremap = true, desc = 'Populate Trouble workspace diagnostics' }) - end, + } + } }, { 'neovim/nvim-lspconfig', event = 'VeryLazy', dependencies = { - 'hrsh7th/cmp-nvim-lsp', - 'artemave/workspace-diagnostics.nvim', + 'folke/snacks.nvim', + 'saghen/blink.cmp', }, config = function() local lspconfig = require('lspconfig') - lspconfig.util.default_config.capabilities = vim.tbl_deep_extend( - 'force', - lspconfig.util.default_config.capabilities, - require('cmp_nvim_lsp').default_capabilities() - ) + local capabilities = require("blink.cmp").get_lsp_capabilities() lspconfig.gopls.setup { + capabilities = capabilities, settings = { gopls = { gofumpt = true, @@ -66,10 +48,12 @@ return { }, }, } - lspconfig.jedi_language_server.setup {} - lspconfig.nil_ls.setup {} - lspconfig.phpactor.setup {} + lspconfig.jedi_language_server.setup { capabilities = capabilities } + lspconfig.nil_ls.setup { capabilities = capabilities } + lspconfig.phpactor.setup { capabilities = capabilities } + lspconfig.ruby_ls.setup { capabilities = capabilities } lspconfig.lua_ls.setup { + capabilities = capabilities, on_init = function(client) local path = client.workspace_folders[1].name if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then @@ -120,27 +104,27 @@ return { vim.keymap.set( 'n', 'dd', - 'Telescope lsp_definitions', + function() Snacks.picker.diagnostics() end, + { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP diagnostics' } + ) + vim.keymap.set( + 'n', + 'df', + function() Snacks.picker.lsp_definitions() end, { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP definitions' } ) vim.keymap.set( 'n', 'di', - 'Telescope lsp_implementations', + function() Snacks.picker.lsp_implementations() end, { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP implementations' } ) vim.keymap.set( 'n', 'dr', - 'Telescope lsp_references', + function() Snacks.picker.lsp_references() end, { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP references' } ) - vim.keymap.set( - 'n', - 'ds', - 'Telescope lsp_document_symbols', - { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP symbols' } - ) vim.keymap.set( 'n', 'dl', @@ -168,7 +152,6 @@ return { }) vim.lsp.codelens.refresh { bufnr = bufnr } end - require('workspace-diagnostics').populate_workspace_diagnostics(client, bufnr) end, }) vim.api.nvim_exec_autocmds('FileType', {}) diff --git a/nvim/lua/plugins/mini.lua b/nvim/lua/plugins/mini.lua index 64d4d8a..76819f4 100644 --- a/nvim/lua/plugins/mini.lua +++ b/nvim/lua/plugins/mini.lua @@ -46,18 +46,11 @@ return { require('mini.ai').setup() require('mini.align').setup() require('mini.bracketed').setup() - require('mini.comment').setup() require('mini.icons').setup() require('mini.surround').setup() - require('mini.jump2d').setup { mappings = { start_jumping = 'S' } } require('mini.splitjoin').setup { detect = { separator = '[,;\n]' }, } require('mini.trailspace').setup() vim.api.nvim_create_user_command('Trim', require('mini.trailspace').trim, {}) - local indent = require('mini.indentscope') - indent.setup { - symbol = '│', - draw = { delay = 0 }, - } local miniclue = require('mini.clue') miniclue.setup { @@ -101,14 +94,6 @@ return { } vim.keymap.set('n', 'nm', map.toggle, { noremap = true, desc = 'minimap open' }) - require('mini.notify').setup { - window = { - winblend = 0, - config = { - border = 'double', - }, - }, - } local files = require("mini.files") files.setup { mappings = { diff --git a/nvim/lua/plugins/misc.lua b/nvim/lua/plugins/misc.lua index 6d36966..715bf34 100644 --- a/nvim/lua/plugins/misc.lua +++ b/nvim/lua/plugins/misc.lua @@ -9,16 +9,6 @@ return { event = 'VeryLazy', config = true, }, - { - 'akinsho/toggleterm.nvim', - event = 'VeryLazy', - opts = { - open_mapping = [[]], - direction = 'float', - close_on_exit = true, - autochdir = true, - }, - }, { 'jinh0/eyeliner.nvim', event = 'VeryLazy', @@ -27,13 +17,6 @@ return { vim.api.nvim_set_hl(0, 'EyelinerSecondary', { underline = true }) end, }, - { - 'OXY2DEV/markview.nvim', - event = 'VeryLazy', - dependencies = { - "nvim-treesitter/nvim-treesitter", - } - }, { 'tiagovla/scope.nvim', event = 'VeryLazy', config = true }, { 'sindrets/diffview.nvim', @@ -65,16 +48,12 @@ return { disable_builtin_notifications = true, integrations = { diffview = true, - telescope = true, - fzf_lua = true, }, }, keys = { { 'ng', - function() - require('neogit').open() - end, + function() require('neogit').open() end, { noremap = true, silent = true, desc = 'Neogit' }, }, }, @@ -98,17 +77,17 @@ return { options = { transparent = true, terminal_colors = false, + modules = { + "mini", + "treesitter", + "neogit", + "aerial" + } }, }, config = function(_, opts) require('nightfox').setup(opts) vim.cmd('colorscheme terafox') - vim.api.nvim_set_hl(0, 'MiniNotifyNormal', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniNotifyTitle', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniNotifyBorder', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniMapNormal', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniClueNormal', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniTablineFill', { bg = 'none' }) vim.api.nvim_set_hl(0, 'StatusLine', { bg = 'none' }) vim.api.nvim_set_hl(0, 'StatusLineNC', { bg = 'none' }) vim.api.nvim_set_hl(0, 'GitSignsAdd', { fg = 'green', bold = true }) @@ -179,4 +158,16 @@ return { autojump = true, }, }, + { + 'gbprod/yanky.nvim', + opts = { + ring = { + storage = "memory", + }, + }, + keys = { + { "y", "(YankyYank)", mode = { "n", "x" } }, + { "fp", "YankyRingHistory", { mode = { "n", "x" }, noremap = true, silent = true, desc = 'Pick history (yanky.nvim)' } } + }, + }, } diff --git a/nvim/lua/plugins/snacks.lua b/nvim/lua/plugins/snacks.lua new file mode 100644 index 0000000..22f28bf --- /dev/null +++ b/nvim/lua/plugins/snacks.lua @@ -0,0 +1,76 @@ +return { + { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + opts = { + bigfile = { enabled = true }, + notifier = { enabled = true }, + scope = { enabled = true }, + terminal = { enabled = true }, + indent = { enabled = true }, + input = { enabled = true }, + words = { enabled = true }, + picker = { + enabled = true, + matcher = { frecency = true }, + layout = { + preset = function() + return vim.o.columns >= 120 and "telescope" or "vertical" + end + }, + win = { + input = { + keys = { + ["wq"] = { "close", mode = "i" }, + } + }, + list = { + keys = { + ["wq"] = { "close", mode = "i" }, + } + } + } + }, + }, + config = function(_, opts) + require("snacks").setup(opts) + vim.api.nvim_set_hl(0, 'SnacksPickerDir', { fg = '#cccccc' }) + end, + keys = { + { '', function() Snacks.terminal.toggle() end, mode = { "n", "t" }, noremap = true, desc = 'terminal open' }, + { 'm', function() Snacks.words.jump(1, true) end, noremap = true, desc = 'next reference' }, + { 'M', function() Snacks.words.jump(-1, true) end, noremap = true, desc = 'next reference' }, + { + 'ff', + function() Snacks.picker.smart() end, + { noremap = true, silent = true, desc = 'Fuzzy find git files' } + }, + { + 'fa', + function() Snacks.picker.grep() end, + { noremap = true, silent = true, desc = 'Fuzzy find grep' } + }, + { + 'f8', + function() Snacks.picker.grep_word() end, + { noremap = true, silent = true, desc = 'Fuzzy find grep word' } + }, + { + 'f?', + function() Snacks.picker.pickers() end, + { noremap = true, silent = true, desc = 'See all pickers' } + }, + { + 'f.', + function() Snacks.picker.resume() end, + { noremap = true, silent = true, desc = 'Fuzzy find resume' } + }, + { + '', + function() Snacks.picker.buffers() end, + { noremap = true, silent = true, desc = 'Fuzzy find buffers' } + }, + } + } +} diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua deleted file mode 100644 index f121f96..0000000 --- a/nvim/lua/plugins/telescope.lua +++ /dev/null @@ -1,140 +0,0 @@ -return { - { - 'nvim-telescope/telescope-fzf-native.nvim', - event = 'VeryLazy', - build = 'make', - }, - { - 'nvim-telescope/telescope.nvim', - event = 'VeryLazy', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope-fzf-native.nvim', - 'nvim-treesitter/nvim-treesitter', - 'tiagovla/scope.nvim', - { - 'gbprod/yanky.nvim', - config = function() - local mapping = require("yanky.telescope.mapping") - require("yanky").setup({ - picker = { - telescope = { - mappings = { - default = mapping.set_register( - require("yanky.utils").get_default_register() - ), - }, - }, - }, - ring = { - storage = "memory", - }, - }) - vim.keymap.set({ "n", "x" }, "y", "(YankyYank)") - end, - }, - }, - config = function() - local telescope = require('telescope') - local actions = require('telescope.actions') - telescope.setup { - defaults = { - layout_strategy = 'vertical', - layout_config = { width = 0.90 }, - prompt_title = false, - results_title = false, - preview_title = false, - vimgrep_arguments = { - 'rg', - '-L', - '--color=never', - '--no-heading', - '--hidden', - '--with-filename', - '--line-number', - '--column', - '--smart-case', - }, - preview = { treesitter = true }, - path_display = { 'truncate' }, - mappings = { - i = { - ['wq'] = actions.close, - [''] = actions.close, - [''] = actions.move_selection_previous, - [''] = actions.move_selection_next, - }, - }, - }, - } - telescope.load_extension('fzf') - telescope.load_extension('scope') - telescope.load_extension('yank_history') - - local b = require('telescope.builtin') - -- Fall back to find_files if not in a git repo - local project_files = function() - local opts = {} -- define here if you want to define something - local ok = pcall(b.git_files, opts) - if not ok then - b.find_files(opts) - end - end - - vim.keymap.set( - 'n', - 'ff', - project_files, - { noremap = true, silent = true, desc = 'Fuzzy find git files' } - ) - vim.keymap.set( - 'n', - 'fg', - b.find_files, - { noremap = true, silent = true, desc = 'Fuzzy find files' } - ) - vim.keymap.set( - 'n', - 'fa', - b.live_grep, - { noremap = true, silent = true, desc = 'Fuzzy find grep' } - ) - vim.keymap.set( - 'n', - 'f8', - b.grep_string, - { noremap = true, silent = true, desc = 'Fuzzy find grep current word' } - ) - vim.keymap.set( - 'n', - 'f?', - b.builtin, - { noremap = true, silent = true, desc = 'See all pickers' } - ) - vim.keymap.set( - 'n', - 'f.', - b.resume, - { noremap = true, silent = true, desc = 'Fuzzy find resume' } - ) - vim.keymap.set( - 'n', - 'fs', - b.lsp_document_symbols, - { noremap = true, silent = true, desc = 'Fuzzy find treesitter objects' } - ) - vim.keymap.set( - 'n', - '', - 'Telescope scope buffers', - { noremap = true, silent = true, desc = 'Pick buffers (scope.nvim)' } - ) - vim.keymap.set( - 'n', - 'fp', - 'Telescope yank_history', - { noremap = true, silent = true, desc = 'Pick history (yanky.nvim)' } - ) - end, - }, -}