From 7632c3686fad9abd8006e6355f02c1794fe0b976 Mon Sep 17 00:00:00 2001 From: Dennis Schoepf Date: Wed, 4 Mar 2026 19:58:45 +0100 Subject: [PATCH] adapts neovim config --- modules/clipboard/default.nix | 23 --- modules/neovim/_editing.nix | 174 ++++++++-------- modules/neovim/_formatter.nix | 96 ++++----- modules/neovim/_git.nix | 54 ++--- modules/neovim/_lsp.nix | 364 +++++++++++++++++----------------- modules/neovim/_options.nix | 90 ++++----- modules/neovim/_picker.nix | 332 +++++++++++++++---------------- 7 files changed, 554 insertions(+), 579 deletions(-) delete mode 100644 modules/clipboard/default.nix diff --git a/modules/clipboard/default.nix b/modules/clipboard/default.nix deleted file mode 100644 index abebd44..0000000 --- a/modules/clipboard/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ inputs, ... }: -{ - flake.modules.nixos.clipboard = - { pkgs, ... }: - - { - environment.systemPackages = with pkgs; [ - wl-clipboard - cliphist - ]; - - home-manager.sharedModules = [ - inputs.self.modules.homeManager.clipboard - ]; - }; - - flake.modules.homeManager.clipboard = - { pkgs, ... }: - { - # Watch clipboard and store history via cliphist - services.cliphist.enable = true; - }; -} diff --git a/modules/neovim/_editing.nix b/modules/neovim/_editing.nix index 9b343fe..7ef4f3e 100644 --- a/modules/neovim/_editing.nix +++ b/modules/neovim/_editing.nix @@ -1,96 +1,96 @@ { pkgs, ... }: { - programs.nixvim = { - plugins.sleuth.enable = true; - plugins.nvim-surround.enable = true; - plugins.flash.enable = true; + programs.nixvim = { + plugins.sleuth.enable = true; + plugins.nvim-surround.enable = true; + plugins.flash.enable = true; - plugins.blink-pairs = { - enable = true; - }; + plugins.blink-pairs = { + enable = true; + }; - # Workaround: Neovim 0.11.x does not implement the is? / is-not? treesitter - # predicates, but newer grammar query files (tree-sitter-nix, tree-sitter-javascript) - # use (#is-not? local) to scope highlights to non-local identifiers. - # Register no-op handlers to suppress the error; remove once Neovim - # ships with built-in support for these predicates. - extraConfigLua = /* lua */ '' - -- (#is?) always returns false (node never "is" something) - vim.treesitter.query.add_predicate("is?", function() - return false - end, { force = true }) - -- (#is-not?) always returns true (node is always "not" something) - vim.treesitter.query.add_predicate("is-not?", function() - return true - end, { force = true }) - ''; + # Workaround: Neovim 0.11.x does not implement the is? / is-not? treesitter + # predicates, but newer grammar query files (tree-sitter-nix, tree-sitter-javascript) + # use (#is-not? local) to scope highlights to non-local identifiers. + # Register no-op handlers to suppress the error; remove once Neovim + # ships with built-in support for these predicates. + extraConfigLua = /* lua */ '' + -- (#is?) always returns false (node never "is" something) + vim.treesitter.query.add_predicate("is?", function() + return false + end, { force = true }) + -- (#is-not?) always returns true (node is always "not" something) + vim.treesitter.query.add_predicate("is-not?", function() + return true + end, { force = true }) + ''; - plugins.treesitter = { - enable = true; - highlight.enable = true; - indent.enable = true; - folding.enable = true; + plugins.treesitter = { + enable = true; + highlight.enable = true; + indent.enable = true; + folding.enable = true; - grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [ - angular - bash - css - html - javascript - jsdoc - json - lua - make - markdown - markdown_inline - go - gomod - gotmpl - python - styled - tsx - typescript - nix - regex - toml - vim - vimdoc - xml - yaml - ]; - }; - - plugins.substitute = { - enable = true; - luaConfig.post = /* lua */ '' - local sub = require("substitute") - vim.keymap.set("n", "s", sub.operator, { noremap = true }) - vim.keymap.set("n", "ss", sub.line, { noremap = true }) - vim.keymap.set("n", "S", sub.eol, { noremap = true }) - vim.keymap.set("x", "s", sub.visual, { noremap = true }) - ''; - }; - - extraPlugins = [ - pkgs.vimPlugins.vim-cool - ]; - - autoCmd = [ - { - callback.__raw = "function() vim.highlight.on_yank() end"; - event = [ - "TextYankPost" - ]; - } - { - event = [ "FileType" ]; - pattern = "qf"; - callback.__raw = /* lua */ '' - function() - vim.keymap.set("n", "", "", { buffer = true }) - end - ''; - } + grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [ + angular + bash + css + html + javascript + jsdoc + json + lua + make + markdown + markdown_inline + go + gomod + gotmpl + python + styled + tsx + typescript + nix + regex + toml + vim + vimdoc + xml + yaml ]; }; + + plugins.substitute = { + enable = true; + luaConfig.post = /* lua */ '' + local sub = require("substitute") + vim.keymap.set("n", "s", sub.operator, { noremap = true }) + vim.keymap.set("n", "ss", sub.line, { noremap = true }) + vim.keymap.set("n", "S", sub.eol, { noremap = true }) + vim.keymap.set("x", "s", sub.visual, { noremap = true }) + ''; + }; + + extraPlugins = [ + pkgs.vimPlugins.vim-cool + ]; + + autoCmd = [ + { + callback.__raw = "function() vim.highlight.on_yank() end"; + event = [ + "TextYankPost" + ]; + } + { + event = [ "FileType" ]; + pattern = "qf"; + callback.__raw = /* lua */ '' + function() + vim.keymap.set("n", "", "", { buffer = true }) + end + ''; + } + ]; + }; } diff --git a/modules/neovim/_formatter.nix b/modules/neovim/_formatter.nix index c94bb31..d3fe959 100644 --- a/modules/neovim/_formatter.nix +++ b/modules/neovim/_formatter.nix @@ -1,55 +1,55 @@ { pkgs, ... }: { - programs.nixvim.plugins.conform-nvim = { - enable = true; - settings = { - formatters_by_ft = { - typescriptreact = { - __unkeyed-1 = "biome-check"; - __unkeyed-2 = "prettierd"; - stop_after_first = true; - }; - astro = [ "prettierd" ]; - typescript = { - __unkeyed-1 = "biome-check"; - __unkeyed-2 = "prettierd"; - stop_after_first = true; - }; - javascript = { - __unkeyed-1 = "biome-check"; - __unkeyed-2 = "prettierd"; - stop_after_first = true; - }; - javascriptreact = { - __unkeyed-1 = "biome-check"; - __unkeyed-2 = "prettierd"; - stop_after_first = true; - }; - html = [ "prettierd" ]; - htmlangular = [ "prettierd" ]; - css = { - __unkeyed-1 = "biome-check"; - __unkeyed-2 = "prettierd"; - stop_after_first = true; - }; - yaml = [ "prettierd" ]; - markdown = [ "prettierd" ]; - json = { - __unkeyed-1 = "biome-check"; - __unkeyed-2 = "prettierd"; - stop_after_first = true; - }; - lua = [ "stylua" ]; - go = [ "goimports" ]; - gomod = [ "goimports" ]; - gowork = [ "goimports" ]; - gotmpl = [ "goimports" ]; + programs.nixvim.plugins.conform-nvim = { + enable = true; + settings = { + formatters_by_ft = { + typescriptreact = { + __unkeyed-1 = "biome-check"; + __unkeyed-2 = "prettierd"; + stop_after_first = true; }; - format_on_save = { - timeout_ms = 500; - lsp_format = "fallback"; + astro = [ "prettierd" ]; + typescript = { + __unkeyed-1 = "biome-check"; + __unkeyed-2 = "prettierd"; + stop_after_first = true; }; + javascript = { + __unkeyed-1 = "biome-check"; + __unkeyed-2 = "prettierd"; + stop_after_first = true; + }; + javascriptreact = { + __unkeyed-1 = "biome-check"; + __unkeyed-2 = "prettierd"; + stop_after_first = true; + }; + html = [ "prettierd" ]; + htmlangular = [ "prettierd" ]; + css = { + __unkeyed-1 = "biome-check"; + __unkeyed-2 = "prettierd"; + stop_after_first = true; + }; + yaml = [ "prettierd" ]; + markdown = [ "prettierd" ]; + json = { + __unkeyed-1 = "biome-check"; + __unkeyed-2 = "prettierd"; + stop_after_first = true; + }; + lua = [ "stylua" ]; + go = [ "goimports" ]; + gomod = [ "goimports" ]; + gowork = [ "goimports" ]; + gotmpl = [ "goimports" ]; + }; + format_on_save = { + timeout_ms = 500; + lsp_format = "fallback"; }; - extraPackages = [ pkgs.stylua ]; }; + extraPackages = [ pkgs.stylua ]; + }; } diff --git a/modules/neovim/_git.nix b/modules/neovim/_git.nix index 69fa283..598339c 100644 --- a/modules/neovim/_git.nix +++ b/modules/neovim/_git.nix @@ -1,31 +1,31 @@ { ... }: { - programs.nixvim = { - plugins.gitportal = { - enable = true; - }; - - keymaps = [ - { - key = "gll"; - action = "GitPortal"; - options.desc = "Open line in Git provider"; - } - { - key = "gll"; - action = "GitPortal"; - options.desc = "Open line in Git provider"; - } - { - key = "gly"; - action = "GitPortal copy_link_to_clipboard"; - options.desc = "Copy link to line at Git provider"; - } - { - key = "glo"; - action = "GitPortal open_link"; - options.desc = "Open link to line at Git provider"; - } - ]; + programs.nixvim = { + plugins.gitportal = { + enable = true; }; + + keymaps = [ + { + key = "gll"; + action = "GitPortal"; + options.desc = "Open line in Git provider"; + } + { + key = "gll"; + action = "GitPortal"; + options.desc = "Open line in Git provider"; + } + { + key = "gly"; + action = "GitPortal copy_link_to_clipboard"; + options.desc = "Copy link to line at Git provider"; + } + { + key = "glo"; + action = "GitPortal open_link"; + options.desc = "Open link to line at Git provider"; + } + ]; + }; } diff --git a/modules/neovim/_lsp.nix b/modules/neovim/_lsp.nix index 92f1d18..4c5ca71 100644 --- a/modules/neovim/_lsp.nix +++ b/modules/neovim/_lsp.nix @@ -1,200 +1,200 @@ { pkgs, ... }: { - programs.nixvim = { - plugins.lspconfig.enable = true; + programs.nixvim = { + plugins.lspconfig.enable = true; - lsp = { - enable = true; + lsp = { + enable = true; - servers = { - lua_ls = { - enable = true; - package = pkgs.lua-language-server; - packageFallback = true; - }; - nil_ls = { - enable = true; - package = pkgs.nil; - packageFallback = true; - }; - gopls = { - enable = true; - package = pkgs.gopls; - packageFallback = true; - }; - ts_ls = { - enable = true; - package = pkgs.typescript-language-server; - packageFallback = true; - }; - jsonls = { - enable = true; - package = pkgs.vscode-langservers-extracted; - packageFallback = true; - }; - cssls = { - enable = true; - package = pkgs.vscode-langservers-extracted; - packageFallback = true; - }; - html = { - enable = true; - package = pkgs.vscode-langservers-extracted; - packageFallback = true; - }; - astro = { - enable = true; - package = pkgs.astro-language-server; - packageFallback = true; - config.init_options.typescript.tsdk = "${pkgs.typescript}/lib/node_modules/typescript/lib"; - }; - eslint = { - enable = true; - package = pkgs.vscode-langservers-extracted; - packageFallback = true; - config = { - root_markers = [ - ".eslintrc" - ".eslintrc.js" - ".eslintrc.cjs" - ".eslintrc.yaml" - ".eslintrc.yml" - ".eslintrc.json" - "eslint.config.js" - "eslint.config.mjs" - "eslint.config.cjs" - "eslint.config.ts" - "eslint.config.mts" - "eslint.config.cts" - "package.json" - ]; - settings = { - validate = "on"; - useESLintClass = false; - experimental = { - useFlatConfig = true; + servers = { + lua_ls = { + enable = true; + package = pkgs.lua-language-server; + packageFallback = true; + }; + nil_ls = { + enable = true; + package = pkgs.nil; + packageFallback = true; + }; + gopls = { + enable = true; + package = pkgs.gopls; + packageFallback = true; + }; + ts_ls = { + enable = true; + package = pkgs.typescript-language-server; + packageFallback = true; + }; + jsonls = { + enable = true; + package = pkgs.vscode-langservers-extracted; + packageFallback = true; + }; + cssls = { + enable = true; + package = pkgs.vscode-langservers-extracted; + packageFallback = true; + }; + html = { + enable = true; + package = pkgs.vscode-langservers-extracted; + packageFallback = true; + }; + astro = { + enable = true; + package = pkgs.astro-language-server; + packageFallback = true; + config.init_options.typescript.tsdk = "${pkgs.typescript}/lib/node_modules/typescript/lib"; + }; + eslint = { + enable = true; + package = pkgs.vscode-langservers-extracted; + packageFallback = true; + config = { + root_markers = [ + ".eslintrc" + ".eslintrc.js" + ".eslintrc.cjs" + ".eslintrc.yaml" + ".eslintrc.yml" + ".eslintrc.json" + "eslint.config.js" + "eslint.config.mjs" + "eslint.config.cjs" + "eslint.config.ts" + "eslint.config.mts" + "eslint.config.cts" + "package.json" + ]; + settings = { + validate = "on"; + useESLintClass = false; + experimental = { + useFlatConfig = true; + }; + codeActionOnSave = { + enable = false; + mode = "all"; + }; + format = true; + quiet = false; + onIgnoredFiles = "off"; + rulesCustomizations = { }; + run = "onType"; + problems = { + shortenToSingleLine = false; + }; + nodePath = ""; + workingDirectory = { + mode = "location"; + }; + codeAction = { + disableRuleComment = { + enable = true; + location = "separateLine"; }; - codeActionOnSave = { - enable = false; - mode = "all"; - }; - format = true; - quiet = false; - onIgnoredFiles = "off"; - rulesCustomizations = { }; - run = "onType"; - problems = { - shortenToSingleLine = false; - }; - nodePath = ""; - workingDirectory = { - mode = "location"; - }; - codeAction = { - disableRuleComment = { - enable = true; - location = "separateLine"; - }; - showDocumentation = { - enable = true; - }; + showDocumentation = { + enable = true; }; }; - handlers = { - "eslint/openDoc".__raw = /* lua */ '' - function(_, result) - if result then - vim.ui.open(result.url) - end - return {} + }; + handlers = { + "eslint/openDoc".__raw = /* lua */ '' + function(_, result) + if result then + vim.ui.open(result.url) end - ''; - "eslint/confirmESLintExecution" = /* lua */ '' - function(_, result) - if not result then - return - end - return 4 -- approved - end - ''; - "eslint/probeFailed" = /* lua */ '' - function() - vim.notify("[lspconfig] ESLint probe failed.", vim.log.levels.WARN) - return {} - end - ''; - "eslint/noLibrary" = /* lua */ '' - function() - vim.notify("[lspconfig] Unable to find ESLint library.", vim.log.levels.WARN) - return {} - end - ''; - }; - on_new_config.__raw = /* lua */ '' - function(config, new_root_dir) - -- This function is called when LSP attaches to a new buffer - -- Set the working directory to the root where eslint config is found - config.settings = config.settings or {} - config.settings.workspaceFolder = { - uri = new_root_dir, - name = vim.fn.fnamemodify(new_root_dir, ":t"), - } - - -- Detect flat config - local flat_config_files = { - "eslint.config.js", - "eslint.config.mjs", - "eslint.config.cjs", - "eslint.config.ts", - "eslint.config.mts", - "eslint.config.cts", - } - - for _, file in ipairs(flat_config_files) do - local config_path = new_root_dir .. "/" .. file - if vim.uv.fs_stat(config_path) then - config.settings.experimental = config.settings.experimental or {} - config.settings.experimental.useFlatConfig = true - break - end - end - - -- Support Yarn PnP - local pnp_cjs = new_root_dir .. "/.pnp.cjs" - local pnp_js = new_root_dir .. "/.pnp.js" - if vim.uv.fs_stat(pnp_cjs) or vim.uv.fs_stat(pnp_js) then - config.cmd = vim.list_extend({ "yarn", "exec" }, config.cmd or {}) + return {} + end + ''; + "eslint/confirmESLintExecution" = /* lua */ '' + function(_, result) + if not result then + return end + return 4 -- approved + end + ''; + "eslint/probeFailed" = /* lua */ '' + function() + vim.notify("[lspconfig] ESLint probe failed.", vim.log.levels.WARN) + return {} + end + ''; + "eslint/noLibrary" = /* lua */ '' + function() + vim.notify("[lspconfig] Unable to find ESLint library.", vim.log.levels.WARN) + return {} end ''; }; - }; - biome = { - enable = true; - package = null; - packageFallback = false; + on_new_config.__raw = /* lua */ '' + function(config, new_root_dir) + -- This function is called when LSP attaches to a new buffer + -- Set the working directory to the root where eslint config is found + config.settings = config.settings or {} + config.settings.workspaceFolder = { + uri = new_root_dir, + name = vim.fn.fnamemodify(new_root_dir, ":t"), + } + + -- Detect flat config + local flat_config_files = { + "eslint.config.js", + "eslint.config.mjs", + "eslint.config.cjs", + "eslint.config.ts", + "eslint.config.mts", + "eslint.config.cts", + } + + for _, file in ipairs(flat_config_files) do + local config_path = new_root_dir .. "/" .. file + if vim.uv.fs_stat(config_path) then + config.settings.experimental = config.settings.experimental or {} + config.settings.experimental.useFlatConfig = true + break + end + end + + -- Support Yarn PnP + local pnp_cjs = new_root_dir .. "/.pnp.cjs" + local pnp_js = new_root_dir .. "/.pnp.js" + if vim.uv.fs_stat(pnp_cjs) or vim.uv.fs_stat(pnp_js) then + config.cmd = vim.list_extend({ "yarn", "exec" }, config.cmd or {}) + end + end + ''; }; }; - - keymaps = [ - { - key = "ca"; - lspBufAction = "code_action"; - } - { - key = "e"; - action = "lua vim.diagnostic.open_float()"; - } - ]; + biome = { + enable = true; + package = null; + packageFallback = false; + }; }; - # Define diagnostic appearance - diagnostic.settings = { - virtual_text = false; - signs = true; - underline = true; - update_in_insert = false; - severity_sort = false; - }; + keymaps = [ + { + key = "ca"; + lspBufAction = "code_action"; + } + { + key = "e"; + action = "lua vim.diagnostic.open_float()"; + } + ]; }; + + # Define diagnostic appearance + diagnostic.settings = { + virtual_text = false; + signs = true; + underline = true; + update_in_insert = false; + severity_sort = false; + }; + }; } diff --git a/modules/neovim/_options.nix b/modules/neovim/_options.nix index e2b1fad..7d8e3c1 100644 --- a/modules/neovim/_options.nix +++ b/modules/neovim/_options.nix @@ -1,50 +1,48 @@ { ... }: { - programs.nixvim = { - globals = { - mapleader = " "; - maplocalleader = " "; - }; - - clipboard.register = "unnamedplus"; - - opts = { - backup = false; - cmdheight = 1; - conceallevel = 0; - fileencoding = "utf-8"; - hlsearch = true; - ignorecase = true; - mouse = "a"; - pumheight = 10; - showmode = false; - smartindent = true; - breakindent = true; - showtabline = 0; - smartcase = true; - splitbelow = true; - splitright = true; - swapfile = false; - termguicolors = true; - timeoutlen = 600; - undofile = true; - updatetime = 230; - writebackup = false; - expandtab = true; - shiftwidth = 2; - tabstop = 2; - cursorline = true; - number = true; - relativenumber = true; - numberwidth = 2; - signcolumn = "yes"; - linebreak = true; - breakat = " ^I!@*-+;:,./?"; - scrolloff = 4; - sidescrolloff = 4; - winbar = ""; - foldlevel = 99; - foldlevelstart = 99; - }; + programs.nixvim = { + globals = { + mapleader = " "; + maplocalleader = " "; }; + + clipboard.register = "unnamedplus"; + + opts = { + backup = false; + cmdheight = 1; + conceallevel = 0; + fileencoding = "utf-8"; + hlsearch = true; + ignorecase = true; + mouse = "a"; + pumheight = 10; + showmode = false; + showtabline = 0; + smartcase = true; + splitbelow = true; + splitright = true; + swapfile = false; + termguicolors = true; + timeoutlen = 600; + undofile = true; + updatetime = 230; + writebackup = false; + expandtab = true; + shiftwidth = 2; + tabstop = 2; + cursorline = true; + number = true; + relativenumber = true; + numberwidth = 2; + signcolumn = "yes"; + linebreak = true; + breakat = " ^I!@*-+;:,./?"; + scrolloff = 4; + sidescrolloff = 4; + winbar = ""; + foldlevel = 99; + foldlevelstart = 99; + }; + }; } diff --git a/modules/neovim/_picker.nix b/modules/neovim/_picker.nix index c1f30b7..2f13fc8 100644 --- a/modules/neovim/_picker.nix +++ b/modules/neovim/_picker.nix @@ -1,172 +1,172 @@ { pkgs, ... }: { - programs.nixvim = { - plugins.oil = { - enable = true; - settings = { - keymaps = { - "q" = "actions.close"; - }; - columns = [ - "icon" - "permissions" - "size" - "mtime" - ]; + programs.nixvim = { + plugins.oil = { + enable = true; + settings = { + keymaps = { + "q" = "actions.close"; }; + columns = [ + "icon" + "permissions" + "size" + "mtime" + ]; }; - - extraPlugins = [ pkgs.vimPlugins.snacks-nvim ]; - extraConfigLua = /* lua */ '' - local Snacks = require("snacks"); - local filter_lsp_definitions = function(item) - if item.file:match("/react/ts5.0/") or item.file:match("react.d.ts") then - return false - end - return true - end - - Snacks.setup({ - bigfile = { enabled = true }, - bufdelete = { enabled = true }, - git = { enabled = true }, - indent = { enabled = true }, - input = { enabled = true }, - notifier = { enabled = true }, - picker = { - enabled = true, - prompt = "λ ", - layout = { preset = "ivy" }, - }, - statuscolumn = { enabled = true }, - }) - ''; - - keymaps = [ - # Git - { - key = "gb"; - action.__raw = "function() Snacks.git.blame_line() end"; - options.desc = "Show git blame for current line"; - } - # Picker - { - key = "."; - action.__raw = "function() Snacks.picker.files({ hidden = true }) end"; - options.desc = "Files"; - } - { - key = ""; - action.__raw = "function() Snacks.picker.git_files() end"; - options.desc = "Git files"; - } - # Find - { - key = "fr"; - action.__raw = "function() Snacks.picker.recent() end"; - options.desc = "Recent"; - } - { - key = "fp"; - action.__raw = "function() Snacks.picker.projects() end"; - options.desc = "Projects"; - } - { - key = "bb"; - action.__raw = "function() Snacks.picker.buffers() end"; - options.desc = "List buffers"; - } - { - key = "bd"; - action.__raw = "function() Snacks.bufdelete() end"; - options.desc = "Delete buffer"; - } - { - key = "bD"; - action.__raw = "function() Snacks.bufdelete.all() end"; - options.desc = "Delete all buffers"; - } - { - key = "bo"; - action.__raw = "function() Snacks.bufdelete.other() end"; - options.desc = "Delete other buffers"; - } - # Search - { - key = "ss"; - action.__raw = "function() Snacks.picker.grep() end"; - options.desc = "Grep"; - } - { - mode = [ - "n" - "x" - ]; - key = "sw"; - action.__raw = "function() Snacks.picker.grep_word() end"; - options.desc = "Visual selection or word"; - } - { - key = "su"; - action.__raw = "function() Snacks.picker.undo() end"; - options.desc = "Undo History"; - } - # Diagnostics - { - key = "td"; - action.__raw = "function() Snacks.picker.diagnostics_buffer() end"; - options.desc = "Buffer Diagnostics"; - } - { - key = "ta"; - action.__raw = "function() Snacks.picker.diagnostics() end"; - options.desc = "Diagnostics"; - } - # LSP - { - key = "gd"; - action.__raw = "function() Snacks.picker.lsp_definitions({ filter = { filter = filter_lsp_definitions } }) end"; - options.desc = "Goto Definition"; - } - { - key = "gD"; - action.__raw = "function() Snacks.picker.lsp_declarations() end"; - options.desc = "Goto Declaration"; - } - { - key = "grr"; - action.__raw = "function() Snacks.picker.lsp_references() end"; - options = { - desc = "References"; - nowait = true; - }; - } - { - key = "gI"; - action.__raw = "function() Snacks.picker.lsp_implementations() end"; - options.desc = "Goto Implementation"; - } - { - key = "gy"; - action.__raw = "function() Snacks.picker.lsp_type_definitions() end"; - options.desc = "Goto T[y]pe Definition"; - } - # Notifications and highlights - { - key = "on"; - action.__raw = "function() Snacks.notifier.show_history() end"; - options.desc = "Open notification history"; - } - { - key = "oh"; - action.__raw = "function() Snacks.picker.highlights() end"; - options.desc = "List highlights"; - } - { - key = "n"; - action = "Oil"; - options.desc = "Opens file explorer"; - } - ]; }; + + extraPlugins = [ pkgs.vimPlugins.snacks-nvim ]; + extraConfigLua = /* lua */ '' + local Snacks = require("snacks"); + local filter_lsp_definitions = function(item) + if item.file:match("/react/ts5.0/") or item.file:match("react.d.ts") then + return false + end + return true + end + + Snacks.setup({ + bigfile = { enabled = true }, + bufdelete = { enabled = true }, + git = { enabled = true }, + indent = { enabled = true }, + input = { enabled = true }, + notifier = { enabled = true }, + picker = { + enabled = true, + prompt = "λ ", + layout = { preset = "ivy" }, + }, + statuscolumn = { enabled = true }, + }) + ''; + + keymaps = [ + # Git + { + key = "gb"; + action.__raw = "function() Snacks.git.blame_line() end"; + options.desc = "Show git blame for current line"; + } + # Picker + { + key = "."; + action.__raw = "function() Snacks.picker.files({ hidden = true }) end"; + options.desc = "Files"; + } + { + key = ""; + action.__raw = "function() Snacks.picker.git_files() end"; + options.desc = "Git files"; + } + # Find + { + key = "fr"; + action.__raw = "function() Snacks.picker.recent() end"; + options.desc = "Recent"; + } + { + key = "fp"; + action.__raw = "function() Snacks.picker.projects() end"; + options.desc = "Projects"; + } + { + key = "bb"; + action.__raw = "function() Snacks.picker.buffers() end"; + options.desc = "List buffers"; + } + { + key = "bd"; + action.__raw = "function() Snacks.bufdelete() end"; + options.desc = "Delete buffer"; + } + { + key = "bD"; + action.__raw = "function() Snacks.bufdelete.all() end"; + options.desc = "Delete all buffers"; + } + { + key = "bo"; + action.__raw = "function() Snacks.bufdelete.other() end"; + options.desc = "Delete other buffers"; + } + # Search + { + key = "ss"; + action.__raw = "function() Snacks.picker.grep() end"; + options.desc = "Grep"; + } + { + mode = [ + "n" + "x" + ]; + key = "sw"; + action.__raw = "function() Snacks.picker.grep_word() end"; + options.desc = "Visual selection or word"; + } + { + key = "su"; + action.__raw = "function() Snacks.picker.undo() end"; + options.desc = "Undo History"; + } + # Diagnostics + { + key = "td"; + action.__raw = "function() Snacks.picker.diagnostics_buffer() end"; + options.desc = "Buffer Diagnostics"; + } + { + key = "ta"; + action.__raw = "function() Snacks.picker.diagnostics() end"; + options.desc = "Diagnostics"; + } + # LSP + { + key = "gd"; + action.__raw = "function() Snacks.picker.lsp_definitions({ filter = { filter = filter_lsp_definitions } }) end"; + options.desc = "Goto Definition"; + } + { + key = "gD"; + action.__raw = "function() Snacks.picker.lsp_declarations() end"; + options.desc = "Goto Declaration"; + } + { + key = "grr"; + action.__raw = "function() Snacks.picker.lsp_references() end"; + options = { + desc = "References"; + nowait = true; + }; + } + { + key = "gI"; + action.__raw = "function() Snacks.picker.lsp_implementations() end"; + options.desc = "Goto Implementation"; + } + { + key = "gy"; + action.__raw = "function() Snacks.picker.lsp_type_definitions() end"; + options.desc = "Goto T[y]pe Definition"; + } + # Notifications and highlights + { + key = "on"; + action.__raw = "function() Snacks.notifier.show_history() end"; + options.desc = "Open notification history"; + } + { + key = "oh"; + action.__raw = "function() Snacks.picker.highlights() end"; + options.desc = "List highlights"; + } + { + key = "n"; + action = "Oil"; + options.desc = "Opens file explorer"; + } + ]; + }; }