Skip to content

Instantly share code, notes, and snippets.

@mingkaic
Last active December 31, 2023 03:39
Show Gist options
  • Select an option

  • Save mingkaic/8f53f9f7b3f4179878eb8967505f1434 to your computer and use it in GitHub Desktop.

Select an option

Save mingkaic/8f53f9f7b3f4179878eb8967505f1434 to your computer and use it in GitHub Desktop.
My neovim init
""" vim-plug plugins (to install `curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim`)
call plug#begin('~/.config/nvim/plugged')
" syntax
"Plug 'valloric/youcompleteme', { 'dir': '~/.config/nvim/plugged/youcompleteme', 'do': './install.py --all' }
Plug 'stefandtw/quickfix-reflector.vim'
Plug 'scrooloose/syntastic'
Plug 'scrooloose/nerdcommenter'
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
Plug 'andersbakken/rtags'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'neovim/nvim-lspconfig'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" git/history
Plug 'tpope/vim-fugitive'
Plug 'mbbill/undotree'
" explorer/navigation
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'majutsushi/tagbar'
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
Plug 'jremmen/vim-ripgrep'
" visuals
Plug 'flazz/vim-colorschemes'
Plug 'itchyny/lightline.vim'
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'webdevel/tabulous'
" frameworks
Plug 'skywind3000/asyncrun.vim'
call plug#end()
""" formatting configs
" general
set number
set belloff=all
set encoding=utf-8
set noswapfile
set nobackup
set undodir=~/.config/nvim/undodir
set undofile
set incsearch
let mapleader = " "
" explorer
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_localrmdir = 'rm -r'
let g:netrw_list_hide = '.*\.swp$,.DS_Store,*/tmp/*,*.so,*.swp,*.zip,*.git,^\.\.\=/\=$'
" syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" visuals
syntax on
colorscheme vividchalk
" styles
set tw=100
set colorcolumn=100
highlight ColorColumn ctermbg=8
" indentations
set smartindent
set tabstop=4 softtabstop=4 shiftwidth=4
autocmd FileType python setlocal expandtab
autocmd FileType java setlocal expandtab
autocmd FileType json setlocal expandtab
autocmd FileType js setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
if executable('rg')
let g:rg_derive_root='true'
endif
" on save
fun! TrimWhiteSpace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
autocmd BufWritePre * :call TrimWhiteSpace()
autocmd BufWritePre *.go :silent call CocAction('runCommand', 'editor.action.organizeImport')
autocmd BufWritePost * mksession! ~/Session.vim
" on enter
autocmd! VimLeave * mksession! ~/Session.vim
" on enter
autocmd! VimEnter * source ~/Session.vim
""" remaps
nmap <leader>h :wincmd h<CR>
nmap <leader>j :wincmd j<CR>
nmap <leader>k :wincmd k<CR>
nmap <leader>l :wincmd l<CR>
nmap <leader>w <C-w>
nmap <leader>u :UndotreeShow<CR>
nmap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
nmap <leader>ps :Rg<SPACE>
nmap <leader>gd <Plug>(coc-definition)
nmap <leader>gy <Plug>(coc-type-definition)
nmap <leader>gi <Plug>(coc-implementation)
nmap <leader>gr <Plug>(coc-references)
nmap <leader>pp :FZF<CR>
nmap <leader>gpp :GFiles<CR>
nmap <F8> :TagbarToggle<CR>
nmap <C-\> <plug>NERDCommenterToggle
vmap <C-\> <plug>NERDCommenterToggle<CR>gv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment