diff --git a/modules/programs/tui/neovim/components/autocomplete.nix b/modules/programs/tui/neovim/components/autocomplete.nix index 650ea1a..4a7789a 100644 --- a/modules/programs/tui/neovim/components/autocomplete.nix +++ b/modules/programs/tui/neovim/components/autocomplete.nix @@ -14,6 +14,7 @@ sops.secrets.github_token = {}; programs.nvf.settings.vim = { + autopairs.nvim-autopairs.enable = true; snippets.luasnip.enable = true; autocomplete.blink-cmp = { @@ -119,6 +120,8 @@ end ''; + ripgrep.score_offset = -5; + words.enabled = mkLuaInline '' function() return vim.tbl_contains({ "gitcommit", "jjdescription", "markdown" }, vim.bo.filetype) diff --git a/modules/programs/tui/neovim/components/bufferline.nix b/modules/programs/tui/neovim/components/bufferline.nix index 80d4442..1058ab7 100644 --- a/modules/programs/tui/neovim/components/bufferline.nix +++ b/modules/programs/tui/neovim/components/bufferline.nix @@ -12,7 +12,7 @@ # keep-sorted start block=yes newline_separated=yes programs.nvf.settings.vim.luaConfigPreSnippets = [ '' - function _G.LCB(bufnr, clicks, button, modifiers) + function _G.close_lualine_buffer(bufnr, clicks, button, modifiers) if button ~= "l" then return end @@ -58,7 +58,7 @@ fmt = mkLuaInline '' function(name, context) - return string.format('%s%%%d@v:lua.LCB@ %%T', name, context.bufnr) + return string.format('%s%%%d@v:lua.close_lualine_buffer@ %%T', name, context.bufnr) end ''; } diff --git a/modules/programs/tui/neovim/components/dashboard.nix b/modules/programs/tui/neovim/components/dashboard.nix index a66e4af..5d9797c 100644 --- a/modules/programs/tui/neovim/components/dashboard.nix +++ b/modules/programs/tui/neovim/components/dashboard.nix @@ -122,7 +122,6 @@ programs.nvf.settings.vim = { # keep-sorted start block=yes newline_separated=yes - # Provide CLI tools consumed by dashboard terminal sections. extraPackages = with pkgs; [ # keep-sorted start dashboard-gh-notify @@ -130,16 +129,6 @@ # keep-sorted end ]; - # Global shortcut to reopen the startup dashboard at any time. - keymaps = [ - { - key = "d"; - mode = "n"; - action = "lua _G.open_snacks_dashboard()"; - desc = "Open dashboard"; - } - ]; - utility.snacks-nvim.setupOpts.dashboard = { enable = true; @@ -156,7 +145,6 @@ ''; preset = { - # Route dashboard pickers through the shared Telescope entry point. pick = mkLuaInline '' function(cmd, opts) cmd = cmd == "files" and "find_files" or cmd @@ -165,7 +153,6 @@ ''; # keep-sorted start block=yes newline_separated=yes - # Define dashboard shortcuts explicitly and omit the default Config entry. keys = [ { icon = " "; @@ -256,7 +243,6 @@ gap = 1; padding = 1; } - # Render startup metrics based on loaded runtime plugins. (mkLuaInline '' function() local metrics = vim.g.snacks_dashboard_metrics or {} @@ -325,6 +311,14 @@ ]; }; + keymaps = [ + { + key = "d"; + mode = "n"; + action = "lua _G.open_snacks_dashboard()"; + desc = "Open dashboard"; + } + ]; }; # keep-sorted end }; diff --git a/modules/programs/tui/neovim/components/diagnostics.nix b/modules/programs/tui/neovim/components/diagnostics.nix index 3649dee..766bb63 100644 --- a/modules/programs/tui/neovim/components/diagnostics.nix +++ b/modules/programs/tui/neovim/components/diagnostics.nix @@ -1,8 +1,113 @@ { flake.modules.homeManager.neovim = { + # keep-sorted start + config, + lib, + # keep-sorted end + ... + }: let + inherit (builtins) div; + inherit + (lib) + # keep-sorted start + fromHexString + substring + toHexString + optionalString + stringLength + removePrefix + # keep-sorted end + ; + inherit (lib.generators) mkLuaInline; + + colors = config.lib.stylix.colors.withHashtag; + + # Blends a subtle severity tint into the editor background. + tintBackground = foreground: let + channel = color: offset: fromHexString (substring offset 2 (removePrefix "#" color)); + blendedChannel = offset: div ((channel colors.base00 offset * 85) + (channel foreground offset * 15)) 100; + toPaddedHex = value: let + hex = toHexString value; + in + optionalString (stringLength hex == 1) "0" + hex; + in "#${toPaddedHex (blendedChannel 0)}${toPaddedHex (blendedChannel 2)}${toPaddedHex (blendedChannel 4)}"; + in { programs.nvf.settings.vim = { - lsp.trouble.enable = true; utility.snacks-nvim.setupOpts.statuscolumn.enable = true; + + diagnostics = { + enable = true; + config = { + virtual_lines = false; + + signs.text = mkLuaInline '' + { + [vim.diagnostic.severity.ERROR] = "󰅙 ", + [vim.diagnostic.severity.WARN] = "󰀦 ", + [vim.diagnostic.severity.INFO] = "󰋼 ", + [vim.diagnostic.severity.HINT] = "󰌵 ", + } + ''; + + virtual_text = { + prefix = mkLuaInline '' + function(diagnostic, index, total) + if index ~= total then + return "" + end + + local icons = { + [vim.diagnostic.severity.ERROR] = "󰅙", + [vim.diagnostic.severity.WARN] = "󰀦", + [vim.diagnostic.severity.INFO] = "󰋼", + [vim.diagnostic.severity.HINT] = "󰌵", + } + return icons[diagnostic.severity] + end + ''; + source = false; + spacing = 2; + }; + }; + }; + + highlight = { + # keep-sorted start block=yes newline_separated=yes + DiagnosticVirtualTextError = { + # keep-sorted start + bg = tintBackground colors.base08; + fg = colors.base08; + # keep-sorted end + }; + DiagnosticVirtualTextHint = { + # keep-sorted start + bg = tintBackground colors.base0B; + fg = colors.base0B; + # keep-sorted end + }; + DiagnosticVirtualTextInfo = { + # keep-sorted start + bg = tintBackground colors.base0C; + fg = colors.base0C; + # keep-sorted end + }; + DiagnosticVirtualTextWarn = { + # keep-sorted start + bg = tintBackground colors.base0A; + fg = colors.base0A; + # keep-sorted end + }; + # keep-sorted end + }; + + keymaps = [ + { + key = "tv"; + mode = "n"; + action = "lua local config = vim.diagnostic.config(); if config.virtual_text then _G.saved_diagnostic_virtual_text = config.virtual_text; vim.diagnostic.config({ virtual_text = false }) else vim.diagnostic.config({ virtual_text = _G.saved_diagnostic_virtual_text or true }) end"; + desc = "Toggle inline diagnostics"; + } + ]; }; }; } diff --git a/modules/programs/tui/neovim/components/dim.nix b/modules/programs/tui/neovim/components/dim.nix index ff535a1..94a79b6 100644 --- a/modules/programs/tui/neovim/components/dim.nix +++ b/modules/programs/tui/neovim/components/dim.nix @@ -1,6 +1,11 @@ { flake.modules.homeManager.neovim = { programs.nvf.settings.vim = { + utility.snacks-nvim.setupOpts.dim = { + enable = true; + scope.min_size = 8; + }; + keymaps = [ { key = "td"; @@ -9,11 +14,6 @@ desc = "Dim Toggle"; } ]; - - utility.snacks-nvim.setupOpts.dim = { - enable = true; - scope.min_size = 8; - }; }; }; } diff --git a/modules/programs/tui/neovim/components/flash.nix b/modules/programs/tui/neovim/components/flash.nix deleted file mode 100644 index b16c16c..0000000 --- a/modules/programs/tui/neovim/components/flash.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ - flake.modules.homeManager.neovim = {lib, ...}: let - inherit (lib.generators) mkLuaInline; - - telescopeFlash = mkLuaInline '' - function(prompt_bufnr) - require("lz.n").trigger_load("flash-nvim") - require("flash").jump({ - pattern = "^", - label = { after = { 0, 0 } }, - search = { - mode = "search", - exclude = { - function(win) - return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= "TelescopeResults" - end, - }, - }, - action = function(match) - local picker = require("telescope.actions.state").get_current_picker(prompt_bufnr) - picker:set_selection(match.pos[1] - 1) - end, - }) - end - ''; - in { - programs.nvf.settings.vim = { - keymaps = [ - { - key = "jd"; - mode = "n"; - action = "lua _G.flash_diagnostics()"; - desc = "Show diagnostics at Flash target"; - } - ]; - - luaConfigPreSnippets = [ - '' - function _G.flash_diagnostics() - require("lz.n").trigger_load("flash-nvim") - require("flash").jump({ - action = function(match, state) - vim.api.nvim_win_call(match.win, function() - vim.api.nvim_win_set_cursor(match.win, match.pos) - vim.diagnostic.open_float() - end) - state:restore() - end, - }) - end - '' - ]; - - telescope.setupOpts.defaults.mappings = { - i."" = telescopeFlash; - n.s = telescopeFlash; - }; - - utility.motion.flash-nvim.enable = true; - }; - }; -} diff --git a/modules/programs/tui/neovim/components/notify.nix b/modules/programs/tui/neovim/components/notify.nix index 1af1443..e28715d 100644 --- a/modules/programs/tui/neovim/components/notify.nix +++ b/modules/programs/tui/neovim/components/notify.nix @@ -7,6 +7,7 @@ ... }: let inherit (lib.generators) mkLuaInline; + inherit (config.programs.nvf.settings.vim.ui) borderType; in { programs.nvf.settings.vim.notify.nvim-notify = { diff --git a/modules/programs/tui/neovim/components/profiler.nix b/modules/programs/tui/neovim/components/profiler.nix index 7ac01d5..6a44200 100644 --- a/modules/programs/tui/neovim/components/profiler.nix +++ b/modules/programs/tui/neovim/components/profiler.nix @@ -1,16 +1,6 @@ { flake.modules.homeManager.neovim = { programs.nvf.settings.vim = { - # keep-sorted start block=yes newline_separated=yes - keymaps = [ - { - key = "pp"; - mode = "n"; - action = "lua Snacks.profiler.toggle()"; - desc = "Profiler Toggle"; - } - ]; - utility.snacks-nvim.setupOpts.profiler = { autocmds = true; @@ -26,7 +16,15 @@ # keep-sorted end }; }; - # keep-sorted end + + keymaps = [ + { + key = "pp"; + mode = "n"; + action = "lua Snacks.profiler.toggle()"; + desc = "Profiler Toggle"; + } + ]; }; }; } diff --git a/modules/programs/tui/neovim/components/statusline.nix b/modules/programs/tui/neovim/components/statusline.nix index d535beb..b3d974d 100644 --- a/modules/programs/tui/neovim/components/statusline.nix +++ b/modules/programs/tui/neovim/components/statusline.nix @@ -1,6 +1,14 @@ { - flake.modules.homeManager.neovim = {lib, ...}: let + flake.modules.homeManager.neovim = { + # keep-sorted start + config, + lib, + # keep-sorted end + ... + }: let inherit (lib.generators) mkLuaInline; + + colors = config.lib.stylix.colors.withHashtag; in { programs.nvf.settings.vim.statusline.lualine.setupOpts = { # keep-sorted start block=yes newline_separated=yes @@ -132,14 +140,15 @@ { "@1" = "diagnostics"; - always_visible = false; + always_visible = true; # keep-sorted start block=yes newline_separated=yes diagnostics_color = { # keep-sorted start - error.fg = "red"; - info.fg = "cyan"; - warn.fg = "yellow"; + error.fg = colors.base08; + hint.fg = colors.base0B; + info.fg = colors.base0C; + warn.fg = colors.base0A; # keep-sorted end }; diff --git a/modules/programs/tui/neovim/languages/csharp.nix b/modules/programs/tui/neovim/languages/csharp.nix new file mode 100644 index 0000000..1872805 --- /dev/null +++ b/modules/programs/tui/neovim/languages/csharp.nix @@ -0,0 +1,8 @@ +{ + flake.modules.homeManager.neovim = { + programs.nvf.settings.vim.languages.csharp = { + enable = true; + format.type = ["csharpier"]; + }; + }; +} diff --git a/modules/programs/tui/neovim/languages/css.nix b/modules/programs/tui/neovim/languages/css.nix index 4f8b5a9..1c251b1 100644 --- a/modules/programs/tui/neovim/languages/css.nix +++ b/modules/programs/tui/neovim/languages/css.nix @@ -3,6 +3,7 @@ programs.nvf.settings.vim = { languages.css = { enable = true; + format.type = ["biome"]; }; diff --git a/modules/programs/tui/neovim/languages/lua.nix b/modules/programs/tui/neovim/languages/lua.nix index 18be57b..3b30b21 100644 --- a/modules/programs/tui/neovim/languages/lua.nix +++ b/modules/programs/tui/neovim/languages/lua.nix @@ -2,6 +2,7 @@ flake.modules.homeManager.neovim = { programs.nvf.settings.vim.languages.lua = { enable = true; + extraDiagnostics.types = ["selene"]; }; }; diff --git a/modules/programs/tui/neovim/languages/other.nix b/modules/programs/tui/neovim/languages/other.nix index 31c55e0..a1b9fee 100644 --- a/modules/programs/tui/neovim/languages/other.nix +++ b/modules/programs/tui/neovim/languages/other.nix @@ -3,7 +3,6 @@ programs.nvf.settings.vim.languages = { # keep-sorted start bash.enable = true; - csharp.enable = true; fish.enable = true; html.enable = true; java.enable = true; diff --git a/modules/programs/tui/neovim/languages/python.nix b/modules/programs/tui/neovim/languages/python.nix index 9577819..0ca1f4e 100644 --- a/modules/programs/tui/neovim/languages/python.nix +++ b/modules/programs/tui/neovim/languages/python.nix @@ -2,8 +2,11 @@ flake.modules.homeManager.neovim = { programs.nvf.settings.vim.languages.python = { enable = true; + + # keep-sorted start format.type = ["ruff"]; lsp.servers = ["ty"]; + # keep-sorted end }; }; } diff --git a/modules/programs/tui/neovim/languages/rust.nix b/modules/programs/tui/neovim/languages/rust.nix index f0b74e4..2fc7b85 100644 --- a/modules/programs/tui/neovim/languages/rust.nix +++ b/modules/programs/tui/neovim/languages/rust.nix @@ -1,16 +1,23 @@ { - flake.modules.homeManager.neovim = { - programs.nvf.settings.vim.languages.rust = { - enable = true; - - extensions.crates-nvim = { + flake.modules.homeManager.neovim = {pkgs, ...}: { + programs.nvf.settings.vim = { + languages.rust = { enable = true; + format.enable = true; + + extensions.crates-nvim = { + enable = true; - setupOpts.popup = { - autofocus = true; - show_version_date = true; + setupOpts.popup = { + autofocus = true; + show_version_date = true; + }; }; }; + + lsp.servers."rust-analyzer".settings."rust-analyzer".rustfmt.overrideCommand = [ + "${pkgs.rustfmt}/bin/rustfmt" + ]; }; }; } diff --git a/modules/programs/tui/neovim/languages/typescript.nix b/modules/programs/tui/neovim/languages/typescript.nix index 5003ce3..af73d61 100644 --- a/modules/programs/tui/neovim/languages/typescript.nix +++ b/modules/programs/tui/neovim/languages/typescript.nix @@ -2,6 +2,7 @@ flake.modules.homeManager.neovim = { programs.nvf.settings.vim.languages.typescript = { enable = true; + extraDiagnostics.types = ["biomejs"]; format.type = ["biome"]; extensions.ts-error-translator = { diff --git a/modules/programs/tui/neovim/settings.nix b/modules/programs/tui/neovim/settings.nix index 14d0d0b..a5650a2 100644 --- a/modules/programs/tui/neovim/settings.nix +++ b/modules/programs/tui/neovim/settings.nix @@ -26,6 +26,7 @@ lsp = { enable = true; formatOnSave = true; + inlayHints.enable = true; # Support embedded code blocks in mixed-language buffers. otter-nvim = {