This repository has no description
8.9 kB
308 lines
1{ inputs, ... }:
2{
3 perSystem =
4 { system, pkgs, ... }:
5 {
6 packages.nvim = inputs.nixvim.legacyPackages.${system}.makeNixvim {
7 vimAlias = true;
8 colorschemes = {
9 ayu = {
10 enable = true;
11 settings.overrides = {
12 EoLSpace = {
13 bg = "#883333";
14 };
15 };
16 };
17 everforest = {
18 enable = true;
19 settings.overrides = {
20 EoLSpace = {
21 bg = "#FF2222"; # doesn't work
22 };
23 };
24 };
25 };
26 globals = {
27 mapleader = " ";
28 lumen_light_colorscheme = "everforest";
29 lumen_dark_colorscheme = "ayu";
30 };
31 opts = {
32 mouse = "a";
33 number = true;
34 shiftwidth = 2;
35 clipboard = "unnamedplus";
36 # undo stuff
37 undofile = true;
38 undolevels = 10000;
39 undoreload = 10000;
40 listchars = "tab:⇥ ,extends:❯,precedes:❮,nbsp:␣,trail:·,eol:↲";
41 };
42 extraConfigVim = ''
43 set et
44
45 " show special characters
46 set list
47
48 " match trailing whitespace
49 match EoLSpace /\s\+$/
50
51 " need to use lua to expand $HOME
52 lua vim.o.undodir = vim.fs.normalize('$HOME/.vim/undodir')
53 '';
54 extraPackages = [
55 pkgs.glib # for vim-lumen
56 ];
57 extraPlugins = [
58 pkgs.vimPlugins.vim-fetch
59 (pkgs.vimUtils.buildVimPlugin {
60 name = "vim-lumen";
61 src = pkgs.fetchFromGitHub {
62 owner = "vimpostor";
63 repo = "vim-lumen";
64 rev = "ac13c32c3e309f6c6a84ff6cad8dbb135e75f0e4";
65 hash = "sha256-rsDUDI9lh4CEX1upMBjeyBOm99GAXWGPQ9vSCN8cmFo=";
66 };
67 })
68 ];
69 # not ready yet, we are waiting for none-ls to get updated
70 # extraConfigLua = ''
71 # local null_ls = require("null-ls")
72 # null_ls.register(null_ls.builtins.formatting.nix_flake_fmt)
73 # '';
74 keymaps = [
75 {
76 mode = "i";
77 key = "<C-p>";
78 action = "<Nop>";
79 }
80 {
81 mode = "i";
82 key = "<C-n>";
83 action = "<Nop>";
84 }
85 {
86 mode = "n";
87 key = "<C-c>";
88 action = ":q<cr>";
89 }
90 {
91 mode = "n";
92 key = "<Space>";
93 action = "<Nop>";
94 }
95 {
96 mode = "n";
97 key = "<leader>sd";
98 action = ":colorscheme ayu-dark<cr>";
99 }
100 {
101 mode = "n";
102 key = "<leader>sw";
103 action = ":colorscheme ayu-light<cr>";
104 }
105 {
106 mode = [
107 "n"
108 "v"
109 ];
110 key = "<leader>cc";
111 action = ":CopilotChatOpen<cr>";
112 }
113 {
114 mode = [
115 "n"
116 "v"
117 ];
118 key = "<leader>ce";
119 action = ":CopilotChatExplain<cr>";
120 }
121 {
122 mode = [
123 "n"
124 "v"
125 ];
126 key = "<leader>cr";
127 action = ":CopilotChatReview<cr>";
128 }
129 {
130 mode = [
131 "n"
132 "v"
133 ];
134 key = "<leader>cf";
135 action = ":CopilotChatFix<cr>";
136 }
137 {
138 mode = [
139 "n"
140 "v"
141 ];
142 key = "<leader>cd";
143 action = ":CopilotChatDocs<cr>";
144 }
145 {
146 mode = [
147 "n"
148 "x"
149 ];
150 key = "p";
151 action = "<Plug>(YankyPutAfter)";
152 }
153 {
154 mode = [
155 "n"
156 "x"
157 ];
158 key = "P";
159 action = "<Plug>(YankyPutBefore)";
160 }
161 {
162 mode = [
163 "c"
164 "i"
165 "n"
166 "x"
167 ];
168 key = "<M-CR>";
169 action = ":lua vim.lsp.buf.code_action()<CR>";
170 }
171 {
172 mode = [
173 "n"
174 ];
175 key = "gd";
176 action = ":lua vim.lsp.buf.definition()<CR>";
177 }
178 {
179 mode = [
180 "n"
181 ];
182 key = "gD";
183 action = ":lua vim.lsp.buf.declaration()<CR>";
184 }
185 ];
186 # autoCmd = [
187 # {
188 # event = "BufWritePost";
189 # desc = "run treefmt on save";
190 # # https://stackoverflow.com/questions/77466697/how-to-automatically-format-on-save
191 # callback.__raw = ''
192 # function()
193 # vim.cmd("silent !treefmt %")
194 # vim.cmd("edit")
195 # end
196 # '';
197 # }
198 # ];
199 plugins.none-ls = {
200 enable = true;
201 # sources.formatting.treefmt = {
202 # enable = true;
203 # package = pkgs.emptyDirectory;
204 # };
205 # package = pkgs.vimPlugins.none-ls-nvim.overrideAttrs (_old: {
206 # src = pkgs.fetchFromGitHub {
207 # owner = "lassulus";
208 # repo = "none-ls.nvim";
209 # rev = "292c2b5eadea0a097b9a01804aea70f5c8125200";
210 # sha256 = "sha256-nbzqXsxmYfxngdJH3NXMLmGgygh6reSEnruoc6l8t/s=";
211 # };
212 # });
213 };
214 plugins.web-devicons.enable = true;
215 plugins.telescope.extensions.undo.enable = true;
216 plugins.telescope = {
217 enable = true;
218 keymaps = {
219 "<leader>b" = "buffers";
220 "<leader>u" = "undo";
221 "<leader>ff" = "find_files";
222 "<leader>fg" = "live_grep";
223 "<leader>fh" = "help_tags";
224 "<leader>fp" = "yank_history";
225 };
226 };
227 plugins.lsp-format.enable = true;
228 plugins.lsp-lines.enable = true;
229 plugins.lsp = {
230 enable = true;
231 servers = {
232 bashls.enable = true; # bash
233 nixd = {
234 enable = true; # nix
235 extraOptions.offset_encoding = "utf-8"; # workaround https://github.com/nix-community/nixvim/issues/2390#issuecomment-2408101568
236 };
237 ruff.enable = true; # python
238 pyright.enable = true; # python
239 jsonls.enable = true; # json
240 };
241 };
242 plugins.treesitter.enable = true;
243 plugins.copilot-cmp.enable = true;
244 plugins.copilot-lua.panel.enabled = false;
245 plugins.copilot-lua.suggestion.enabled = false;
246 plugins.cmp_yanky.enable = true;
247 plugins.cmp = {
248 enable = true;
249 autoEnableSources = true;
250 settings = {
251 experimental = {
252 ghost_text = true;
253 };
254 sources = [
255 { name = "nvim_lsp"; }
256 { name = "emoji"; }
257 {
258 name = "buffer"; # text within current buffer
259 option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
260 keywordLength = 2;
261 }
262 {
263 name = "copilot"; # enable copilot
264 }
265 {
266 name = "path"; # file system paths
267 keywordLength = 3;
268 }
269 { name = "cmp_yanky"; }
270 ];
271
272 mapping = {
273 "<Tab>" = "cmp.mapping.select_next_item()";
274 "<S-Tab>" = "cmp.mapping.select_prev_item()";
275 "<C-n>" = "cmp.mapping.select_next_item()";
276 "<C-p>" = "cmp.mapping.select_prev_item()";
277 "<C-e>" = "cmp.mapping.abort()";
278 "<C-b>" = "cmp.mapping.scroll_docs(-4)";
279 "<C-f>" = "cmp.mapping.scroll_docs(4)";
280 "<CR>" = ''
281 cmp.mapping({
282 i = function(fallback)
283 if cmp.visible() and cmp.get_active_entry() then
284 cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
285 else
286 fallback()
287 end
288 end,
289 s = cmp.mapping.confirm({ select = true }),
290 c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
291 })
292 '';
293 };
294 };
295 };
296 plugins.bufferline.enable = true;
297 plugins.which-key.enable = true;
298 plugins.yanky = {
299 enable = true;
300 enableTelescope = true;
301 };
302 plugins.comment.enable = true;
303 plugins.copilot-chat.enable = true;
304 plugins.undotree.enable = true; # seems to be needed for undo history in telescope
305 plugins.leap.enable = true;
306 };
307 };
308}