This repository has no description
0

Configure Feed

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

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