{ config, lib, pkgs, ... }: let cfg = config.jade.neovim; in with lib; { options.jade.neovim = { enable = mkEnableOption "Enable neovim"; }; config = mkIf cfg.enable { home-manager.users.jade = { pkgs,... } : { home.packages = with pkgs; [ rust-analyzer neovide ]; programs.neovim = { enable = true; viAlias = true; vimAlias = true; vimdiffAlias = true; # Plugins {{{ plugins = with pkgs.vimPlugins; [ nerdtree-git-plugin ctrlp-vim vim-devicons vim-nix vim-pug coc-rust-analyzer coc-git coc-fzf coc-css coc-yaml coc-json coc-html coc-emmet coc-vimlsp coc-tsserver { plugin = toggleterm-nvim; config = '' lua require("toggleterm").setup{} autocmd TermEnter term://*toggleterm#* \ tnoremap exe v:count1 . "ToggleTerm" " By applying the mappings this way you can pass a count to your " mapping to open a specific window. " For example: 2 will open terminal 2 nnoremap exe v:count1 . "ToggleTerm direction=float" inoremap exe v:count1 . "ToggleTerm direction=float" ''; } { plugin = gruvbox-nvim; config = "colorscheme gruvbox"; } { plugin = nerdtree; config = "nmap :NERDTreeToggle"; } { plugin = nerdcommenter; config = '' vmap ++ NERDCommenterToggle nmap ++ NERDCommenterToggle ''; } ]; # }}} # Coc {{{ coc = { enable = true; settings = { rust-analyzer.server.path = "${pkgs.rust-analyzer}/bin/rust-analyzer"; }; pluginConfig = '' let mapleader = "\" nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) nnoremap K :call show_documentation() nmap gr (coc-rename) nmap ac (coc-codeaction) nmap qf (coc-fix-current) " Use tab for trigger completion with characters ahead and navigate. " NOTE: There's always complete item selected by default, you may want to enable " no select by `"suggest.noselect": true` in your configuration file. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. inoremap \ coc#pum#visible() ? coc#pum#next(1) : \ CheckBackspace() ? "\" : \ coc#refresh() inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" if has('nvim-0.4.0') || has('patch-8.2.0750') nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" endif " Make to accept selected completion item or notify coc.nvim to format " u breaks current undo, please make your own choice. inoremap coc#pum#visible() ? coc#pum#confirm() \: "\u\\=coc#on_enter()\" function! CheckBackspace() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Make to accept selected completion item or notify coc.nvim to format " u breaks current undo, please make your own choice. inoremap coc#pum#visible() ? coc#pum#confirm() \: "\u\\=coc#on_enter()\" function! CheckBackspace() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use to trigger completion. if has('nvim') inoremap coc#refresh() else inoremap coc#refresh() endif nmap rn (coc-rename) ''; }; # }}} extraConfig = '' " neovide let g:neovide_refresh_rate_idle=5 let g:neovide_cursor_animation_length=0.1 let g:neovide_cursor_trail_size=0.3 let g:neovide_cursor_vfx_mode="railgun" let g:neovide_remember_window_size = v:false set guifont=FiraCode\ Nerd\ Font:h11 set fdm=marker nmap H _ vmap H _ nmap L $ vmap L $ " terminal normal mode tnoremap " j/k move virtual lines (wrapped) noremap j (v:count == 0 ? 'gj' : 'j') noremap k (v:count == 0 ? 'gk' : 'k') set relativenumber set number set smarttab set cindent set tabstop=4 set shiftwidth=4 ''; }; }; }; }