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