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.5 kB 286 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 = { }; 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 # autoCmd = [ 175 # { 176 # event = "BufWritePost"; 177 # desc = "run treefmt on save"; 178 # # https://stackoverflow.com/questions/77466697/how-to-automatically-format-on-save 179 # callback.__raw = '' 180 # function() 181 # vim.cmd("silent !treefmt %") 182 # vim.cmd("edit") 183 # end 184 # ''; 185 # } 186 # ]; 187 plugins.none-ls = { 188 enable = true; 189 # sources.formatting.treefmt = { 190 # enable = true; 191 # package = pkgs.emptyDirectory; 192 # }; 193 # package = pkgs.vimPlugins.none-ls-nvim.overrideAttrs (_old: { 194 # src = pkgs.fetchFromGitHub { 195 # owner = "lassulus"; 196 # repo = "none-ls.nvim"; 197 # rev = "292c2b5eadea0a097b9a01804aea70f5c8125200"; 198 # sha256 = "sha256-nbzqXsxmYfxngdJH3NXMLmGgygh6reSEnruoc6l8t/s="; 199 # }; 200 # }); 201 }; 202 plugins.web-devicons.enable = true; 203 plugins.telescope.extensions.undo.enable = true; 204 plugins.telescope = { 205 enable = true; 206 keymaps = { 207 "<leader>b" = "buffers"; 208 "<leader>u" = "undo"; 209 "<leader>ff" = "find_files"; 210 "<leader>fg" = "live_grep"; 211 "<leader>fh" = "help_tags"; 212 "<leader>fp" = "yank_history"; 213 }; 214 }; 215 plugins.lsp-format.enable = true; 216 plugins.lsp-lines.enable = true; 217 plugins.lsp = { 218 enable = true; 219 servers = { 220 bashls.enable = true; # bash 221 nixd = { 222 enable = true; # nix 223 extraOptions.offset_encoding = "utf-8"; # workaround https://github.com/nix-community/nixvim/issues/2390#issuecomment-2408101568 224 }; 225 ruff_lsp.enable = true; # python 226 harper_ls.enable = true; # comments 227 jsonls.enable = true; # json 228 }; 229 }; 230 plugins.treesitter.enable = true; 231 plugins.copilot-cmp.enable = true; 232 plugins.copilot-lua.panel.enabled = false; 233 plugins.copilot-lua.suggestion.enabled = false; 234 plugins.cmp_yanky.enable = true; 235 plugins.cmp = { 236 enable = true; 237 autoEnableSources = true; 238 settings = { 239 experimental = { 240 ghost_text = true; 241 }; 242 sources = [ 243 { name = "nvim_lsp"; } 244 { name = "emoji"; } 245 { 246 name = "buffer"; # text within current buffer 247 option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; 248 keywordLength = 2; 249 } 250 { 251 name = "copilot"; # enable copilot 252 } 253 { 254 name = "path"; # file system paths 255 keywordLength = 3; 256 } 257 { name = "cmp_yanky"; } 258 ]; 259 260 mapping = { 261 "<Tab>" = "cmp.mapping.select_next_item()"; 262 "<S-Tab>" = "cmp.mapping.select_prev_item()"; 263 "<C-n>" = "cmp.mapping.select_next_item()"; 264 "<C-p>" = "cmp.mapping.select_prev_item()"; 265 "<C-e>" = "cmp.mapping.abort()"; 266 "<C-b>" = "cmp.mapping.scroll_docs(-4)"; 267 "<C-f>" = "cmp.mapping.scroll_docs(4)"; 268 "<C-Space>" = "cmp.mapping.complete()"; 269 "<CR>" = "cmp.mapping.confirm({ select = true })"; 270 "<S-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })"; 271 }; 272 }; 273 }; 274 plugins.bufferline.enable = true; 275 plugins.which-key.enable = true; 276 plugins.yanky = { 277 enable = true; 278 enableTelescope = true; 279 }; 280 plugins.comment.enable = true; 281 plugins.copilot-chat.enable = true; 282 plugins.undotree.enable = true; # seems to be needed for undo history in telescope 283 plugins.leap.enable = true; 284 }; 285 }; 286}