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