Enable neovim through home-manager
- We need to set the default editor to just "nvim" not a particular path, as
this allows us to override nvim in our home
- Add the mapleader bind to the start of init.vim
- As the leader is interpreted whenever we make a keybind, we must have it at
the start or it won't be respected for some of our keybinds (but will be for
others)
- Package the scrollbar plugin and install it
- Setup configs for stuff like treesitter, theme, COC, scrollbar etc.
- Add git capabilities to neovim
- Install fugitive, gitgutter and git-conflict, along with some other basic git
stuff
- Allow mouse control in neovim
diff --git a/modules/neovim/coc/default.nix b/modules/neovim/coc/default.nix
new file mode 100644
index 0000000..fc6f72d
--- /dev/null
+++ b/modules/neovim/coc/default.nix
@@ -0,0 +1,47 @@
+{
+ pkgs,
+ lib,
+ ...
+}: {
+ programs.neovim = {
+ coc = {
+ enable = true;
+ settings = {
+ "suggest.noselect" = false;
+ "cSpell.checkOnlyEnabledfileTypes" = false;
+ "rust-analyzer.serverPath" = "${pkgs.rust-analyzer}/bin/rust-analyzer";
+ languageserver = {
+ nix = {
+ command = "${pkgs.rnix-lsp}/bin/rnix-lsp";
+ filetypes = ["nix"];
+ };
+ };
+ };
+ };
+ plugins = with pkgs.vimPlugins; [
+ # Language servers
+ coc-tsserver
+ coc-eslint
+ coc-rust-analyzer
+ coc-json
+ coc-jest
+ coc-css
+
+ # Spellchecker
+ coc-spell-checker # FIXME: Broken in upstream, needs an overlay
+
+ # File explorer
+ coc-explorer
+ coc-git # TODO: Check if coc-git is still needed
+
+ # Snippet completion
+ coc-snippets
+ vim-snippets
+ ];
+ extraConfig = lib.pipe [./keybinds.vim ./theme.vim] [
+ (map builtins.readFile)
+ (builtins.concatStringsSep "\n")
+ ];
+ extraPackages = [pkgs.nodejs pkgs.rustc];
+ };
+}
diff --git a/modules/neovim/coc/keybinds.vim b/modules/neovim/coc/keybinds.vim
new file mode 100644
index 0000000..8e5c0c1
--- /dev/null
+++ b/modules/neovim/coc/keybinds.vim
@@ -0,0 +1,16 @@
+nmap <silent> ]c :call CocAction('diagnosticNext')<cr>
+nmap <silent> [c :call CocAction('diagnosticPrevious')<cr>
+nmap <silent> <Leader>fs <Plug>(coc-codeaction-selected)
+nmap <silent> <Leader>fg <Plug>(coc-codeaction-cursor)
+nmap <silent> <Leader>ff <Plug>(coc-codeaction)
+nmap <Leader>fe <Cmd>CocCommand explorer<CR>
+
+function! s:show_documentation()
+if (index(['vim','help'], &filetype) >= 0)
+execute 'h '.expand('<cword>')
+else
+call CocAction('doHover')
+endif
+endfunction
+
+nnoremap <silent> K :call <SID>show_documentation()<CR>
diff --git a/modules/neovim/coc/theme.vim b/modules/neovim/coc/theme.vim
new file mode 100644
index 0000000..92506a4
--- /dev/null
+++ b/modules/neovim/coc/theme.vim
@@ -0,0 +1,3 @@
+highlight CocErrorSign ctermfg=168 guifg=#e06c75 ctermbg=NONE guibg=NONE
+highlight CocInfoSign ctermfg=75 guifg=#61afef ctermbg=NONE guibg=NONE
+highlight CocWarningSign ctermfg=180 guifg=#e5c07b ctermbg=NONE guibg=NONE