From b535f8ad4a8737ed25c1fdd77bc8b39d592cb766 Mon Sep 17 00:00:00 2001 From: Michael Thomson Date: Wed, 13 Nov 2024 18:32:57 -0500 Subject: [PATCH] nixvim Signed-off-by: Michael Thomson --- flake.lock | 340 ++++++++++++++++-- flake.nix | 6 +- hosts/macbook/home.nix | 2 +- modules/home-manager/nixvim/default.nix | 223 ++++++++++++ .../nixvim/plugins/treesitter.nix | 0 5 files changed, 541 insertions(+), 30 deletions(-) create mode 100644 modules/home-manager/nixvim/default.nix create mode 100644 modules/home-manager/nixvim/plugins/treesitter.nix diff --git a/flake.lock b/flake.lock index 88365bc..666cc9c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "devshell": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1728330715, + "narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=", + "owner": "numtide", + "repo": "devshell", + "rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -32,6 +53,20 @@ "type": "github" } }, + "flake-compat_3": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -74,6 +109,45 @@ "type": "indirect" } }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730504689, + "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "506278e768c2a08bec68eb62932193e341f55c90", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "git-hooks": { "inputs": { "flake-compat": "flake-compat_2", @@ -88,11 +162,41 @@ ] }, "locked": { - "lastModified": 1730302582, - "narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=", + "lastModified": 1731363552, + "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf", + "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "git-hooks_2": { + "inputs": { + "flake-compat": [ + "nixvim", + "flake-compat" + ], + "gitignore": "gitignore_2", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730814269, + "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "d70155fdc00df4628446352fc58adc640cd705c2", "type": "github" }, "original": { @@ -123,6 +227,28 @@ "type": "github" } }, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "hercules-ci-effects": { "inputs": { "flake-parts": "flake-parts_2", @@ -132,11 +258,11 @@ ] }, "locked": { - "lastModified": 1730229744, - "narHash": "sha256-2W//PmgocN9lplDJ7WoiP9EcrfUxqvtxplCAqlwvquY=", + "lastModified": 1730903510, + "narHash": "sha256-mnynlrPeiW0nUQ8KGZHb3WyxAxA3Ye/BH8gMjdoKP6E=", "owner": "hercules-ci", "repo": "hercules-ci-effects", - "rev": "d70658494391994c7b32e8fe5610dae76737e4df", + "rev": "b89ac4d66d618b915b1f0a408e2775fe3821d141", "type": "github" }, "original": { @@ -152,11 +278,11 @@ ] }, "locked": { - "lastModified": 1730837930, - "narHash": "sha256-0kZL4m+bKBJUBQse0HanewWO0g8hDdCvBhudzxgehqc=", + "lastModified": 1731535640, + "narHash": "sha256-2EckCJn4wxran/TsRiCOFcmVpep2m9EBKl99NBh2GnM=", "owner": "nix-community", "repo": "home-manager", - "rev": "2f607e07f3ac7e53541120536708e824acccfaa8", + "rev": "35b055009afd0107b69c286fca34d2ad98940d57", "type": "github" }, "original": { @@ -165,6 +291,55 @@ "type": "github" } }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731235328, + "narHash": "sha256-NjavpgE9/bMe/ABvZpyHIUeYF1mqR5lhaep3wB79ucs=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "60bb110917844d354f3c18e05450606a435d2d10", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729958008, + "narHash": "sha256-EiOq8jF4Z/zQe0QYVc3+qSKxRK//CFHMB84aYrYGwEs=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "9fd01aad037f345350eab2cd45e1946cc66da4eb", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.6", + "repo": "ixx", + "type": "github" + } + }, "neovim-nightly-overlay": { "inputs": { "flake-compat": "flake-compat", @@ -175,11 +350,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1730823220, - "narHash": "sha256-qQAYFkeoqvMpGj2lwBuAKQpN1mSF5tXRfgGwbQsnO6Y=", + "lastModified": 1731500640, + "narHash": "sha256-bxtcbR33ftcSA+7+E52i+cqWAdoCQNFpxR1180HRX48=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "d64f5c5f3f16383773638dc48e717c17301e30ce", + "rev": "1329ddcc318e77e4629eb629d39f7f7c9b2632f6", "type": "github" }, "original": { @@ -191,11 +366,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1730762793, - "narHash": "sha256-1dSHnG7rCtubItTt4Zayj7Z3oZY3b/TQDUcQbdS6ZH4=", + "lastModified": 1731454739, + "narHash": "sha256-ihuASDo2BVZpUpsW6Z8Ll/xvczRPgGT/EGrrNt7NnwU=", "owner": "neovim", "repo": "neovim", - "rev": "f5b84c1a44069af70a3f0c3330e7cc25b224ad93", + "rev": "1128d75550fa0b481b8953a194bae890d733a166", "type": "github" }, "original": { @@ -211,11 +386,11 @@ ] }, "locked": { - "lastModified": 1730878299, - "narHash": "sha256-0VIz/3PKaylSIoRdOE07kkT1tMXgqaybXrfIS2Xz+so=", + "lastModified": 1731454423, + "narHash": "sha256-TtwvgFxUa0wyptLhQbKaixgNW1UXf3+TDqfX3Kp63oM=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "98e7dba87238e4fa4eac609dc44f07dab40661c4", + "rev": "6c71c49e2448e51ad830ed211024e6d0edc50116", "type": "github" }, "original": { @@ -224,13 +399,34 @@ "type": "github" } }, + "nix-darwin_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731153869, + "narHash": "sha256-3Ftf9oqOypcEyyrWJ0baVkRpvQqroK/SVBFLvU3nPuc=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "5c74ab862c8070cbf6400128a1b56abb213656da", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, "nixos-hardware": { "locked": { - "lastModified": 1730886862, - "narHash": "sha256-wCZtRGM1NGxq6VG4+TMzfsa4cuG2VJVtowtYuWW5W3g=", + "lastModified": 1731403644, + "narHash": "sha256-T9V7CTucjRZ4Qc6pUEV/kpgNGzQbHWfGcfK6JJLfUeI=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "90642a0deae927fa911d49d4f7c5616257105141", + "rev": "f6581f1c3b137086e42a08a906bdada63045f991", "type": "github" }, "original": { @@ -242,11 +438,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1730643484, - "narHash": "sha256-FZN70acnL7V0gfmtLTdsi4J1o51bfaBYDTi3E7b7z3U=", + "lastModified": 1731245184, + "narHash": "sha256-vmLS8+x+gHRv1yzj3n+GTAEObwmhxmkkukB2DwtJRdU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4ae2e647537bcdbb82265469442713d066675275", + "rev": "aebe249544837ce42588aa4b2e7972222ba12e8f", "type": "github" }, "original": { @@ -258,11 +454,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1730785428, - "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "lastModified": 1731139594, + "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", "type": "github" }, "original": { @@ -272,13 +468,101 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat_3", + "flake-parts": "flake-parts_3", + "git-hooks": "git-hooks_2", + "home-manager": "home-manager_2", + "nix-darwin": "nix-darwin_2", + "nixpkgs": [ + "nixpkgs" + ], + "nuschtosSearch": "nuschtosSearch", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1731527733, + "narHash": "sha256-12OpSgbLDiKmxvBXwVracIfGI9FpjFyHpa1r0Ho+NFA=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "f11a877bcc1d66cc8bd7990c704f91c1e99c7d08", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731060242, + "narHash": "sha256-43yLsOm/wxBbfYSNDWVJeVv5Ij+23X3BIjFUfsdx/6M=", + "owner": "NuschtOS", + "repo": "search", + "rev": "ef493352f9e1f051e01a55c062731503a6b36b4e", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, "root": { "inputs": { "home-manager": "home-manager", "neovim-nightly-overlay": "neovim-nightly-overlay", "nix-darwin": "nix-darwin", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_2", + "nixvim": "nixvim" + } + }, + "systems": { + "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": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730321837, + "narHash": "sha256-vK+a09qq19QNu2MlLcvN4qcRctJbqWkX7ahgPZ/+maI=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "746901bb8dba96d154b66492a29f5db0693dbfcc", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index e96a817..4de34df 100644 --- a/flake.nix +++ b/flake.nix @@ -13,9 +13,13 @@ }; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = inputs@{ self, nixpkgs, home-manager, nix-darwin, nixos-hardware, ... }: { + outputs = inputs@{ self, nixpkgs, home-manager, nix-darwin, nixos-hardware, nixvim, ... }: { nixosConfigurations = { desktop = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; diff --git a/hosts/macbook/home.nix b/hosts/macbook/home.nix index eba214e..7998045 100644 --- a/hosts/macbook/home.nix +++ b/hosts/macbook/home.nix @@ -3,7 +3,7 @@ { imports = [ ../../modules/home-manager/git - ../../modules/home-manager/neovim + ../../modules/home-manager/nixvim ../../modules/home-manager/emacs ../../modules/home-manager/wezterm ../../modules/home-manager/kitty diff --git a/modules/home-manager/nixvim/default.nix b/modules/home-manager/nixvim/default.nix new file mode 100644 index 0000000..3f497c2 --- /dev/null +++ b/modules/home-manager/nixvim/default.nix @@ -0,0 +1,223 @@ +{ inputs, pkgs, config, ... }: + +{ + imports = [ + inputs.nixvim.homeManagerModules.nixvim + ]; + + programs.nixvim = { + enable = true; + defaultEditor = true; + + colorschemes = { + kanagawa = { + enable = true; + }; + }; + + globals = { + mapleader = " "; + maplocalleader = " "; + }; + + opts = { + number = true; + relativenumber = true; + mouse = "a"; + showmode = false; + laststatus = 3; + swapfile = false; + + clipboard = { + register = "unnamedplus"; + }; + + breakindent = true; + undofile = true; + ignorecase = true; + smartcase = true; + signcolumn = "yes"; + updatetime = 50; + timeoutlen = 300; + inccommand = "split"; + cursorline = true; + scrolloff = 10; + hlsearch = true; + }; + + keymaps = [ + { + mode = "n"; + key = "fe"; + action = "Oil"; + } + { + mode = "n"; + key = "ff"; + action = "Pick files"; + } + { + mode = "n"; + key = "fg"; + action = "Pick grep_live"; + } + { + mode = "n"; + key = "u"; + action = "UndotreeToggle"; + } + ]; + + plugins = { + web-devicons.enable = true; + sleuth = { + enable = true; + }; + treesitter = { + enable = true; + settings = { + highlight = { + enable = true; + additional_vim_regex_highlighting = true; + }; + indent = { + enable = true; + }; + autotag = { + enable = true; + }; + }; + }; + harpoon = { + enable = true; + keymaps = { + addFile = "a"; + toggleQuickMenu = "e"; + navNext = "k"; + navPrev = "j"; + }; + }; + mini = { + enable = true; + modules = { + ai = { + n_lines = 500; + }; + surround = {}; + statusline = { + use_icons = true; + }; + comment = {}; + trailspace = {}; + pick = {}; + }; + }; + friendly-snippets = { + enable = true; + }; + cmp = { + enable = true; + + settings = { + snippet = { + expand = '' + function(args) + require('luasnip').lsp_expand(args.body) + end + ''; + }; + completion = { + completeopt = "menu,menuone,noinsert"; + }; + mapping = { + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.confirm { select = true }"; + "" = "cmp.mapping.complete {}"; + "" = '' + cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { 'i', 's' }) + ''; + "" = '' + cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }) + ''; + }; + sources = [ + { + name = "luasnip"; + } + { + name = "nvim_lsp"; + } + { + name = "path"; + } + ]; + }; + }; + oil = { + enable = true; + }; + undotree = { + enable = true; + }; + tmux-navigator = { + enable = true; + }; + cmp-nvim-lsp = { + enable = true; + }; + fidget = { + enable = true; + }; + lsp = { + enable = true; + servers = { + nixd = { + enable = true; + }; + ts_ls = { + enable = true; + }; + eslint = { + enable = true; + }; + html = { + enable = true; + }; + cssls = { + enable = true; + }; + volar = { + enable = true; + tslsIntegration = true; + }; + }; + keymaps = { + diagnostic = { + "[d" = "goto_next"; + "]d" = "goto_prev"; + "d" = "open_float"; + }; + lspBuf = { + "K" = "hover"; + "gd" = "definition"; + "gr" = "references"; + "rn" = "rename"; + "ca" = "code_action"; + "" = "signature_help"; + }; + }; + }; + }; + }; +} diff --git a/modules/home-manager/nixvim/plugins/treesitter.nix b/modules/home-manager/nixvim/plugins/treesitter.nix new file mode 100644 index 0000000..e69de29