home: setup vim

master
Chan Wen Xu 2021-09-12 23:54:45 +07:00
parent 2752ceaf2f
commit a432abe279
3 changed files with 89 additions and 1 deletions

@ -25,7 +25,6 @@
firefox
git
git-crypt
vim
];
fonts.fonts = with pkgs; [

@ -25,6 +25,19 @@
size = 12;
};
};
programs.neovim = {
enable = true;
coc.enable = true;
vimAlias = true;
withNodeJs = true;
plugins = with pkgs.vimPlugins; [
coc-nvim
coc-clangd
vim-airline
onedark-vim
];
extraConfig = builtins.readFile ./vimrc;
};
programs.zsh = {
enable = true;
enableSyntaxHighlighting = true;

@ -0,0 +1,76 @@
set nocompatible
set showcmd
set rnu
syntax on
filetype on
filetype plugin on
filetype indent on
colorscheme onedark
hi Comment guifg=#b7ffbd ctermfg=102
hi Normal guifg=#eeeeee guibg=#00000ee
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
" --BACKUP
set backup
set backupdir=~/.vim/backup/
set writebackup
set backupcopy=yes
au BufWritePre * let &bex = '@' . strftime("%F.%H:%M")
" --Display
set mouse=ar
set title
set number "Line numbers
set ruler
set wrap
set scrolloff=3
set lazyredraw
set termguicolors
set foldmethod=indent
set foldlevelstart=8 "Don't fold automatically unless really nested
" --Search
set ignorecase
set smartcase
set incsearch
set hlsearch
" --Tab
set tabstop=4
set shiftwidth=4
set softtabstop=0
" --Beep
set visualbell
set noerrorbells
set backspace=indent,eol,start
set hidden
" --Svelte files are essentially HTML
autocmd BufRead,BufNewFile *.svelte set filetype=html
" --My cute shortcuts
noremap // :nohls<CR>
inoremap jj <Esc>
" (q)uit, (w)ith path edit, (e)dit, (r)eload
noremap ,q :wqa<CR>
noremap ,w :tabedit<SPACE>
noremap ,e :tabnew<CR>:Files<CR>
noremap ,r :so ~/.vimrc<CR>
" (h)elp
noremap ,h :help<SPACE>
noremap <C-j> :bn<CR>
noremap <C-k> :bp<CR>
autocmd FileType cpp noremap ,c :!g++<SPACE>
autocmd FileType cpp map ,cf ,c"%"<CR>
autocmd FileType cpp map ,r ,c-o a ;./a;rm a<C-Left><C-Left>
autocmd FileType cpp map ,rf ,r"%"<CR>