From ce49423247eb1b685bd4f9394123055b2d29c640 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Sat, 9 May 2026 18:12:17 +0800 Subject: [PATCH] feat(neovim): migrate to nixvim with minimal plugins (#260) Replace bare programs.neovim with programs.nixvim. Only 3 plugins: neo-tree (file explorer), catppuccin (colorscheme), treesitter. Add core editor opts matching helix defaults: clipboard, cursorline, scrolloff, wrap, mouse, undofile, smart search, split direction. Enable 5 LSP servers: nixd, rust-analyzer, gopls, pyright, bashls. Signed-off-by: Ryan Yin --- flake.lock | 61 +++++++++++++- flake.nix | 5 ++ home/base/core/editors/neovim/default.nix | 96 +++++++++++++++++++++-- 3 files changed, 154 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index defe349e..c6ac8e01 100644 --- a/flake.lock +++ b/flake.lock @@ -343,9 +343,30 @@ "type": "github" } }, + "flake-parts_4": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1777932387, + "narHash": "sha256-nUYVPiqrzr36ThiQOAr5MKeGHDBSDM3OFWkz0uDjOvc=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "71a3a77326609675e9f8b51084cf23d5d1945899", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { - "systems": "systems_3" + "systems": "systems_4" }, "locked": { "lastModified": 1681202837, @@ -898,6 +919,28 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "flake-parts": "flake-parts_4", + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems_3" + }, + "locked": { + "lastModified": 1777991353, + "narHash": "sha256-DFwjggMV+nzCZpwK6Obxj9F+P59rbLVowGqHETfctBk=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "7986a276960b4dfaed9bb2c3c438b5ba71ae08f1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, "nu_scripts": { "flake": false, "locked": { @@ -1039,6 +1082,7 @@ "nixpkgs-master": "nixpkgs-master", "nixpkgs-patched": "nixpkgs-patched", "nixpkgs-stable": "nixpkgs-stable", + "nixvim": "nixvim", "nu_scripts": "nu_scripts", "nuenv": "nuenv", "nur-ryan4yin": "nur-ryan4yin", @@ -1153,6 +1197,21 @@ "type": "github" } }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 89c28862..7f3282bf 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # https://github.com/catppuccin/nix catppuccin = { url = "github:catppuccin/nix"; diff --git a/home/base/core/editors/neovim/default.nix b/home/base/core/editors/neovim/default.nix index 5c7074cd..4c1b1461 100644 --- a/home/base/core/editors/neovim/default.nix +++ b/home/base/core/editors/neovim/default.nix @@ -1,14 +1,96 @@ -{ pkgs, ... }: +{ config, nixvim, ... }: { - programs = { - neovim = { + + imports = [ nixvim.homeModules.nixvim ]; + home.shellAliases = { + + vi = "nvim"; + vim = "nvim"; + }; + + programs.nixvim = { + enable = true; + + clipboard.providers.wl-copy.enable = true; + + 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; + }; + + colorschemes.catppuccin = { enable = true; + settings = { + transparent_background = true; + }; + }; - viAlias = true; - vimAlias = true; + plugins.lsp.servers = { + nixd.enable = true; + "rust_analyzer" = { + enable = true; + installCargo = false; + installRustc = false; + }; + gopls.enable = true; + pyright.enable = true; + bashls.enable = true; + }; - withRuby = false; - withPython3 = false; + 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 = { + filesystem = { + filtered_items = { + visible = true; + hide_dotfiles = false; + hide_gitignored = false; + }; + follow_current_file = { + enabled = true; + leave_dirs_open = false; + }; + }; + }; }; }; }