feat(neovim): replace nixvim with programs.neovim (#336)

nixvim has been disabled for a long time (programs.nixvim.enable = false), so
drop the flake input (and prune flake.lock). Port the settings it carried to
Home Manager's programs.neovim: opts and per-plugin setup become an initLua
block plus a plugin list. The catppuccin module already provides the
colorscheme, vi stays unmapped, and the plain system neovim package is
untouched so sudo/nvim --clean keep using it.
This commit is contained in:
ryan4yin | 二花 authored and GitHub committed 2026-10-01 21:19:18 +08:00
1 parent 4909f6357b
commit 739cd171ba
3 files changed
+99 -153

No files matched your search

+99 -88
View File
@@ -1,105 +1,116 @@
{
config,
nixvim,
pkgs,
...
}:
let
# Parsers are bundled into the plugin, so no runtime `:TSInstall` is needed.
# Add a language here to get its treesitter highlighting and queries.
treesitter = pkgs.vimPlugins.nvim-treesitter.withPlugins (
p: with p; [
bash
go
json
lua
make
markdown
nix
nu
python
regex
rust
toml
vim
vimdoc
xml
yaml
]
);
in
{
# Neovim config, ported from the old `programs.nixvim` block. The colorscheme
# itself comes from `home/base/core/theme.nix` (catppuccin.nvim is enabled
# there and appends its own plugin + setup).
#
# The plain system package (modules/base/packages.nix) stays in place for
# privileged edits: `sudo` uses the system PATH, so
# `$SUDO_EDITOR = "nvim --clean"` keeps this user config out of root-owned
# files.
programs.neovim = {
enable = true;
vimAlias = true;
imports = [ nixvim.homeModules.nixvim ];
# No python/ruby plugins are configured; use the new explicit defaults
# instead of the legacy providers (and their deprecation warnings).
withPython3 = false;
withRuby = false;
programs.nixvim.nixpkgs.useGlobalPackages = true;
home.shellAliases = {
# Language servers started by `vim.lsp.enable` below; each must be on $PATH.
extraPackages = with pkgs; [
bash-language-server
gopls
nixd
pyright
rust-analyzer
];
vi = "nvim";
vim = "nvim";
};
plugins = [
pkgs.vimPlugins.neo-tree-nvim
pkgs.vimPlugins.nvim-lspconfig
pkgs.vimPlugins.nvim-web-devicons
treesitter
];
programs.nixvim = {
# temporarily disabled: nixvim's manpage pulls nixos-render-docs from nixpkgs,
# which is broken (patch fails to apply) on the current nixpkgs pin
enable = false;
initLua = ''
-- Editor options (previously `programs.nixvim.opts`).
local opt = vim.opt
opt.number = true
opt.relativenumber = true
opt.cursorline = true
opt.signcolumn = "auto"
opt.clipboard = "unnamedplus"
opt.scrolloff = 8
opt.swapfile = false
opt.title = true
opt.titlelen = 20
opt.smartindent = false
opt.mouse = "a"
opt.undofile = true
opt.ignorecase = true
opt.smartcase = true
opt.splitbelow = true
opt.splitright = true
opt.updatetime = 300
opt.wrap = true
opt.linebreak = true
clipboard.providers.wl-copy.enable = pkgs.stdenv.hostPlatform.isLinux;
-- Treesitter highlighting; parsers come from the bundled plugin.
-- `pcall` skips filetypes that have no parser available.
vim.api.nvim_create_autocmd("FileType", {
callback = function()
pcall(vim.treesitter.start)
end,
})
opts = {
number = true;
relativenumber = true;
cursorline = true;
signcolumn = "auto";
clipboard = "unnamedplus";
scrolloff = 8;
swapfile = false;
title = true;
titlelen = 20;
smartindent = false;
mouse = "a";
undofile = true;
ignorecase = true;
smartcase = true;
splitbelow = true;
splitright = true;
updatetime = 300;
wrap = true;
linebreak = true;
};
-- LSP: nvim-lspconfig ships the server definitions, Neovim starts them.
vim.lsp.enable({ "nixd", "rust_analyzer", "gopls", "pyright", "bashls" })
colorschemes.catppuccin = {
enable = true;
settings = {
transparent_background = true;
};
};
plugins.lsp.servers = {
nixd.enable = true;
"rust_analyzer" = {
enable = true;
installCargo = false;
installRustc = false;
};
gopls.enable = true;
pyright.enable = true;
bashls.enable = true;
};
plugins.treesitter = {
enable = true;
grammarPackages = with config.programs.nixvim.plugins.treesitter.package.builtGrammars; [
bash
json
lua
make
markdown
nix
regex
rust
go
python
toml
vim
vimdoc
xml
yaml
nu
];
};
plugins.neo-tree = {
enable = true;
settings = {
-- File explorer.
require("neo-tree").setup({
filesystem = {
filtered_items = {
visible = true;
hide_dotfiles = false;
hide_gitignored = false;
};
visible = true,
hide_dotfiles = false,
hide_gitignored = false,
},
follow_current_file = {
enabled = true;
leave_dirs_open = false;
};
};
};
};
enabled = true,
leave_dirs_open = false,
},
},
})
'';
};
# Matches the old `programs.nixvim.colorschemes.catppuccin.settings`.
catppuccin.nvim.settings.transparent_background = true;
}