309 lines
9.3 KiB
VimL
309 lines
9.3 KiB
VimL
call plug#begin('~/.vim/plugged')
|
|
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " Amazing combination of features.
|
|
"Plug 'godoctor/godoctor.vim' " Some refactoring tools
|
|
Plug 'plytophogy/vim-virtualenv'
|
|
Plug 'mg979/vim-visual-multi'
|
|
Plug 'airblade/vim-rooter'
|
|
Plug 'vim-airline/vim-airline'
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
" Plug 'majutsushi/tagbar' " install exuberant-ctags
|
|
Plug 'tpope/vim-commentary'
|
|
Plug 'tpope/vim-fugitive'
|
|
" Plug 'SirVer/ultisnips'
|
|
" Plug 'neomake/neomake'
|
|
" Plug 'godlygeek/tabular'
|
|
Plug 'lepture/vim-jinja'
|
|
Plug 'b4b4r07/vim-hcl'
|
|
Plug 'hashivim/vim-packer'
|
|
Plug 'hashivim/vim-terraform'
|
|
" Plug 'scrooloose/nerdtree'
|
|
Plug 'preservim/nerdtree'
|
|
Plug 'PotatoesMaster/i3-vim-syntax'
|
|
"Plug 'tpope/vim-surround'
|
|
"Plugin 'jiangmiao/auto-pairs'
|
|
"Plug 'elzr/vim-json'
|
|
Plug 'tsandall/vim-rego'
|
|
Plug 'honza/vim-snippets'
|
|
if !has('nvim')
|
|
" Plugins for when you're not using neovim
|
|
endif
|
|
if has('nvim')
|
|
" Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
|
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
|
"Plug 'jodosha/vim-godebug' " Debugger integration via delve
|
|
endif
|
|
" All of your Plugs must be added before the following line
|
|
call plug#end()
|
|
|
|
"""""""""""""""""
|
|
" Plugin Config "
|
|
"""""""""""""""""
|
|
""" deoplete
|
|
if has('nvim')
|
|
" ---------------------------------------------------------------------------
|
|
" coc.nvim default settings
|
|
" ---------------------------------------------------------------------------
|
|
|
|
" if hidden is not set, TextEdit might fail.
|
|
set hidden
|
|
" Better display for messages
|
|
set cmdheight=2
|
|
" Smaller updatetime for CursorHold & CursorHoldI
|
|
set updatetime=300
|
|
" don't give |ins-completion-menu| messages.
|
|
set shortmess+=c
|
|
" always show signcolumns
|
|
set signcolumn=yes
|
|
|
|
" Use tab for trigger completion with characters ahead and navigate.
|
|
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
|
|
inoremap <silent><expr> <TAB>
|
|
\ pumvisible() ? "\<C-n>" :
|
|
\ <SID>check_back_space() ? "\<TAB>" :
|
|
\ coc#refresh()
|
|
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
|
|
|
function! s:check_back_space() abort
|
|
let col = col('.') - 1
|
|
return !col || getline('.')[col - 1] =~# '\s'
|
|
endfunction
|
|
|
|
" Use <c-space> to trigger completion.
|
|
inoremap <silent><expr> <c-space> coc#refresh()
|
|
|
|
" Use `[c` and `]c` to navigate diagnostics
|
|
nmap <silent> [c <Plug>(coc-diagnostic-prev)
|
|
nmap <silent> ]c <Plug>(coc-diagnostic-next)
|
|
|
|
" Remap keys for gotos
|
|
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)
|
|
|
|
" Use U to show documentation in preview window
|
|
nnoremap <silent> U :call <SID>show_documentation()<CR>
|
|
|
|
" Remap for rename current word
|
|
nmap <leader>rn <Plug>(coc-rename)
|
|
|
|
" Remap for format selected region
|
|
vmap <leader>f <Plug>(coc-format-selected)
|
|
nmap <leader>f <Plug>(coc-format-selected)
|
|
" Show all diagnostics
|
|
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
|
|
" Manage extensions
|
|
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
|
|
" Show commands
|
|
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
|
|
" Find symbol of current document
|
|
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
|
|
" Search workspace symbols
|
|
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
|
|
" Do default action for next item.
|
|
nnoremap <silent> <space>j :<C-u>CocNext<CR>
|
|
" Do default action for previous item.
|
|
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
|
|
" Resume latest coc list
|
|
nnoremap <silent> <space>p :<C-u>CocListResume<CR>n
|
|
|
|
"""" Snippets
|
|
|
|
" " Use <C-l> for trigger snippet expand.
|
|
" imap <C-l> <Plug>(coc-snippets-expand)
|
|
|
|
" " Use <C-j> for select text for visual placeholder of snippet.
|
|
" vmap <C-j> <Plug>(coc-snippets-select)
|
|
|
|
" " Use <C-j> for jump to next placeholder, it's default of coc.nvim
|
|
" let g:coc_snippet_next = '<c-j>'
|
|
|
|
" " Use <C-k> for jump to previous placeholder, it's default of coc.nvim
|
|
" let g:coc_snippet_prev = '<c-k>'
|
|
|
|
" " Use <C-j> for both expand and jump (make expand higher priority.)
|
|
" imap <C-j> <Plug>(coc-snippets-expand-jump)
|
|
|
|
" " Use <leader>x for convert visual selected code to snippet
|
|
" xmap <leader>x <Plug>(coc-convert-snippet)
|
|
|
|
inoremap <silent><expr> <TAB>
|
|
\ pumvisible() ? coc#_select_confirm() :
|
|
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
|
|
\ <SID>check_back_space() ? "\<TAB>" :
|
|
\ coc#refresh()
|
|
|
|
function! s:check_back_space() abort
|
|
let col = col('.') - 1
|
|
return !col || getline('.')[col - 1] =~# '\s'
|
|
endfunction
|
|
|
|
let g:coc_snippet_next = '<tab>'
|
|
endif
|
|
|
|
|
|
""" tagbar
|
|
nmap <F8> :TagbarToggle<CR>
|
|
let g:tagbar_type_go = {
|
|
\ 'ctagstype' : 'go',
|
|
\ 'kinds' : [
|
|
\ 'p:package',
|
|
\ 'i:imports:1',
|
|
\ 'c:constants',
|
|
\ 'v:variables',
|
|
\ 't:types',
|
|
\ 'n:interfaces',
|
|
\ 'w:fields',
|
|
\ 'e:embedded',
|
|
\ 'm:methods',
|
|
\ 'r:constructor',
|
|
\ 'f:functions'
|
|
\ ],
|
|
\ 'sro' : '.',
|
|
\ 'kind2scope' : {
|
|
\ 't' : 'ctype',
|
|
\ 'n' : 'ntype'
|
|
\ },
|
|
\ 'scope2kind' : {
|
|
\ 'ctype' : 't',
|
|
\ 'ntype' : 'n'
|
|
\ },
|
|
\ 'ctagsbin' : 'gotags',
|
|
\ 'ctagsargs' : '-sort -silent'
|
|
\ }
|
|
|
|
|
|
""" vim-rooter
|
|
" let g:rooter_use_lcd = 1
|
|
let g:rooter_cd_cmd="lcd"
|
|
let g:rooter_silent_chdir = 1
|
|
let g:rooter_resolve_links = 1
|
|
|
|
|
|
""" vim-terraform
|
|
let g:terraform_fmt_on_save=1
|
|
"autocmd filetype tf set syntax=terraform
|
|
autocmd FileType terraform setlocal commentstring=#%s
|
|
|
|
|
|
""" vim-jinja
|
|
autocmd BufNewFile,BufRead *.j2 set filetype=jinja
|
|
|
|
|
|
""" vim-go
|
|
" disable all linters as that is taken care of by coc.nvim
|
|
let g:go_diagnostics_enabled = 0
|
|
let g:go_metalinter_enabled = []
|
|
|
|
" don't jump to errors after metalinter is invoked
|
|
let g:go_jump_to_error = 0
|
|
|
|
" run go imports on file save
|
|
let g:go_fmt_command = "goimports"
|
|
|
|
" automatically highlight variable your cursor is on
|
|
let g:go_auto_sameids = 0
|
|
|
|
let g:go_highlight_types = 1
|
|
let g:go_highlight_types = 1
|
|
let g:go_highlight_fields = 1
|
|
let g:go_highlight_functions = 1
|
|
let g:go_highlight_function_calls = 1
|
|
let g:go_highlight_operators = 1
|
|
let g:go_highlight_extra_types = 1
|
|
let g:go_highlight_build_constraints = 1
|
|
let g:go_highlight_generate_tags = 1
|
|
|
|
" let g:go_def_mode='gopls'
|
|
" let g:go_info_mode='gopls'
|
|
let g:go_term_enabled = 1
|
|
|
|
" disable vim-go :GoDef short cut (gd)
|
|
" this is handled by LanguageClient [LC]
|
|
let g:go_def_mapping_enabled = 0
|
|
|
|
|
|
""" neomake
|
|
" Full config: when writing or reading a buffer, and on changes in insert and
|
|
" normal mode (after 1s; no delay when writing).
|
|
" call neomake#configure#automake('nrwi', 500)
|
|
|
|
|
|
""" NERDtree
|
|
" nnoremap <leader>n :NERDTreeFocus<CR>
|
|
" nnoremap <C-n> :NERDTree<CR>
|
|
nnoremap <C-t> :NERDTreeToggle<CR>
|
|
nnoremap <C-h> :NERDTreeFind<CR>
|
|
|
|
" Start NERDTree when Vim starts with a directory argument.
|
|
autocmd StdinReadPre * let s:std_in=1
|
|
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
|
|
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
|
|
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
|
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
|
" Close the tab if NERDTree is the only window remaining in it.
|
|
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
|
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
|
|
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
|
|
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
|
|
|
|
|
|
""" airline
|
|
let g:airline_theme='powerlineish' " <theme> is a valid theme name
|
|
let g:airline_powerline_fonts = 1
|
|
" powerline symbols
|
|
let g:airline_left_sep = ''
|
|
let g:airline_left_alt_sep = ''
|
|
let g:airline_right_sep = ''
|
|
let g:airline_right_alt_sep = ''
|
|
let g:airline_symbols = {}
|
|
let g:airline_symbols.branch = ''
|
|
let g:airline_symbols.readonly = ''
|
|
let g:airline_symbols.linenr = '☰'
|
|
let g:airline_symbols.maxlinenr = ''
|
|
let g:airline_symbols.dirty='⚡'
|
|
|
|
|
|
"""""""""""""""""""""
|
|
" Personal Settings "
|
|
"""""""""""""""""""""
|
|
set number
|
|
|
|
colorscheme Czar
|
|
hi Normal guibg=NONE ctermbg=NONE
|
|
|
|
command! W w !sudo tee >/dev/null %
|
|
|
|
set backupdir=~/.vim/tmp/backup//
|
|
set directory=~/.vim/tmp/swap//
|
|
set undodir=~/.vim/tmp/undo//
|
|
|
|
set completeopt-=preview
|
|
|
|
set colorcolumn=80
|
|
autocmd Filetype java setlocal colorcolumn=100
|
|
autocmd Filetype html setlocal colorcolumn=100
|
|
autocmd Filetype go setlocal colorcolumn=100
|
|
autocmd Filetype netrw setlocal colorcolumn=
|
|
|
|
set tabstop=2
|
|
set shiftwidth=2
|
|
set noexpandtab
|
|
autocmd FileType python setlocal expandtab
|
|
autocmd FileType python setlocal tabstop=4
|
|
autocmd FileType python setlocal shiftwidth=4
|
|
autocmd filetype json setlocal expandtab
|
|
autocmd filetype tf setlocal expandtab
|
|
|
|
"set list lcs=tab:\┆\ ,trail:▓,space:.
|
|
"set list lcs=tab:\⇥\ ,trail:▓,space:.
|
|
set list lcs=tab:\⇥\ ,trail:▓
|
|
|
|
""" Help Navigation
|
|
autocmd FileType help nnoremap <buffer> <CR> <C-]>
|
|
autocmd FileType help nnoremap <buffer> <BS> <C-T>
|
|
autocmd FileType help nnoremap <buffer> o /'\l\{2,\}'<CR>
|
|
autocmd FileType help nnoremap <buffer> O ?'\l\{2,\}'<CR>
|
|
autocmd FileType help nnoremap <buffer> s /\|\zs\S\+\ze\|<CR>
|
|
autocmd FileType help nnoremap <buffer> S ?\|\zs\S\+\ze\|<CR>
|