diff options
Diffstat (limited to 'common/vim.nix')
-rw-r--r-- | common/vim.nix | 206 |
1 files changed, 124 insertions, 82 deletions
diff --git a/common/vim.nix b/common/vim.nix index aa74a39..ec43738 100644 --- a/common/vim.nix +++ b/common/vim.nix | |||
@@ -2,81 +2,108 @@ inputs: | |||
2 | 2 | ||
3 | { config, pkgs, lib, ... }: | 3 | { config, pkgs, lib, ... }: |
4 | 4 | ||
5 | let myNeovim = (pkgs.neovim.override { | 5 | let |
6 | configure = { | 6 | inherit (pkgs.unstable) vimPlugins wrapNeovim; |
7 | |||
8 | inherit (config.vim) beforePlugins; | ||
9 | |||
10 | customRC = with lib; | ||
11 | (concatStringsSep | ||
12 | "\n" | ||
13 | (mapAttrsToList | ||
14 | (variable: value: "let g:${variable} = ${value}") | ||
15 | config.vim.variables)) | ||
16 | + "\n" | ||
17 | + builtins.readFile ../dotfiles/vimrc.vim + config.vim.extraConfig; | ||
18 | |||
19 | vam = with pkgs; { | ||
20 | pluginDictionaries = [ | ||
21 | # UI | ||
22 | { name = "undotree"; } | ||
23 | { name = "gruvbox-community"; } | ||
24 | { name = "gitgutter"; } | ||
25 | { name = "lightline-vim"; } | ||
26 | { name = "vim-dirvish"; } | ||
27 | |||
28 | # Motions | ||
29 | { name = "camelcasemotion"; } | ||
30 | { name = "surround"; } | ||
31 | { name = "targets-vim"; } | ||
32 | |||
33 | # Frameworks | ||
34 | { name = "deoplete-nvim"; } | ||
35 | { name = "neosnippet"; } | ||
36 | { name = "neosnippet-snippets"; } | ||
37 | { name = "neoformat"; } | ||
38 | { name = "ctrlp"; } | ||
39 | # Syntax generic completion for deoplete | ||
40 | { name = "neco-syntax"; } | ||
41 | |||
42 | # Languages | ||
43 | { name = "vim-polyglot"; } | ||
44 | { name = "editorconfig-vim"; } | ||
45 | # Vim completion for deoplete | ||
46 | { name = "neco-vim"; } | ||
47 | { name = "deoplete-zsh"; } | ||
48 | { name = "vim-pandoc"; } | ||
49 | { name = "vim-pandoc-syntax"; } | ||
50 | |||
51 | # Languages (but not programming languages) | ||
52 | { name = "vim-grammarous"; } | ||
53 | |||
54 | # Other | ||
55 | { name = "tmux-complete-vim"; } | ||
56 | { name = "fugitive"; } | ||
57 | { name = "rhubarb"; } | ||
58 | { name = "repeat"; } | ||
59 | { name = "vim-unimpaired"; } | ||
60 | { name = "tabular"; } | ||
61 | { name = "vimwiki"; } | ||
62 | { name = "vim-abolish"; } | ||
63 | |||
64 | ] ++ config.vim.extraPlugins; | ||
65 | 7 | ||
66 | }; | 8 | neovim-unwrapped = inputs.neovim-master.defaultPackage.${config.nixpkgs.system}; |
9 | |||
10 | cfg = config.vim; | ||
11 | |||
12 | myConfigPackage = with lib; | ||
13 | pkgs.writeTextDir | ||
14 | "share/vim-plugins/myConfig/lua/myConfig.lua" | ||
15 | '' | ||
16 | -- Autogenerated variables from the NixOS configuration | ||
17 | |||
18 | ${(concatStringsSep | ||
19 | "\n" | ||
20 | (mapAttrsToList | ||
21 | (variable: value: "vim.g.${variable} = ${value}") | ||
22 | cfg.variables))} | ||
23 | |||
24 | -- vim.lua from the NixOS configuration | ||
25 | |||
26 | ${builtins.readFile ../dotfiles/vim.lua} | ||
27 | |||
28 | -- luaConfig from the NixOS configuration | ||
29 | |||
30 | ${cfg.luaConfig} | ||
31 | ''; | ||
32 | |||
33 | myNeovim = wrapNeovim neovim-unwrapped { | ||
34 | configure = { | ||
67 | 35 | ||
36 | inherit (config.vim) beforePlugins; | ||
37 | |||
38 | customRC = '' | ||
39 | autocmd VimEnter * lua require("myConfig") | ||
40 | |||
41 | ${cfg.extraConfig} | ||
42 | ''; | ||
43 | |||
44 | packages.myVimPackage = with vimPlugins; { | ||
45 | start = [ | ||
46 | myConfigPackage | ||
47 | |||
48 | # Dependencies | ||
49 | plenary-nvim | ||
50 | popup-nvim | ||
51 | |||
52 | # UI | ||
53 | undotree | ||
54 | gruvbox-community | ||
55 | lualine-nvim | ||
56 | gitsigns-nvim | ||
57 | vim-dirvish | ||
58 | lsp-status-nvim | ||
59 | |||
60 | completion-nvim | ||
61 | completion-buffers | ||
62 | snippets-nvim | ||
63 | |||
64 | telescope-nvim | ||
65 | |||
66 | # Treesitter | ||
67 | nvim-treesitter | ||
68 | completion-treesitter | ||
69 | nvim-treesitter-textobjects | ||
70 | nvim-treesitter-context | ||
71 | |||
72 | # Motions | ||
73 | camelcasemotion | ||
74 | surround | ||
75 | targets-vim | ||
76 | |||
77 | neoformat | ||
78 | |||
79 | # Languages | ||
80 | vim-polyglot | ||
81 | editorconfig-vim | ||
82 | vim-pandoc | ||
83 | vim-pandoc-syntax | ||
84 | |||
85 | # Languages (but not programming languages) | ||
86 | vim-grammarous | ||
87 | |||
88 | # Other | ||
89 | tmux-complete-vim | ||
90 | fugitive | ||
91 | rhubarb | ||
92 | repeat | ||
93 | vim-unimpaired | ||
94 | tabular | ||
95 | vim-abolish | ||
96 | ] ++ config.vim.extraPlugins; | ||
97 | }; | ||
98 | }; | ||
68 | }; | 99 | }; |
69 | }); | 100 | in |
70 | in { | 101 | { |
71 | options.vim = with lib; { | 102 | options.vim = with lib; { |
72 | 103 | ||
73 | variables = mkOption { | 104 | variables = mkOption { |
74 | type = types.attrsOf types.str; | 105 | type = types.attrsOf types.str; |
75 | default = { | 106 | default = {}; |
76 | dominant_color = "'${config.theme.colors.dominant}'"; | ||
77 | ripgrep_path = "'${pkgs.ripgrep}/bin/rg'"; | ||
78 | fd_path = "'${pkgs.fd}/bin/fd'"; | ||
79 | }; | ||
80 | description = '' | 107 | description = '' |
81 | Extra global variables to add at the beginning of the vim configuration. | 108 | Extra global variables to add at the beginning of the vim configuration. |
82 | 109 | ||
@@ -85,17 +112,11 @@ in { | |||
85 | }; | 112 | }; |
86 | 113 | ||
87 | extraPlugins = mkOption { | 114 | extraPlugins = mkOption { |
88 | type = types.listOf (types.attrsOf types.str); | 115 | type = with types; listOf package; |
89 | default = []; | 116 | default = [ ]; |
90 | description = "Names of extra plugins to add"; | 117 | description = "Names of extra plugins to add"; |
91 | }; | 118 | }; |
92 | 119 | ||
93 | extraRepoPlugins = mkOption { | ||
94 | type = types.listOf (types.attrsOf types.str); | ||
95 | default = []; | ||
96 | description = "Names of extra plugins to add that are present in the local repository"; | ||
97 | }; | ||
98 | |||
99 | beforePlugins = mkOption { | 120 | beforePlugins = mkOption { |
100 | type = types.lines; | 121 | type = types.lines; |
101 | default = ""; | 122 | default = ""; |
@@ -107,9 +128,30 @@ in { | |||
107 | default = ""; | 128 | default = ""; |
108 | description = "Extra lines to add at the end of the vim configuration"; | 129 | description = "Extra lines to add at the end of the vim configuration"; |
109 | }; | 130 | }; |
131 | |||
132 | luaConfig = mkOption { | ||
133 | type = types.lines; | ||
134 | default = ""; | ||
135 | description = "Lua Neovim configuration"; | ||
136 | }; | ||
137 | |||
138 | wrappedPackage = mkOption { | ||
139 | type = types.package; | ||
140 | description = "Resulting wrapped Neovim package"; | ||
141 | readOnly = true; | ||
142 | }; | ||
110 | }; | 143 | }; |
111 | 144 | ||
112 | config = { | 145 | config = { |
146 | vim = { | ||
147 | wrappedPackage = myNeovim; | ||
148 | variables = { | ||
149 | dominant_color = "'${config.theme.colors.dominant}'"; | ||
150 | ripgrep_path = "'${pkgs.ripgrep}/bin/rg'"; | ||
151 | fd_path = "'${pkgs.fd}/bin/fd'"; | ||
152 | }; | ||
153 | }; | ||
154 | |||
113 | environment.systemPackages = with pkgs; [ | 155 | environment.systemPackages = with pkgs; [ |
114 | myNeovim | 156 | myNeovim |
115 | ]; | 157 | ]; |
@@ -119,13 +161,13 @@ in { | |||
119 | }; | 161 | }; |
120 | 162 | ||
121 | home-manager.users.minijackson = { ... }: | 163 | home-manager.users.minijackson = { ... }: |
122 | { | 164 | { |
123 | xdg.dataFile."nvim/backup/.keep".text = ""; | 165 | xdg.dataFile."nvim/backup/.keep".text = ""; |
124 | }; | 166 | }; |
125 | 167 | ||
126 | home-manager.users.root = { ... }: | 168 | home-manager.users.root = { ... }: |
127 | { | 169 | { |
128 | xdg.dataFile."nvim/backup/.keep".text = ""; | 170 | xdg.dataFile."nvim/backup/.keep".text = ""; |
129 | }; | 171 | }; |
130 | }; | 172 | }; |
131 | } | 173 | } |