Kieran's opinionated (and probably slightly dumb) nix config
1{ config, lib, pkgs, ... }:
2
3{
4 programs.neovim = {
5 enable = true;
6 extraPackages = with pkgs; [
7 # LazyVim
8 lua-language-server
9 stylua
10 # Telescope
11 ripgrep
12 ];
13
14 plugins = with pkgs.vimPlugins; [
15 lazy-nvim
16 ];
17
18 defaultEditor = true;
19 viAlias = true;
20 vimAlias = true;
21
22 extraLuaConfig =
23 let
24 plugins = with pkgs.vimPlugins; [
25 # LazyVim
26 LazyVim
27 bufferline-nvim
28 cmp-buffer
29 cmp-nvim-lsp
30 cmp-path
31 cmp_luasnip
32 conform-nvim
33 dashboard-nvim
34 dressing-nvim
35 flash-nvim
36 friendly-snippets
37 gitsigns-nvim
38 indent-blankline-nvim
39 lualine-nvim
40 neo-tree-nvim
41 neoconf-nvim
42 neodev-nvim
43 noice-nvim
44 nui-nvim
45 nvim-cmp
46 nvim-lint
47 nvim-lspconfig
48 nvim-notify
49 nvim-spectre
50 nvim-treesitter
51 nvim-treesitter-context
52 nvim-treesitter-textobjects
53 nvim-ts-autotag
54 nvim-ts-context-commentstring
55 nvim-web-devicons
56 persistence-nvim
57 plenary-nvim
58 telescope-fzf-native-nvim
59 telescope-nvim
60 todo-comments-nvim
61 tokyonight-nvim
62 trouble-nvim
63 vim-illuminate
64 vim-startuptime
65 which-key-nvim
66 { name = "LuaSnip"; path = luasnip; }
67 { name = "catppuccin"; path = catppuccin-nvim; }
68 { name = "mini.ai"; path = mini-nvim; }
69 { name = "mini.bufremove"; path = mini-nvim; }
70 { name = "mini.comment"; path = mini-nvim; }
71 { name = "mini.indentscope"; path = mini-nvim; }
72 { name = "mini.pairs"; path = mini-nvim; }
73 { name = "mini.surround"; path = mini-nvim; }
74 ];
75 mkEntryFromDrv = drv:
76 if lib.isDerivation drv then
77 { name = "${lib.getName drv}"; path = drv; }
78 else
79 drv;
80 lazyPath = pkgs.linkFarm "lazy-plugins" (builtins.map mkEntryFromDrv plugins);
81 in
82 ''
83 require("lazy").setup({
84 defaults = {
85 lazy = true,
86 },
87 dev = {
88 -- reuse files from pkgs.vimPlugins.*
89 path = "${lazyPath}",
90 patterns = { "." },
91 -- fallback to download
92 fallback = true,
93 },
94 spec = {
95 { "LazyVim/LazyVim", import = "lazyvim.plugins" },
96 -- The following configs are needed for fixing lazyvim on nix
97 -- force enable telescope-fzf-native.nvim
98 { "nvim-telescope/telescope-fzf-native.nvim", enabled = true },
99 -- disable mason.nvim, use programs.neovim.extraPackages
100 { "williamboman/mason-lspconfig.nvim", enabled = false },
101 { "williamboman/mason.nvim", enabled = false },
102 -- import/override with your plugins
103 { import = "plugins" },
104 -- treesitter handled by xdg.configFile."nvim/parser", put this line at the end of spec to clear ensure_installed
105 { "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },
106 },
107 })
108 '';
109 };
110
111 # https://github.com/nvim-treesitter/nvim-treesitter#i-get-query-error-invalid-node-type-at-position
112 xdg.configFile."nvim/parser".source =
113 let
114 parsers = pkgs.symlinkJoin {
115 name = "treesitter-parsers";
116 paths = (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: with plugins; [
117 c
118 lua
119 ])).dependencies;
120 };
121 in
122 "${parsers}/parser";
123
124 # Normal LazyVim config here, see https://github.com/LazyVim/starter/tree/main/lua
125}