# 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, `<leader>lf` formats on demand.
#
# <leader>ff / fg / fb telescope: files / live grep / buffers
# - oil: edit the parent directory as a buffer
# <leader>e / E file tree / reveal current file
# <leader>o / a oil floating window / start screen
# gd gr K <leader>ca LSP: definition, references, hover, code action
# <leader>lf format buffer
# ]c [c <leader>gp gitsigns: next/previous hunk, preview hunk
# gcc gc{motion} comment.nvim
# <Esc> clear search highlight
# <space> 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 = "<leader>rn";
codeAction = "<leader>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" "<cmd>Telescope find_files<CR>")
(button "r" "Recent files" "<cmd>Telescope oldfiles<CR>")
(button "g" "Search project" "<cmd>Telescope live_grep<CR>")
(button "e" "File tree" "<cmd>Neotree toggle<CR>")
(button "c" "NixOS configuration" "<cmd>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<CR>")
(button "n" "New file" "<cmd>enew<CR>")
(button "q" "Quit" "<cmd>quit<CR>")
];
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 = "<C-\\>";
setupOpts.direction = "float";
};
debugger.nvim-dap = {
enable = true;
ui.enable = true;
mappings = {
continue = "<F5>";
toggleBreakpoint = "<F9>";
stepOver = "<F10>";
stepInto = "<F11>";
stepOut = "<F12>";
};
};
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 = "<cmd>Oil<CR>"; desc = "Open parent directory"; silent = true; }
{ key = "<leader>e"; mode = "n"; action = "<cmd>Neotree toggle<CR>"; desc = "File tree"; silent = true; }
{ key = "<leader>E"; mode = "n"; action = "<cmd>Neotree reveal<CR>"; desc = "Reveal file in tree"; silent = true; }
{ key = "<leader>o"; mode = "n"; action = "<cmd>Oil --float<CR>"; desc = "Directory editor (oil)"; silent = true; }
{ key = "<leader>a"; mode = "n"; action = "<cmd>Alpha<CR>"; desc = "Start screen"; silent = true; }
{ key = "<leader>fr"; mode = "n"; action = "<cmd>Telescope oldfiles<CR>"; desc = "Recent files"; silent = true; }
{ key = "<leader>lf"; mode = "n"; action = "<cmd>lua require('lz.n').trigger_load('conform-nvim'); require('conform').format({ async = true, lsp_format = 'fallback' })<CR>"; desc = "Format buffer"; silent = true; }
{ key = "<leader>xx"; mode = "n"; action = "<cmd>lua vim.diagnostic.setqflist()<CR>"; desc = "Project diagnostics"; silent = true; }
{ key = "<Esc>"; mode = "n"; action = "<cmd>nohlsearch<CR>"; desc = "Clear search highlight"; silent = true; }
{ key = "<leader>w"; mode = "n"; action = "<cmd>write<CR>"; desc = "Save"; silent = true; }
{ key = "<leader>q"; mode = "n"; action = "<cmd>quit<CR>"; desc = "Quit"; silent = true; }
{ key = "<C-h>"; mode = "n"; action = "<C-w>h"; desc = "Window left"; }
{ key = "<C-j>"; mode = "n"; action = "<C-w>j"; desc = "Window down"; }
{ key = "<C-k>"; mode = "n"; action = "<C-w>k"; desc = "Window up"; }
{ key = "<C-l>"; mode = "n"; action = "<C-w>l"; desc = "Window right"; }
{ key = "<"; mode = "v"; action = "<gv"; desc = "Dedent, keep selection"; }
{ key = ">"; mode = "v"; action = ">gv"; desc = "Indent, keep selection"; }
];
};
};
}
;
}