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