nix-configs/modules/neovim.nix

115 lines
2.6 KiB
Nix
Raw Normal View History

2022-09-01 21:23:12 +02: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
{
plugin = gruvbox-nvim;
config = "colorscheme gruvbox";
}
{
plugin = nerdtree;
config = "nmap <C-n> :NERDTreeToggle<CR>";
}
{
plugin = nerdcommenter;
config = ''
vmap ++ <plug>NERDCommenterToggle
nmap ++ <plug>NERDCommenterToggle
'';
}
];
# }}}
# Coc {{{
#coc = {
#enable = true;
#};
# }}}
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>?
" }}}
'';
};
};
};
}