# modules/home/neovim.nix — Neovim through nvf (github:notashelf/nvf): the # editor and its plugins are one Nix-built package, no plugin manager, no # ~/.config/nvim, nothing downloaded on first start. Replaces the AstroNvim # tree the dotfiles carried (2026-10-08): that one pulled ~60 plugins through # lazy.nvim and compiled treesitter parsers on the machine. # # Languages: the ones this machine edits (Nix, Lua # for Hyprland, Python and Bash for the toolbox, Markdown for the vault, and # the config formats). Each gets treesitter, an LSP and a formatter; format on # save is off, `lf` formats on demand. # # ff / fg / fb telescope: files / live grep / buffers # - oil: edit the parent directory as a buffer # e / E file tree / reveal current file # o / a oil floating window / start screen # gd gr K ca LSP: definition, references, hover, code action # lf format buffer # ]c [c gp gitsigns: next/previous hunk, preview hunk # gcc gc{motion} comment.nvim # clear search highlight # leader # # kitty's copy mode (modules/home/terminal.nix) starts plain pkgs.neovim with # -u, so it is unaffected by this configuration and stays instant. { ... }: let theme = import ../_palette.nix; in { flake.homeModules.neovim = { inputs, config, lib, ... }: let flakeExpr = "builtins.getFlake ${builtins.toJSON "${config.home.homeDirectory}/NixDaemon"}"; button = key: label: command: lib.generators.mkLuaInline "require('alpha.themes.dashboard').button(${builtins.toJSON key}, ${builtins.toJSON label}, ${builtins.toJSON command})"; in { imports = [ inputs.nvf.homeManagerModules.default ]; home.sessionVariables.VISUAL = "nvim"; programs.nvf = { enable = true; defaultEditor = true; settings.vim = { viAlias = true; vimAlias = true; theme = { enable = true; name = "rose-pine"; style = "main"; # main, not moon transparent = false; }; # Keep Rosé Pine's highlight roles and apply the shared Gruvpine palette. luaConfigRC.theme = lib.mkIf (theme.name != "rose-pine") (lib.mkForce { before = [ "pluginConfigs" "lazyConfigs" ]; after = [ ]; data = '' require("rose-pine").setup({ dark_variant = "main", palette = { main = vim.fn.json_decode([==[${builtins.toJSON (theme.palette // { highlight_low = theme.palette.hlLow; highlight_med = theme.palette.hlMed; highlight_high = theme.palette.hlHigh; _nc = theme.palette.base; })}]==]) }, styles = { bold = false, italic = false, transparency = false }, }) vim.cmd("colorscheme rose-pine") ''; }); # Editor behaviour lineNumberMode = "relNumber"; searchCase = "smart"; preventJunkFiles = true; undoFile.enable = true; clipboard = { enable = true; registers = "unnamedplus"; providers.wl-copy.enable = true; }; options = { tabstop = 2; shiftwidth = 2; softtabstop = 2; scrolloff = 6; wrap = false; signcolumn = "yes"; cursorline = true; splitbelow = true; splitright = true; updatetime = 250; timeoutlen = 400; }; # All language tools are Nix-built, including nixd's option completion # and basedpyright + Ruff for Python, lua-language-server, # bash-language-server/shfmt, marksman, yaml/json/taplo). lsp = { enable = true; formatOnSave = false; inlayHints.enable = false; mappings = { goToDefinition = "gd"; listReferences = "gr"; hover = "K"; renameSymbol = "rn"; codeAction = "ca"; nextDiagnostic = "]d"; previousDiagnostic = "[d"; # Use Conform's Nix-built formatters, even without an attached LSP. format = null; }; servers = { nixd.settings.nixd = lib.optionalAttrs (config.home.username == "daemonsec") { nixpkgs.expr = "import (${flakeExpr}).inputs.nixpkgs { }"; options = { nixos.expr = "(${flakeExpr}).nixosConfigurations.nixos.options"; home-manager.expr = "(${flakeExpr}).nixosConfigurations.nixos.options.home-manager.users.type.getSubOptions []"; }; }; basedpyright.settings.basedpyright.analysis = { typeCheckingMode = "standard"; diagnosticMode = "openFilesOnly"; autoSearchPaths = true; }; }; }; languages = { enableTreesitter = true; enableFormat = true; nix = { enable = true; lsp.servers = [ "nixd" ]; format.type = [ "nixfmt" ]; # the style this repo is written in extraDiagnostics.enable = true; # statix + deadnix }; lua.enable = true; python = { enable = true; lsp.servers = [ "basedpyright" "ruff" ]; format.type = [ "ruff" ]; dap.enable = true; }; bash.enable = true; markdown.enable = true; yaml.enable = true; json.enable = true; toml.enable = true; }; autocomplete.blink-cmp = { enable = true; friendly-snippets.enable = true; setupOpts = { signature.enabled = true; completion = { documentation.auto_show = true; # Enter only accepts a deliberately selected suggestion. list.selection.preselect = false; }; }; }; telescope.enable = true; git.gitsigns.enable = true; binds.whichKey.enable = true; statusline.lualine.enable = true; autopairs.nvim-autopairs.enable = true; comments.comment-nvim.enable = true; utility.oil-nvim.enable = true; visuals.nvim-web-devicons.enable = true; ui.borders.enable = true; filetree.neo-tree = { enable = true; setupOpts = { close_if_last_window = true; window = { position = "left"; width = 32; }; filesystem = { # Oil handles `nvim .`; the sidebar has its own explicit keys. hijack_netrw_behavior = "disabled"; follow_current_file.enabled = true; filtered_items = { hide_dotfiles = false; hide_gitignored = true; }; }; }; }; dashboard.alpha = { enable = true; theme = null; layout = [ { type = "padding"; val = 3; } { type = "text"; val = [ " ▗▄▄▄ ▗▄▄▄▄ ▄▄▄▖ " " ▜███▙ ▜███▙ ▟███▛ " " ▜███▙ ▜███▙▟███▛ " " ▟█████████████████▙ ▜████▛ ▟▙ " " ▟███████████████████▙ ▜███▙ ▟██▙ " " ▄▄▄▄▖ ▜███▙ ▟███▛ " " ▟███▛ ▜██▛ ▟███▛ " " ▟███▛ ▜▛ ▟███▛ " " ▟███████▛ ▟███████▙ " " ▜██████▛ ▟███████▛ " " ▜███▙ ▜▙ ▟███▛ " " ▜███▙ ▜██▙ ▟███▛ " " ▜███▙ ▜███▙▄▄▄▄▄▄▄▄████▛ " " ▜██▛ ▜███████████████▛ " " ▜▛ ▜█████████████▛ " ]; opts = { position = "center"; hl = "Type"; }; } { type = "padding"; val = 1; } { type = "text"; val = "N I X D A E M O N / C O D E"; opts = { position = "center"; hl = "Title"; }; } { type = "padding"; val = 1; } { type = "group"; val = [ (button "f" "Find file" "Telescope find_files") (button "r" "Recent files" "Telescope oldfiles") (button "g" "Search project" "Telescope live_grep") (button "e" "File tree" "Neotree toggle") (button "c" "NixOS configuration" "lua local p = vim.fn.expand('~/NixDaemon'); if vim.fn.isdirectory(p) == 1 then vim.cmd.cd(p); vim.cmd('Telescope find_files') else vim.notify('No ~/NixDaemon checkout found') end") (button "n" "New file" "enew") (button "q" "Quit" "quit") ]; opts.spacing = 0; } { type = "padding"; val = 1; } { type = "text"; val = "Nix + Python • Space opens your command guide"; opts = { position = "center"; hl = "Comment"; }; } ]; }; terminal.toggleterm = { enable = true; mappings.open = ""; setupOpts.direction = "float"; }; debugger.nvim-dap = { enable = true; ui.enable = true; mappings = { continue = ""; toggleBreakpoint = ""; stepOver = ""; stepInto = ""; stepOut = ""; }; }; luaConfigRC.python-indent = '' vim.api.nvim_create_autocmd("FileType", { pattern = "python", group = vim.api.nvim_create_augroup("nixdaemon_python", { clear = true }), callback = function() vim.bo.expandtab = true vim.bo.tabstop = 4 vim.bo.shiftwidth = 4 vim.bo.softtabstop = 4 end, }) ''; keymaps = [ { key = "-"; mode = "n"; action = "Oil"; desc = "Open parent directory"; silent = true; } { key = "e"; mode = "n"; action = "Neotree toggle"; desc = "File tree"; silent = true; } { key = "E"; mode = "n"; action = "Neotree reveal"; desc = "Reveal file in tree"; silent = true; } { key = "o"; mode = "n"; action = "Oil --float"; desc = "Directory editor (oil)"; silent = true; } { key = "a"; mode = "n"; action = "Alpha"; desc = "Start screen"; silent = true; } { key = "fr"; mode = "n"; action = "Telescope oldfiles"; desc = "Recent files"; silent = true; } { key = "lf"; mode = "n"; action = "lua require('lz.n').trigger_load('conform-nvim'); require('conform').format({ async = true, lsp_format = 'fallback' })"; desc = "Format buffer"; silent = true; } { key = "xx"; mode = "n"; action = "lua vim.diagnostic.setqflist()"; desc = "Project diagnostics"; silent = true; } { key = ""; mode = "n"; action = "nohlsearch"; desc = "Clear search highlight"; silent = true; } { key = "w"; mode = "n"; action = "write"; desc = "Save"; silent = true; } { key = "q"; mode = "n"; action = "quit"; desc = "Quit"; silent = true; } { key = ""; mode = "n"; action = "h"; desc = "Window left"; } { key = ""; mode = "n"; action = "j"; desc = "Window down"; } { key = ""; mode = "n"; action = "k"; desc = "Window up"; } { key = ""; mode = "n"; action = "l"; desc = "Window right"; } { key = "<"; mode = "v"; action = "