2017-12-13 13:08:26 +00:00
|
|
|
|
2019-10-18 12:56:42 +00:00
|
|
|
" Function to source only if file exists {
|
|
|
|
function! SourceIfExists(file)
|
|
|
|
if filereadable(expand(a:file))
|
|
|
|
exe 'source' a:file
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
" }
|
|
|
|
|
2020-06-14 16:04:12 +00:00
|
|
|
let g:rc_files = {
|
2020-06-14 13:35:30 +00:00
|
|
|
\ 'early': '~/.config/vim/early.vimrc',
|
|
|
|
\ 'pre': '~/.config/vim/pre-plug.vimrc',
|
|
|
|
\ 'plug': '~/.config/vim/plug.vimrc',
|
|
|
|
\ 'post': '~/.config/vim/post-plug.vimrc',
|
2020-06-14 15:11:35 +00:00
|
|
|
\ 'late': '~/.config/vim/late.vimrc',
|
|
|
|
\ 'my': $MYVIMRC
|
2020-06-14 13:35:30 +00:00
|
|
|
\ }
|
|
|
|
|
|
|
|
" Edit source files
|
|
|
|
function! EditVimRcFiles()
|
2020-06-14 16:04:12 +00:00
|
|
|
for l:rc_key in keys(g:rc_files)
|
|
|
|
let l:ex_file = expand(g:rc_files[l:rc_key])
|
|
|
|
if filereadable(l:ex_file)
|
2020-08-03 15:56:05 +00:00
|
|
|
exe 'edit' l:ex_file
|
2020-06-14 13:35:30 +00:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endfunction
|
|
|
|
|
2020-06-14 16:04:12 +00:00
|
|
|
call SourceIfExists(g:rc_files['early'])
|
2020-06-12 19:05:48 +00:00
|
|
|
|
2020-07-16 13:40:42 +00:00
|
|
|
" set preferred color scheme if not set
|
|
|
|
if !exists("g:my_color_scheme")
|
|
|
|
let g:my_color_scheme='one'
|
|
|
|
endif
|
|
|
|
|
2020-06-09 20:41:11 +00:00
|
|
|
" Hide buffers don't close them
|
|
|
|
set hidden
|
2020-08-03 15:56:05 +00:00
|
|
|
|
|
|
|
" Sane pane opening
|
|
|
|
set splitbelow
|
|
|
|
set splitright
|
2020-06-09 20:41:11 +00:00
|
|
|
|
|
|
|
" File indent opts
|
|
|
|
set shiftwidth=2
|
|
|
|
set tabstop=8
|
|
|
|
set softtabstop=2
|
|
|
|
set expandtab
|
2020-06-14 15:11:35 +00:00
|
|
|
set encoding=utf-8
|
2020-08-05 13:01:02 +00:00
|
|
|
try
|
|
|
|
" Vim 8.2 only
|
|
|
|
exec "set listchars=trail:\u02FD,extends:\u22B3,precedes:\u22B2,nbsp:\u02EC,conceal:\u2219,tab:\u2559\u254C\u2556"
|
|
|
|
catch
|
|
|
|
exec "set listchars=trail:\u02FD,extends:\u22B3,precedes:\u22B2,nbsp:\u02EC,conceal:\u2219,tab:\u2559\u254C"
|
|
|
|
endtry
|
2020-06-14 15:11:35 +00:00
|
|
|
set list
|
2020-06-14 15:18:25 +00:00
|
|
|
set ignorecase
|
|
|
|
set infercase
|
2020-06-09 20:41:11 +00:00
|
|
|
filetype plugin indent on
|
|
|
|
|
|
|
|
" Set completion messages off
|
|
|
|
set shortmess+=c
|
|
|
|
|
|
|
|
" Preview window + menu for autocompletions
|
|
|
|
set completeopt+=preview
|
|
|
|
set completeopt+=menuone
|
|
|
|
set completeopt+=longest
|
|
|
|
|
|
|
|
" Lower update time (Default 4000)
|
|
|
|
set updatetime=300
|
|
|
|
|
2021-08-08 19:22:07 +00:00
|
|
|
set number
|
|
|
|
set relativenumber
|
2020-06-09 20:41:11 +00:00
|
|
|
try
|
2021-08-08 19:22:07 +00:00
|
|
|
set signcolumn=auto
|
2020-06-09 20:41:11 +00:00
|
|
|
catch
|
|
|
|
set signcolumn=yes:1
|
|
|
|
endtry
|
2021-08-08 19:22:07 +00:00
|
|
|
|
|
|
|
" Use existing buffers
|
|
|
|
set switchbuf="useopen,usetab"
|
2019-10-18 12:56:42 +00:00
|
|
|
|
2020-06-09 20:41:11 +00:00
|
|
|
if exists('+termguicolors')
|
|
|
|
set termguicolors
|
|
|
|
endif
|
2019-10-18 12:56:42 +00:00
|
|
|
|
2020-06-14 16:04:12 +00:00
|
|
|
exec "set rtp=$VIMHOME," . &rtp
|
2017-12-13 13:08:26 +00:00
|
|
|
|
2020-10-03 14:48:05 +00:00
|
|
|
" Better if check for loading plugins
|
|
|
|
" This one won't cause vim-plug to autodelete 'unloaded' plugins
|
2020-10-01 13:23:04 +00:00
|
|
|
function! LoadIf(check, ...)
|
|
|
|
let opts = get(a:000, 0, {})
|
|
|
|
" Use opts, or default to not loading plugin
|
|
|
|
return a:check ? opts : extend(opts, { 'on': [], 'for': [] })
|
|
|
|
endfunction
|
|
|
|
|
2020-10-03 14:48:05 +00:00
|
|
|
" Check if we can use async Syntastic
|
2020-10-01 13:23:04 +00:00
|
|
|
let useNeomake = has('nvim') || v:version > 800
|
2020-05-01 13:04:55 +00:00
|
|
|
|
2020-06-14 16:04:12 +00:00
|
|
|
call SourceIfExists(g:rc_files['pre'])
|
2018-05-02 12:51:32 +00:00
|
|
|
call plug#begin("$VIMHOME/plugged")
|
2020-06-14 15:11:35 +00:00
|
|
|
Plug 'junegunn/vim-easy-align'
|
2020-10-03 14:48:05 +00:00
|
|
|
Plug 'tmsvg/pear-tree'
|
2017-12-13 13:08:26 +00:00
|
|
|
Plug 'tpope/vim-sensible'
|
|
|
|
Plug 'tpope/vim-fugitive'
|
2020-06-09 20:41:11 +00:00
|
|
|
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
|
|
|
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
|
2017-12-13 13:08:26 +00:00
|
|
|
Plug 'scrooloose/nerdcommenter'
|
|
|
|
Plug 'scrooloose/vim-statline'
|
2021-08-08 19:22:07 +00:00
|
|
|
Plug 'qpkorr/vim-bufkill'
|
2017-12-13 13:08:26 +00:00
|
|
|
Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
|
2020-06-09 20:41:11 +00:00
|
|
|
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
|
|
|
|
Plug 'pearofducks/ansible-vim', { 'for': ['yaml', 'yml'] }
|
2019-01-15 11:36:11 +00:00
|
|
|
Plug 'luochen1990/rainbow'
|
2020-07-16 14:20:25 +00:00
|
|
|
Plug 'kevinoid/vim-jsonc'
|
2020-06-09 20:41:11 +00:00
|
|
|
Plug 'junegunn/fzf', { 'on': ['FZF', '<Plug>fzf#run', '<Plug>fzf#wrap'] }
|
2020-10-03 16:02:30 +00:00
|
|
|
Plug 'junegunn/fzf.vim'
|
2020-05-01 13:04:55 +00:00
|
|
|
Plug 'sheerun/vim-polyglot'
|
2020-06-09 20:41:11 +00:00
|
|
|
Plug 'adelarsq/vim-matchit'
|
|
|
|
Plug 'vim-airline/vim-airline'
|
|
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
|
|
Plug 'airblade/vim-gitgutter'
|
2020-06-14 15:11:35 +00:00
|
|
|
Plug 'rakr/vim-one'
|
|
|
|
Plug 'mox-mox/vim-localsearch'
|
2020-07-11 14:59:08 +00:00
|
|
|
Plug 'romainl/vim-cool'
|
|
|
|
Plug 'christoomey/vim-tmux-navigator', { 'on': ['TmuxNavigateLeft', 'TmuxNavigateDown', 'TmuxNavigateUp', 'TmuxNavigateRight', 'TmuxNavigatePrevious'] }
|
2020-10-01 13:23:04 +00:00
|
|
|
|
|
|
|
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
|
|
|
|
Plug 'scrooloose/syntastic', LoadIf(!useNeomake)
|
|
|
|
Plug 'neomake/neomake', LoadIf(useNeomake)
|
2020-10-03 14:48:05 +00:00
|
|
|
Plug 'romainl/vim-qf', LoadIf(useNeomake)
|
2020-10-01 13:23:04 +00:00
|
|
|
|
|
|
|
Plug 'roxma/nvim-yarp', LoadIf(has('nvim'))
|
|
|
|
Plug 'roxma/vim-hug-neovim-rpc', LoadIf(has('nvim'))
|
2020-06-14 16:04:12 +00:00
|
|
|
call SourceIfExists(g:rc_files['plug'])
|
2017-12-13 13:08:26 +00:00
|
|
|
call plug#end()
|
2020-06-14 16:04:12 +00:00
|
|
|
call SourceIfExists(g:rc_files['post'])
|
2017-12-13 13:08:26 +00:00
|
|
|
|
|
|
|
execute ':silent !mkdir -p ~/.vimbackup'
|
|
|
|
|
2020-06-14 16:04:12 +00:00
|
|
|
set backupdir=~/.vimbackup
|
2017-12-13 13:08:26 +00:00
|
|
|
set directory=~/.vimbackup
|
|
|
|
set hlsearch
|
|
|
|
|
2020-06-09 20:41:11 +00:00
|
|
|
" Airline
|
2020-06-14 15:11:35 +00:00
|
|
|
" Airline replaces showmode
|
|
|
|
set noshowmode
|
2020-06-09 20:41:11 +00:00
|
|
|
let g:airline#extensions#branch#format = 2
|
|
|
|
let g:airline#extensions#branch#displayed_head_limit = 16
|
2020-06-14 15:11:35 +00:00
|
|
|
let g:airline#extensions#tabline#enabled = 1
|
|
|
|
let g:airline#extensions#tabline#left_alt_sep = '|'
|
2020-08-03 15:56:05 +00:00
|
|
|
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
|
2020-06-14 15:11:35 +00:00
|
|
|
let g:airline_powerline_fonts = 1
|
2020-07-16 14:51:43 +00:00
|
|
|
let g:airline_theme='one'
|
2020-06-14 15:11:35 +00:00
|
|
|
if !exists('g:airline_symbols')
|
|
|
|
let g:airline_symbols = {}
|
|
|
|
endif
|
2020-06-09 20:41:11 +00:00
|
|
|
|
2017-12-13 13:08:26 +00:00
|
|
|
" Commenting
|
|
|
|
let g:NERDSpaceDelims = 1
|
|
|
|
let g:NERDCompactSexyComs = 1
|
|
|
|
let g:NERDDefaultAlign = 'left'
|
|
|
|
let g:NERDCommentEmptyLines = 1
|
|
|
|
let g:NERDTrimTrailingWhitespace = 1
|
|
|
|
|
2020-06-09 20:41:11 +00:00
|
|
|
augroup PsoxNERDTree
|
|
|
|
autocmd!
|
|
|
|
" Autoquit if nerdtree is last open window
|
|
|
|
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
|
|
|
|
|
|
|
" Open nerdtree if opening a directory
|
|
|
|
autocmd StdinReadPre * let s:std_in=1
|
|
|
|
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
|
|
|
|
augroup END
|
|
|
|
|
2020-10-01 13:23:04 +00:00
|
|
|
if useNeomake
|
2020-10-03 14:48:05 +00:00
|
|
|
" Don't move cursor into qf/loc on open
|
2020-10-01 13:23:04 +00:00
|
|
|
let g:neomake_open_list = 2
|
2020-10-03 14:48:05 +00:00
|
|
|
" Allow multiple makers to resolve
|
2020-10-01 13:23:04 +00:00
|
|
|
let g:neomake_serialize = 1
|
|
|
|
let g:neomake_serialize_abort_on_error = 1
|
|
|
|
" Run on write (instant) + read (800ms) buffers
|
|
|
|
call neomake#configure#automake('rw', 800)
|
|
|
|
|
2020-10-03 14:48:05 +00:00
|
|
|
" Disable inherited syntastic if it exists
|
2020-10-01 13:23:04 +00:00
|
|
|
if has_key(plugs, 'syntastic')
|
|
|
|
let g:syntastic_mode_map = {
|
|
|
|
\ "mode": "passive",
|
|
|
|
\ "active_filetypes": [],
|
|
|
|
\ "passive_filetypes": [] }
|
|
|
|
endif
|
|
|
|
endif
|
2020-06-09 20:41:11 +00:00
|
|
|
|
2020-10-03 14:48:05 +00:00
|
|
|
" If we can't use Neomake, fall back to Syntastic
|
2020-10-01 13:23:04 +00:00
|
|
|
if !useNeomake
|
|
|
|
" Syntastic Settings
|
|
|
|
" Note that airline automatically configures these
|
|
|
|
let g:syntastic_always_populate_loc_list = 1
|
|
|
|
let g:syntastic_enable_signs = 1
|
|
|
|
let g:syntastic_auto_loc_list = 1
|
|
|
|
let g:syntastic_check_on_open = 1
|
|
|
|
let g:syntastic_check_on_wq = 0
|
|
|
|
" Syntastic enable specific checkers
|
|
|
|
let g:syntastic_enable_zsh_checker = 1
|
|
|
|
let g:syntastic_enable_bash_checker = 1
|
|
|
|
endif
|
2017-12-13 13:08:26 +00:00
|
|
|
|
2020-10-03 14:48:05 +00:00
|
|
|
" vim-qf
|
|
|
|
if has_key(plugs, 'vim-qf')
|
|
|
|
" Don't force qf/loc windows to bottom
|
|
|
|
let g:qf_window_bottom = 0
|
|
|
|
let g:qf_loclist_window_bottom = 0
|
|
|
|
|
|
|
|
" Let Neomake control window size
|
|
|
|
if useNeomake
|
|
|
|
let g:qf_auto_resize = 0
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2019-09-11 09:09:50 +00:00
|
|
|
" ripgrep settings
|
2019-09-11 09:51:26 +00:00
|
|
|
let g:rg_highlight = 'true'
|
|
|
|
let g:rg_derive_root = 'true'
|
2019-09-11 09:09:50 +00:00
|
|
|
|
2020-10-03 14:48:05 +00:00
|
|
|
" Balance pairs when on open, close and delete
|
|
|
|
let g:pear_tree_smart_openers = 1
|
|
|
|
let g:pear_tree_smart_closers = 1
|
|
|
|
let g:pear_tree_smart_backspace = 1
|
|
|
|
|
2020-06-09 20:41:11 +00:00
|
|
|
" Other
|
|
|
|
let g:rainbow_active = 1
|
|
|
|
augroup PsoxFileAutos
|
|
|
|
autocmd!
|
|
|
|
autocmd FileType yaml setlocal indentkeys-=<:> ts=8 sts=2 sw=2 expandtab
|
2020-10-03 15:34:22 +00:00
|
|
|
autocmd FileType go setlocal ts=8 sts=4 sw=4 noexpandtab
|
2021-04-22 14:58:44 +00:00
|
|
|
\| autocmd BufWritePre <buffer> silent :call CocAction('format')
|
2020-06-09 20:41:11 +00:00
|
|
|
" Tidy nerdtree windiw
|
|
|
|
autocmd FileType nerdtree setlocal nocursorcolumn nonumber norelativenumber signcolumn=no
|
2020-10-03 15:34:22 +00:00
|
|
|
" Autoinstall absent plugins
|
2020-07-11 14:59:08 +00:00
|
|
|
autocmd VimEnter *
|
|
|
|
\ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
|
|
|
\| PlugInstall --sync
|
|
|
|
\| q
|
2020-07-16 13:40:42 +00:00
|
|
|
\| execute "colorscheme " . g:my_color_scheme
|
2020-07-11 14:59:08 +00:00
|
|
|
\| endif
|
2021-04-22 14:58:44 +00:00
|
|
|
|
|
|
|
if has_key(plugs, 'coc.nvim')
|
2021-08-08 19:22:07 +00:00
|
|
|
" Highlight the symbol and its references when hovering
|
2021-04-22 14:58:44 +00:00
|
|
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|
2021-08-08 19:22:07 +00:00
|
|
|
" Update signature help on jump placeholder
|
|
|
|
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
2021-04-22 14:58:44 +00:00
|
|
|
endif
|
2021-08-08 19:22:07 +00:00
|
|
|
|
|
|
|
" Force non file buffers to not pollute the buffer list
|
|
|
|
autocmd FileType quickfix,netrw setlocal nobuflisted
|
|
|
|
|
|
|
|
" Actually kill netrw when trying to quit it
|
|
|
|
autocmd FileType netrw nnoremap <buffer><silent> <Esc> :call <SID>CloseNetrw()<CR>
|
2020-06-09 20:41:11 +00:00
|
|
|
augroup END
|
|
|
|
|
2021-08-08 19:22:07 +00:00
|
|
|
function! s:CloseNetrw() abort
|
|
|
|
for bufn in range(1, bufnr('$'))
|
|
|
|
if bufexists(bufn) && getbufvar(bufn, '&filetype') ==# 'netrw'
|
|
|
|
silent! execute 'bwipeout ' . bufn
|
|
|
|
if getline(2) =~# '^" Netrw '
|
|
|
|
silent! bwipeout
|
|
|
|
endif
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endfunction
|
|
|
|
|
2020-06-09 20:41:11 +00:00
|
|
|
" Set bindings for coc.nvim
|
2021-08-08 19:22:07 +00:00
|
|
|
if has_key(plugs, 'coc.nvim') && executable("node")
|
2020-07-16 10:14:58 +00:00
|
|
|
if !exists("g:coc_global_extensions")
|
|
|
|
let g:coc_global_extensions=[]
|
|
|
|
endif
|
2020-07-11 14:59:08 +00:00
|
|
|
let g:coc_global_extensions+=[ 'coc-yank' ]
|
|
|
|
let g:coc_global_extensions+=[ 'coc-spell-checker' ]
|
|
|
|
let g:coc_global_extensions+=[ 'coc-vimlsp' ]
|
|
|
|
let g:coc_global_extensions+=[ 'coc-rust-analyzer' ]
|
|
|
|
let g:coc_global_extensions+=[ 'coc-json' ]
|
|
|
|
let g:coc_global_extensions+=[ 'coc-markdownlint' ]
|
|
|
|
let g:coc_global_extensions+=[ 'coc-yaml' ]
|
2021-04-22 14:58:44 +00:00
|
|
|
|
2021-04-26 10:44:22 +00:00
|
|
|
" Do action on current word
|
|
|
|
nmap <silent> <leader>. <Plug>(coc-codeaction-selected)w
|
|
|
|
|
|
|
|
" Do action on a selection
|
|
|
|
nmap <silent> <leader>/ <Plug>(coc-codeaction-selected)
|
|
|
|
xmap <silent> <leader>/ <Plug>(coc-codeaction-selected)
|
2021-04-22 14:58:44 +00:00
|
|
|
|
2021-08-08 19:22:07 +00:00
|
|
|
" rename symbol
|
2021-08-15 11:07:44 +00:00
|
|
|
nmap <silent> <leader>rn <Plug>(coc-rename)
|
2021-08-08 19:22:07 +00:00
|
|
|
" goto definition / references
|
2021-08-15 11:07:44 +00:00
|
|
|
nmap <silent> <leader>gd <Plug>(coc-definition)
|
|
|
|
nmap <silent> <leader>gr <Plug>(coc-references)
|
2021-08-08 19:22:07 +00:00
|
|
|
|
2022-08-17 15:22:15 +00:00
|
|
|
" Add `:Format` command to format current buffer.
|
|
|
|
command! -nargs=0 Format :call CocActionAsync('format')
|
|
|
|
|
2020-06-09 20:41:11 +00:00
|
|
|
" Use tab for trigger completion with characters ahead and navigate.
|
|
|
|
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
|
|
|
" other plugin before putting this into your config.
|
2020-07-11 14:59:08 +00:00
|
|
|
inoremap <silent><expr> <TAB>
|
2022-08-17 15:22:15 +00:00
|
|
|
\ coc#pum#visible() ? coc#pum#next(1):
|
|
|
|
\ CheckBackspace() ? "\<Tab>" :
|
2020-06-09 20:41:11 +00:00
|
|
|
\ coc#refresh()
|
2022-08-17 15:22:15 +00:00
|
|
|
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
|
|
|
|
|
|
|
|
" Make <CR> to accept selected completion item or notify coc.nvim to format
|
|
|
|
" <C-g>u breaks current undo, please make your own choice.
|
|
|
|
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
|
|
|
|
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
2020-06-09 20:41:11 +00:00
|
|
|
|
2022-08-17 15:22:15 +00:00
|
|
|
function! CheckBackspace() abort
|
2020-06-09 20:41:11 +00:00
|
|
|
let col = col('.') - 1
|
|
|
|
return !col || getline('.')[col - 1] =~# '\s'
|
|
|
|
endfunction
|
|
|
|
|
2022-08-17 15:22:15 +00:00
|
|
|
" Use <c-space> to trigger completion.
|
|
|
|
if has('nvim')
|
|
|
|
inoremap <silent><expr> <c-space> coc#refresh()
|
2020-06-09 20:41:11 +00:00
|
|
|
else
|
2022-08-17 15:22:15 +00:00
|
|
|
inoremap <silent><expr> <c-@> coc#refresh()
|
2020-06-09 20:41:11 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
" Use `[g` and `]g` to navigate diagnostics
|
2020-07-11 14:59:08 +00:00
|
|
|
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
|
|
|
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
|
|
|
|
2021-04-22 14:58:44 +00:00
|
|
|
" Remap PageUp and PageDown for scroll float windows/popups.
|
|
|
|
if has('nvim-0.4.0') || has('patch-8.2.0750')
|
|
|
|
" Normal
|
|
|
|
nnoremap <silent><nowait><expr> <PageDown> coc#float#has_scroll() ? coc#float#scroll(1) : "\<PageDown>"
|
|
|
|
nnoremap <silent><nowait><expr> <PageUp> coc#float#has_scroll() ? coc#float#scroll(0) : "\<PageUp>"
|
|
|
|
endif
|
|
|
|
|
2020-07-11 14:59:08 +00:00
|
|
|
" Use K to show documentation in preview window.
|
2022-08-17 15:22:15 +00:00
|
|
|
nnoremap <silent> K :call ShowDocumentation()<CR>
|
|
|
|
|
|
|
|
function! ShowDocumentation()
|
|
|
|
if CocAction('hasProvider', 'hover')
|
2021-04-22 14:58:44 +00:00
|
|
|
call CocActionAsync('doHover')
|
2020-07-11 14:59:08 +00:00
|
|
|
else
|
2022-08-17 15:22:15 +00:00
|
|
|
call feedkeys('K', 'in')
|
2020-07-11 14:59:08 +00:00
|
|
|
endif
|
2020-06-09 20:41:11 +00:00
|
|
|
endfunction
|
2020-07-11 14:59:08 +00:00
|
|
|
|
2021-04-22 14:58:44 +00:00
|
|
|
" Open yank list
|
2020-07-11 14:59:08 +00:00
|
|
|
nnoremap <silent> <C-Y> :<C-u>CocList -A --normal yank<CR>
|
|
|
|
endif
|
2020-06-09 20:41:11 +00:00
|
|
|
|
2021-08-08 19:22:07 +00:00
|
|
|
" FZF overides
|
|
|
|
if has_key(plugs, 'fzf.vim')
|
|
|
|
if executable('rg')
|
|
|
|
" Only search file contents, not file name
|
|
|
|
" We can use the stock :Files for that
|
|
|
|
command! -bang -nargs=* Rg call
|
|
|
|
\ fzf#vim#grep(
|
|
|
|
\ "rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>),
|
|
|
|
\ 1,
|
|
|
|
\ fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}),
|
|
|
|
\ <bang>0
|
|
|
|
\ )
|
|
|
|
|
|
|
|
" Override the default grep implementation in vim
|
|
|
|
set grepprg=rg\ --vimgrep\ --smart-case\ --follow
|
|
|
|
|
|
|
|
" If the user hasn't set a default FZF command, and has ripgrep installed,
|
|
|
|
" use it over find, otherwise defer to the user's preferred command
|
|
|
|
if empty($FZF_DEFAULT_COMMAND)
|
|
|
|
command! -bang -nargs=? -complete=dir Files call
|
|
|
|
\ fzf#vim#files(<q-args>, fzf#vim#with_preview({'source': 'rg --files --hidden --glob "!**/.git/**" ' }), <bang>0)
|
|
|
|
endif
|
|
|
|
|
2021-11-04 15:11:37 +00:00
|
|
|
nnoremap <A-g> :Rg
|
|
|
|
nnoremap <leader><A-g> :Rg!
|
2021-08-15 11:07:44 +00:00
|
|
|
nnoremap <silent> <A-S-g> :Rg<CR>
|
|
|
|
nnoremap <silent> <leader><A-S-g> :Rg!<CR>
|
2021-08-08 19:22:07 +00:00
|
|
|
endif
|
|
|
|
|
2021-11-04 15:11:37 +00:00
|
|
|
nnoremap <A-f> :Files
|
|
|
|
nnoremap <leader><A-f> :Files!
|
2021-08-15 11:07:44 +00:00
|
|
|
nnoremap <silent> <A-S-f> :Files<CR>
|
|
|
|
nnoremap <silent> <leader><A-S-f> :Files!<CR>
|
|
|
|
|
|
|
|
nnoremap <A-b> :Buffers
|
2021-11-04 15:11:37 +00:00
|
|
|
nnoremap <leader><A-b> :Buffers!
|
2021-08-15 11:07:44 +00:00
|
|
|
nnoremap <silent> <A-S-b> :Buffers<CR>
|
|
|
|
nnoremap <silent> <leader><A-S-b> :Buffers!<CR>
|
2021-08-08 19:22:07 +00:00
|
|
|
endif
|
|
|
|
|
2020-07-11 14:59:08 +00:00
|
|
|
" Vim Tmux unified movement
|
|
|
|
if has_key(plugs, 'vim-tmux-navigator')
|
|
|
|
let g:tmux_navigator_no_mappings = 1
|
|
|
|
let g:tmux_navigator_disable_when_zoomed = 1
|
|
|
|
|
|
|
|
nnoremap <silent> <C-h> :TmuxNavigateLeft<cr>
|
|
|
|
nnoremap <silent> <C-j> :TmuxNavigateDown<cr>
|
|
|
|
nnoremap <silent> <C-k> :TmuxNavigateUp<cr>
|
|
|
|
nnoremap <silent> <C-l> :TmuxNavigateRight<cr>
|
2020-06-09 20:41:11 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
" NERDTree Toggle
|
|
|
|
nnoremap <F2> :NERDTreeToggle<CR>
|
|
|
|
|
|
|
|
" Workaround for writing readonly files
|
2020-06-14 16:04:12 +00:00
|
|
|
cnoremap w!! w !sudo tee % > /dev/null
|
2020-06-09 20:41:11 +00:00
|
|
|
|
2020-08-03 15:56:05 +00:00
|
|
|
" Vim config(s) editing
|
2020-07-16 14:43:30 +00:00
|
|
|
nnoremap <leader>ve :call EditVimRcFiles()<cr>
|
|
|
|
nnoremap <leader>vs :source $MYVIMRC<cr>
|
|
|
|
nnoremap <leader>vl <Plug>localsearch_toggle
|
2020-06-14 15:11:35 +00:00
|
|
|
|
2020-06-09 20:41:11 +00:00
|
|
|
" Toggles all gutter items
|
|
|
|
nnoremap <silent> <leader>N :call ToggleGutter()<CR>
|
|
|
|
|
|
|
|
function! ToggleGutter() abort
|
|
|
|
if &number
|
|
|
|
exec "set nonumber norelativenumber signcolumn=no"
|
|
|
|
else
|
|
|
|
exec "set number relativenumber"
|
2021-08-08 19:22:07 +00:00
|
|
|
try | set signcolumn=auto | catch | set signcolumn=yes:1 | endtry
|
2020-06-09 20:41:11 +00:00
|
|
|
endif
|
|
|
|
endfunction
|
2019-10-18 12:56:42 +00:00
|
|
|
|
2020-08-03 15:56:05 +00:00
|
|
|
" Buffer movement
|
|
|
|
nnoremap <silent> <TAB> :call BufferJump("bnext")<CR>
|
|
|
|
nnoremap <silent> <S-TAB> :call BufferJump("bprevious")<CR>
|
|
|
|
nnoremap <silent> <leader><TAB> :call ListBuffers()<CR>
|
|
|
|
|
|
|
|
function BufferJump(command)
|
|
|
|
let start_buffer = bufnr('%')
|
|
|
|
execute a:command
|
|
|
|
while &buftype ==# 'quickfix' && bufnr('%') != start_buffer
|
|
|
|
execute a:command
|
|
|
|
endwhile
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function ListBuffers()
|
|
|
|
try
|
|
|
|
Buffers
|
|
|
|
catch
|
|
|
|
buffers<CR>b<space>
|
|
|
|
endtry
|
|
|
|
endfunction
|
|
|
|
|
2020-06-14 15:11:35 +00:00
|
|
|
" Default colorscheme
|
2020-08-03 15:56:05 +00:00
|
|
|
set background=dark
|
2020-06-15 22:46:49 +00:00
|
|
|
let g:one_allow_italics=1
|
2020-07-16 13:40:42 +00:00
|
|
|
execute "colorscheme " . g:my_color_scheme
|
|
|
|
highlight Comment term=italic cterm=italic gui=italic
|
2020-06-14 15:11:35 +00:00
|
|
|
|
2020-05-01 13:04:55 +00:00
|
|
|
set exrc
|
|
|
|
set secure
|
2018-06-14 13:58:34 +00:00
|
|
|
set modeline
|
|
|
|
set modelines=7
|
|
|
|
|
2020-06-14 16:04:12 +00:00
|
|
|
call SourceIfExists(g:rc_files['late'])
|
2017-12-13 13:08:26 +00:00
|
|
|
" vim: ts=8 sw=2 si
|