nix-configs/modules/neovim.nix

136 lines
3.2 KiB
Nix
Raw Normal View History

2022-09-01 19:23:12 +00:00
{ 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,... } : {
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
# Plugins {{{
plugins = with pkgs.vimPlugins; [
nerdtree-git-plugin
ctrlp-vim
vim-nerdtree-syntax-highlight
vim-devicons
vim-nix
2022-09-02 08:33:55 +00:00
vim-pug
coc-rust-analyzer
coc-git
coc-fzf
coc-css
coc-yaml
coc-json
coc-html
coc-emmet
coc-vimlsp
coc-tsserver
2022-09-01 19:23:12 +00:00
{
plugin = gruvbox-nvim;
config = "colorscheme gruvbox";
}
{
plugin = nerdtree;
config = "nmap <C-n> :NERDTreeToggle<CR>";
}
{
plugin = nerdcommenter;
config = ''
vmap ++ <plug>NERDCommenterToggle
nmap ++ <plug>NERDCommenterToggle
'';
}
];
# }}}
# Coc {{{
2022-09-02 08:33:55 +00:00
coc = {
enable = true;
settings = { };
pluginConfig = ''
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nnoremap <silent> K :call <SID>show_documentation()<CR>
nmap gr <Plug>(coc-rename)
nmap <leader>ac <Plug>(coc-codeaction)
nmap <leader>qf <Plug>(coc-fix-current)
'';
};
2022-09-01 19:23:12 +00:00
# }}}
extraConfig = ''
set fdm=marker
nmap H _
vmap H _
nmap L $
vmap L $
" terminal normal mode
tnoremap <Esc> <C-\><C-n>
" j/k move virtual lines (wrapped)
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
set relativenumber
set number
set smarttab
set cindent
set tabstop=4
set shiftwidth=4
" Emacs Insert mode/command mode hotkeys {{{
" movement
inoremap <C-f> <Right>
inoremap <C-b> <Left>
inoremap <C-p> <Up>
inoremap <C-n> <Down>
cnoremap <C-f> <Right>
cnoremap <C-b> <Left>
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
inoremap <C-e> <C-o>$
inoremap <C-a> <C-o>_
cnoremap <C-e> <C-o>$
cnoremap <C-a> <C-o>_
inoremap <M-f> <C-Right>
inoremap <M-b> <C-Left>
inoremap <M-e> <C-o>)
inoremap <M-a> <C-o>(
cnoremap <M-f> <C-Right>
cnoremap <M-b> <C-Left>
cnoremap <M-e> <C-o>)
cnoremap <M-a> <C-o>(
inoremap <M-<> <Esc>ggi
inoremap <M->> <Esc>Gi
cnoremap <M-<> <Esc>ggi
cnoremap <M->> <Esc>Gi
" editing
inoremap <C-d> <Del>
inoremap <M-BS> <C-o>db
inoremap <M-d> <C-o>de
cnoremap <C-d> <Del>
cnoremap <M-BS> <C-o>db
cnoremap <M-d> <C-o>de
inoremap <C-s> <C-o>/
inoremap <C-r> <C-o>?
" }}}
'';
};
};
};
}