This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / tools / nvim.nix
9.3 kB 317 lines
1{ inputs, ... }: 2{ 3 perSystem = 4 { system, pkgs, ... }: 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 = true; 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 function watch_theme_file() 42 local path = '/var/theme/current_theme' 43 local uv = vim.loop 44 45 local watcher = uv.new_fs_event() 46 watcher:start(path, {}, function(err, filename, events) 47 if err then 48 print('Error watching file:', err) 49 return 50 end 51 52 -- Use Lua's io.open to read the file content 53 local file = io.open(path, 'r') 54 if not file then 55 print('Failed to open file:', path) 56 return 57 end 58 59 local content = file:read('*a') -- Read the entire file 60 file:close() 61 62 content = content:gsub('%s+$', "") 63 content = content:gsub('"', '\\"') 64 65 -- Execute a Neovim command based on the content 66 vim.schedule(function() 67 cmd = 'set background=' .. content 68 vim.cmd(cmd) 69 end) 70 end) 71 end 72 watch_theme_file() 73 74 ''; 75 extraPlugins = [ 76 pkgs.vimPlugins.vim-fetch 77 ]; 78 # not ready yet, we are waiting for none-ls to get updated 79 # extraConfigLua = '' 80 # local null_ls = require("null-ls") 81 # null_ls.register(null_ls.builtins.formatting.nix_flake_fmt) 82 # ''; 83 keymaps = [ 84 { 85 mode = "i"; 86 key = "<C-p>"; 87 action = "<Nop>"; 88 } 89 { 90 mode = "i"; 91 key = "<C-n>"; 92 action = "<Nop>"; 93 } 94 { 95 mode = "n"; 96 key = "<C-c>"; 97 action = ":q<cr>"; 98 } 99 { 100 mode = "n"; 101 key = "<Space>"; 102 action = "<Nop>"; 103 } 104 { 105 mode = "n"; 106 key = "<leader>sd"; 107 action = ":colorscheme ayu-dark<cr>"; 108 } 109 { 110 mode = "n"; 111 key = "<leader>sw"; 112 action = ":colorscheme ayu-light<cr>"; 113 } 114 { 115 mode = [ 116 "n" 117 "v" 118 ]; 119 key = "<leader>cc"; 120 action = ":CopilotChatOpen<cr>"; 121 } 122 { 123 mode = [ 124 "n" 125 "v" 126 ]; 127 key = "<leader>ce"; 128 action = ":CopilotChatExplain<cr>"; 129 } 130 { 131 mode = [ 132 "n" 133 "v" 134 ]; 135 key = "<leader>cr"; 136 action = ":CopilotChatReview<cr>"; 137 } 138 { 139 mode = [ 140 "n" 141 "v" 142 ]; 143 key = "<leader>cf"; 144 action = ":CopilotChatFix<cr>"; 145 } 146 { 147 mode = [ 148 "n" 149 "v" 150 ]; 151 key = "<leader>cd"; 152 action = ":CopilotChatDocs<cr>"; 153 } 154 { 155 mode = [ 156 "n" 157 "x" 158 ]; 159 key = "p"; 160 action = "<Plug>(YankyPutAfter)"; 161 } 162 { 163 mode = [ 164 "n" 165 "x" 166 ]; 167 key = "P"; 168 action = "<Plug>(YankyPutBefore)"; 169 } 170 { 171 mode = [ 172 "c" 173 "i" 174 "n" 175 "x" 176 ]; 177 key = "<M-CR>"; 178 action = ":lua vim.lsp.buf.code_action()<CR>"; 179 } 180 { 181 mode = [ 182 "n" 183 ]; 184 key = "gd"; 185 action = ":lua vim.lsp.buf.definition()<CR>"; 186 } 187 { 188 mode = [ 189 "n" 190 ]; 191 key = "gD"; 192 action = ":lua vim.lsp.buf.declaration()<CR>"; 193 } 194 ]; 195 # autoCmd = [ 196 # { 197 # event = "BufWritePost"; 198 # desc = "run treefmt on save"; 199 # # https://stackoverflow.com/questions/77466697/how-to-automatically-format-on-save 200 # callback.__raw = '' 201 # function() 202 # vim.cmd("silent !treefmt %") 203 # vim.cmd("edit") 204 # end 205 # ''; 206 # } 207 # ]; 208 plugins.none-ls = { 209 enable = true; 210 # sources.formatting.treefmt = { 211 # enable = true; 212 # package = pkgs.emptyDirectory; 213 # }; 214 # package = pkgs.vimPlugins.none-ls-nvim.overrideAttrs (_old: { 215 # src = pkgs.fetchFromGitHub { 216 # owner = "lassulus"; 217 # repo = "none-ls.nvim"; 218 # rev = "292c2b5eadea0a097b9a01804aea70f5c8125200"; 219 # sha256 = "sha256-nbzqXsxmYfxngdJH3NXMLmGgygh6reSEnruoc6l8t/s="; 220 # }; 221 # }); 222 }; 223 plugins.web-devicons.enable = true; 224 plugins.telescope.extensions.undo.enable = true; 225 plugins.telescope = { 226 enable = true; 227 keymaps = { 228 "<leader>b" = "buffers"; 229 "<leader>u" = "undo"; 230 "<leader>ff" = "find_files"; 231 "<leader>fg" = "live_grep"; 232 "<leader>fh" = "help_tags"; 233 "<leader>fp" = "yank_history"; 234 }; 235 }; 236 plugins.lsp-format.enable = true; 237 plugins.lsp-lines.enable = true; 238 plugins.lsp = { 239 enable = true; 240 servers = { 241 bashls.enable = true; # bash 242 nixd = { 243 enable = true; # nix 244 extraOptions.offset_encoding = "utf-8"; # workaround https://github.com/nix-community/nixvim/issues/2390#issuecomment-2408101568 245 }; 246 ruff.enable = true; # python 247 pyright.enable = true; # python 248 jsonls.enable = true; # json 249 }; 250 }; 251 plugins.treesitter.enable = true; 252 plugins.copilot-cmp.enable = true; 253 plugins.copilot-lua.panel.enabled = false; 254 plugins.copilot-lua.suggestion.enabled = false; 255 plugins.cmp_yanky.enable = true; 256 plugins.cmp = { 257 enable = true; 258 autoEnableSources = true; 259 settings = { 260 experimental = { 261 ghost_text = true; 262 }; 263 sources = [ 264 { name = "nvim_lsp"; } 265 { name = "emoji"; } 266 { 267 name = "buffer"; # text within current buffer 268 option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; 269 keywordLength = 2; 270 } 271 { 272 name = "copilot"; # enable copilot 273 } 274 { 275 name = "path"; # file system paths 276 keywordLength = 3; 277 } 278 { name = "cmp_yanky"; } 279 ]; 280 281 mapping = { 282 "<Tab>" = "cmp.mapping.select_next_item()"; 283 "<S-Tab>" = "cmp.mapping.select_prev_item()"; 284 "<C-n>" = "cmp.mapping.select_next_item()"; 285 "<C-p>" = "cmp.mapping.select_prev_item()"; 286 "<C-e>" = "cmp.mapping.abort()"; 287 "<C-b>" = "cmp.mapping.scroll_docs(-4)"; 288 "<C-f>" = "cmp.mapping.scroll_docs(4)"; 289 "<CR>" = '' 290 cmp.mapping({ 291 i = function(fallback) 292 if cmp.visible() and cmp.get_active_entry() then 293 cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) 294 else 295 fallback() 296 end 297 end, 298 s = cmp.mapping.confirm({ select = true }), 299 c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), 300 }) 301 ''; 302 }; 303 }; 304 }; 305 plugins.bufferline.enable = true; 306 plugins.which-key.enable = true; 307 plugins.yanky = { 308 enable = true; 309 enableTelescope = true; 310 }; 311 plugins.comment.enable = true; 312 plugins.copilot-chat.enable = true; 313 plugins.undotree.enable = true; # seems to be needed for undo history in telescope 314 plugins.leap.enable = true; 315 }; 316 }; 317}