forked from
lass.pds.lassul.us/superconfig
This repository has no description
9.0 kB
309 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 sources.formatting.nix_flake_fmt.enable = true;
214 };
215 plugins.web-devicons.enable = true;
216 plugins.telescope.extensions.undo.enable = true;
217 plugins.telescope = {
218 enable = true;
219 keymaps = {
220 "<leader>b" = "buffers";
221 "<leader>u" = "undo";
222 "<leader>ff" = "find_files";
223 "<leader>fg" = "live_grep";
224 "<leader>fh" = "help_tags";
225 "<leader>fp" = "yank_history";
226 };
227 };
228 plugins.lsp-format.enable = true;
229 plugins.lsp-lines.enable = true;
230 plugins.lsp = {
231 enable = true;
232 servers = {
233 bashls.enable = true; # bash
234 nixd = {
235 enable = true; # nix
236 extraOptions.offset_encoding = "utf-8"; # workaround https://github.com/nix-community/nixvim/issues/2390#issuecomment-2408101568
237 };
238 ruff.enable = true; # python
239 pyright.enable = true; # python
240 jsonls.enable = true; # json
241 };
242 };
243 plugins.treesitter.enable = true;
244 plugins.copilot-cmp.enable = true;
245 plugins.copilot-lua.settings.panel.enabled = false;
246 plugins.copilot-lua.settings.suggestion.enabled = false;
247 plugins.cmp_yanky.enable = true;
248 plugins.cmp = {
249 enable = true;
250 autoEnableSources = true;
251 settings = {
252 experimental = {
253 ghost_text = true;
254 };
255 sources = [
256 { name = "nvim_lsp"; }
257 { name = "emoji"; }
258 {
259 name = "buffer"; # text within current buffer
260 option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
261 keywordLength = 2;
262 }
263 {
264 name = "copilot"; # enable copilot
265 }
266 {
267 name = "path"; # file system paths
268 keywordLength = 3;
269 }
270 { name = "cmp_yanky"; }
271 ];
272
273 mapping = {
274 "<Tab>" = "cmp.mapping.select_next_item()";
275 "<S-Tab>" = "cmp.mapping.select_prev_item()";
276 "<C-n>" = "cmp.mapping.select_next_item()";
277 "<C-p>" = "cmp.mapping.select_prev_item()";
278 "<C-e>" = "cmp.mapping.abort()";
279 "<C-b>" = "cmp.mapping.scroll_docs(-4)";
280 "<C-f>" = "cmp.mapping.scroll_docs(4)";
281 "<CR>" = ''
282 cmp.mapping({
283 i = function(fallback)
284 if cmp.visible() and cmp.get_active_entry() then
285 cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
286 else
287 fallback()
288 end
289 end,
290 s = cmp.mapping.confirm({ select = true }),
291 c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
292 })
293 '';
294 };
295 };
296 };
297 plugins.bufferline.enable = true;
298 plugins.which-key.enable = true;
299 plugins.yanky = {
300 enable = true;
301 enableTelescope = true;
302 };
303 plugins.comment.enable = true;
304 plugins.copilot-chat.enable = true;
305 plugins.undotree.enable = true; # seems to be needed for undo history in telescope
306 plugins.gitsigns.enable = true;
307 };
308 };
309}