neovim.nix (5537B)
1 # modules/home/neovim.nix — Neovim through nvf (github:notashelf/nvf): the 2 # editor and its plugins are one Nix-built package, no plugin manager, no 3 # ~/.config/nvim, nothing downloaded on first start. Replaces the AstroNvim 4 # tree the dotfiles carried (2026-10-08): that one pulled ~60 plugins through 5 # lazy.nvim and compiled treesitter parsers on the machine. 6 # 7 # Kept deliberately small. Languages: the ones this machine edits (Nix, Lua 8 # for Hyprland, Python and Bash for the toolbox, Markdown for the vault, and 9 # the config formats). Each gets treesitter, an LSP and a formatter; format on 10 # save is off, `<leader>lf` formats on demand. 11 # 12 # <leader>ff / fg / fb telescope: files / live grep / buffers 13 # - oil: edit the parent directory as a buffer 14 # <leader>e oil in a floating window 15 # gd gr K <leader>ca LSP: definition, references, hover, code action (nvf defaults) 16 # <leader>lf format buffer 17 # ]c [c <leader>gp gitsigns: next/previous hunk, preview hunk 18 # gcc gc{motion} comment.nvim 19 # <Esc> clear search highlight 20 # <space> leader 21 # 22 # kitty's copy mode (modules/home/terminal.nix) starts plain pkgs.neovim with 23 # -u, so it is unaffected by this configuration and stays instant. 24 { ... }: 25 let theme = import ../_palette.nix; in 26 { 27 flake.homeModules.neovim = 28 { inputs, pkgs, lib, ... }: 29 { 30 imports = [ inputs.nvf.homeManagerModules.default ]; 31 32 programs.nvf = { 33 enable = true; 34 settings.vim = { 35 viAlias = true; 36 vimAlias = true; 37 38 theme = { 39 enable = true; 40 name = "rose-pine"; 41 style = "main"; # main, not moon 42 transparent = false; 43 }; 44 45 # Keep Rosé Pine's highlight roles and apply the shared Gruvpine palette. 46 luaConfigRC.theme = lib.mkIf (theme.name != "rose-pine") 47 (lib.mkForce { 48 before = [ "pluginConfigs" "lazyConfigs" ]; 49 after = [ ]; 50 data = '' 51 require("rose-pine").setup({ 52 dark_variant = "main", 53 palette = { main = vim.fn.json_decode([==[${builtins.toJSON (theme.palette // { 54 highlight_low = theme.palette.hlLow; 55 highlight_med = theme.palette.hlMed; 56 highlight_high = theme.palette.hlHigh; 57 _nc = theme.palette.base; 58 })}]==]) }, 59 styles = { bold = false, italic = false, transparency = false }, 60 }) 61 vim.cmd("colorscheme rose-pine") 62 ''; 63 }); 64 65 # Editor behaviour 66 lineNumberMode = "relNumber"; 67 searchCase = "smart"; 68 preventJunkFiles = true; 69 undoFile.enable = true; 70 clipboard = { 71 enable = true; 72 registers = "unnamedplus"; 73 providers.wl-copy.enable = true; 74 }; 75 options = { 76 tabstop = 2; 77 shiftwidth = 2; 78 softtabstop = 2; 79 scrolloff = 6; 80 wrap = false; 81 signcolumn = "yes"; 82 cursorline = true; 83 splitbelow = true; 84 splitright = true; 85 updatetime = 250; 86 timeoutlen = 400; 87 }; 88 89 # Languages: treesitter + LSP + formatter each, chosen by nvf's defaults 90 # (nil for Nix, basedpyright/ruff for Python, lua-language-server, 91 # bash-language-server/shfmt, marksman, yaml/json/taplo). 92 lsp = { 93 enable = true; 94 formatOnSave = false; 95 inlayHints.enable = false; 96 }; 97 languages = { 98 enableTreesitter = true; 99 enableFormat = true; 100 nix = { 101 enable = true; 102 format.type = [ "nixfmt" ]; # the style this repo is written in 103 }; 104 lua.enable = true; 105 python.enable = true; 106 bash.enable = true; 107 markdown.enable = true; 108 yaml.enable = true; 109 json.enable = true; 110 toml.enable = true; 111 }; 112 113 autocomplete.blink-cmp.enable = true; 114 telescope.enable = true; 115 git.gitsigns.enable = true; 116 binds.whichKey.enable = true; 117 statusline.lualine.enable = true; 118 autopairs.nvim-autopairs.enable = true; 119 comments.comment-nvim.enable = true; 120 utility.oil-nvim.enable = true; 121 visuals.nvim-web-devicons.enable = true; 122 ui.borders.enable = true; 123 124 keymaps = [ 125 { key = "-"; mode = "n"; action = "<cmd>Oil<CR>"; desc = "Open parent directory"; silent = true; } 126 { key = "<leader>e"; mode = "n"; action = "<cmd>Oil --float<CR>"; desc = "Explorer (oil)"; silent = true; } 127 { key = "<Esc>"; mode = "n"; action = "<cmd>nohlsearch<CR>"; desc = "Clear search highlight"; silent = true; } 128 { key = "<leader>w"; mode = "n"; action = "<cmd>write<CR>"; desc = "Save"; silent = true; } 129 { key = "<leader>q"; mode = "n"; action = "<cmd>quit<CR>"; desc = "Quit"; silent = true; } 130 { key = "<C-h>"; mode = "n"; action = "<C-w>h"; desc = "Window left"; } 131 { key = "<C-j>"; mode = "n"; action = "<C-w>j"; desc = "Window down"; } 132 { key = "<C-k>"; mode = "n"; action = "<C-w>k"; desc = "Window up"; } 133 { key = "<C-l>"; mode = "n"; action = "<C-w>l"; desc = "Window right"; } 134 { key = "<"; mode = "v"; action = "<gv"; desc = "Dedent, keep selection"; } 135 { key = ">"; mode = "v"; action = ">gv"; desc = "Indent, keep selection"; } 136 ]; 137 }; 138 }; 139 } 140 ; 141 }