337 lines
8.7 KiB
VimL
337 lines
8.7 KiB
VimL
" Plugins
|
|
call plug#begin('~/.vim/plugged')
|
|
|
|
" Startify
|
|
Plug 'mhinz/vim-startify'
|
|
|
|
" Theme
|
|
Plug 'kyoz/purify', { 'rtp': 'vim' }
|
|
Plug 'joshdick/onedark.vim'
|
|
|
|
" Surround
|
|
Plug 'tpope/vim-surround'
|
|
|
|
" Lightline
|
|
Plug 'itchyny/lightline.vim'
|
|
Plug 'mengelbrecht/lightline-bufferline'
|
|
|
|
" Distraction-free
|
|
Plug 'junegunn/goyo.vim'
|
|
|
|
" Syntax
|
|
Plug 'sheerun/vim-polyglot'
|
|
Plug 'kevinoid/vim-jsonc'
|
|
|
|
" Color highlight
|
|
Plug 'ap/vim-css-color'
|
|
|
|
" Symlink
|
|
Plug 'aymericbeaumet/vim-symlink'
|
|
|
|
" Code completion
|
|
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
|
|
"Plug 'phpactor/phpactor', { 'for': 'php', 'branch': 'master', 'do': 'composer install --no-dev -o' }
|
|
|
|
" ALE
|
|
Plug 'dense-analysis/ale'
|
|
|
|
" Emmet
|
|
Plug 'mattn/emmet-vim'
|
|
|
|
" Debugging
|
|
Plug 'puremourning/vimspector'
|
|
|
|
" Git
|
|
Plug 'tpope/vim-fugitive'
|
|
Plug 'airblade/vim-gitgutter'
|
|
|
|
" Obsession
|
|
Plug 'tpope/vim-obsession'
|
|
|
|
" NERDTree
|
|
Plug 'preservim/nerdtree'
|
|
Plug 'Xuyuanp/nerdtree-git-plugin'
|
|
|
|
" VimDevIcons
|
|
Plug 'ryanoasis/vim-devicons'
|
|
|
|
" Snippets
|
|
Plug 'SirVer/ultisnips'
|
|
Plug 'honza/vim-snippets'
|
|
|
|
" FZF
|
|
Plug 'junegunn/fzf'
|
|
Plug 'junegunn/fzf.vim'
|
|
|
|
" Bufonly
|
|
Plug 'schickling/vim-bufonly'
|
|
|
|
" Lastplace
|
|
Plug 'farmergreg/vim-lastplace'
|
|
|
|
call plug#end()
|
|
|
|
syntax on
|
|
|
|
colorscheme onedark
|
|
|
|
set nocompatible
|
|
|
|
" .exrc
|
|
set exrc
|
|
set secure
|
|
|
|
" Mouse
|
|
set mouse=a
|
|
if !has('nvim')
|
|
set ttymouse=sgr
|
|
endif
|
|
|
|
" .vimrc
|
|
nnoremap <M-e> :e ~/.vimrc<CR>
|
|
nnoremap <M-r> :so ~/.vimrc<CR>
|
|
|
|
" Indentation
|
|
filetype plugin indent on
|
|
set expandtab
|
|
set tabstop=4
|
|
set shiftwidth=4
|
|
set autoindent
|
|
set smartindent
|
|
|
|
" Search
|
|
set hlsearch
|
|
|
|
" FZF
|
|
nnoremap <leader>fa :Ag<CR>
|
|
nnoremap <leader>fb :Buffers<CR>
|
|
nnoremap <leader>fc :Commands<CR>
|
|
nnoremap <leader>fg :GitFiles<CR>
|
|
nnoremap <leader>fhc :History:<CR>
|
|
nnoremap <leader>fhs :History/<CR>
|
|
nnoremap <leader>ff :Files<CR>
|
|
nnoremap <leader>fr :Rg<CR>
|
|
nnoremap <leader>fm :Maps<CR>
|
|
|
|
" Startify
|
|
let g:startify_custom_header = ''
|
|
let g:startify_session_persistence = 1
|
|
let g:startify_session_sort = 1
|
|
let g:startify_change_to_vcs_root = 1
|
|
let g:startify_lists = [
|
|
\ { 'type': 'sessions', 'header': [' Sessions'] },
|
|
\ { 'type': 'files', 'header': [' MRU'] },
|
|
\ { 'type': 'dir', 'header': [' MRU '. getcwd()] },
|
|
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
|
|
\ { 'type': 'commands', 'header': [' Commands'] },
|
|
\ ]
|
|
|
|
" Lightline
|
|
set laststatus=2
|
|
set cmdheight=2
|
|
set showtabline=2
|
|
|
|
let g:lightline = {
|
|
\ 'colorscheme': 'wombat',
|
|
\ 'active': {
|
|
\ 'left': [ [ 'mode', 'paste' ],
|
|
\ [ 'cocstatus', 'readonly', 'filename', 'modified', 'gitbranch'] ]
|
|
\ },
|
|
\ 'tabline': {
|
|
\ 'left': [ ['buffers'] ]
|
|
\ },
|
|
\ 'component_expand': {
|
|
\ 'buffers': 'lightline#bufferline#buffers'
|
|
\ },
|
|
\ 'component_function': {
|
|
\ 'cocstatus': 'coc#status',
|
|
\ 'gitbranch': 'FugitiveHead'
|
|
\ },
|
|
\ 'component_type': {
|
|
\ 'buffers': 'tabsel'
|
|
\ }
|
|
\ }
|
|
|
|
let g:lightline#bufferline#show_number = 1
|
|
let g:lightline#bufferline#enable_devicons = 1
|
|
let g:lightline#bufferline#clickable = 1024
|
|
let g:lightline.component_raw = {'buffers': 1}
|
|
|
|
" Buffers
|
|
nnoremap <leader>b :ls<CR>:b<Space>
|
|
nnoremap <leader>cb :BufOnly<CR>
|
|
|
|
" Distraction-free
|
|
nnoremap <leader>g :Goyo<CR>
|
|
|
|
" Line numbers
|
|
set number
|
|
set relativenumber
|
|
|
|
" Undo
|
|
set undofile
|
|
set undodir=~/.vim/undo
|
|
set undolevels=1024
|
|
|
|
" Backup
|
|
set nobackup
|
|
set nowritebackup
|
|
|
|
" updatetime
|
|
set updatetime=450
|
|
|
|
" ALE
|
|
let g:ale_disable_lsp = 1
|
|
|
|
" Debugging
|
|
let g:vimspector_enable_mappings = 'HUMAN'
|
|
nmap <Leader>di <Plug>VimspectorBalloonEval
|
|
xmap <Leader>di <Plug>VimspectorBalloonEval
|
|
nmap <Leader>dr :VimspectorReset<CR>
|
|
|
|
" Tabs
|
|
nnoremap <C-Left> :tabprevious<CR>
|
|
nnoremap <C-Right> :tabnext<CR>
|
|
nnoremap <C-j> :tabprevious<CR>
|
|
nnoremap <C-k> :tabnext<CR>
|
|
|
|
" Clipboard
|
|
vmap <Leader-C> "+y
|
|
|
|
" NERDTree
|
|
autocmd StdinReadPre * let s:std_in=1
|
|
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
|
|
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
|
|
|
let g:NERTreeChDirMode = 2
|
|
|
|
map <C-n> :NERDTreeToggle<CR>
|
|
nnoremap <C-m> :NERDTreeFind<CR>
|
|
|
|
" Code completion
|
|
set hidden
|
|
set shortmess+=c
|
|
set signcolumn=yes
|
|
|
|
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
|
|
|
|
if has('nvim')
|
|
inoremap <silent><expr> <c-space> coc#refresh()
|
|
else
|
|
inoremap <silent><expr> <c-@> coc#refresh()
|
|
endif
|
|
|
|
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
|
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
|
|
|
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
|
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
|
|
|
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)
|
|
|
|
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
|
|
|
function! s:show_documentation()
|
|
if (index(['vim','help'], &filetype) >= 0)
|
|
execute 'h '.expand('<cword>')
|
|
elseif (coc#rpc#ready())
|
|
call CocActionAsync('doHover')
|
|
else
|
|
execute '!' . &keywordprg . " " . expand('<cword>')
|
|
endif
|
|
endfunction
|
|
|
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|
|
|
|
nmap <leader>rn <Plug>(coc-rename)
|
|
xmap <leader>f <Plug>(coc-format-selected)
|
|
nmap <leader>f <Plug>(coc-format-selected)
|
|
xmap <leader>a <Plug>(coc-codeaction-selected)
|
|
nmap <leader>a <Plug>(coc-codeaction-selected)
|
|
nmap <leader>ac <Plug>(coc-codeaction)
|
|
nmap <leader>qf <Plug>(coc-fix-current)
|
|
|
|
xmap if <Plug>(coc-funcobj-i)
|
|
omap if <Plug>(coc-funcobj-i)
|
|
xmap af <Plug>(coc-funcobj-a)
|
|
omap af <Plug>(coc-funcobj-a)
|
|
xmap ic <Plug>(coc-classobj-i)
|
|
omap ic <Plug>(coc-classobj-i)
|
|
xmap ac <Plug>(coc-classobj-a)
|
|
omap ac <Plug>(coc-classobj-a)
|
|
|
|
if has('nvim-0.4.0') || has('patch-8.2.0750')
|
|
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
|
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
|
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
|
|
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
|
|
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
|
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
|
endif
|
|
|
|
if has('nvim')
|
|
vnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#nvim_scroll(1, 1) : "\<C-f>"
|
|
vnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#nvim_scroll(0, 1) : "\<C-b>"
|
|
endif
|
|
|
|
nmap <silent> <C-s> <Plug>(coc-range-select)
|
|
xmap <silent> <C-s> <Plug>(coc-range-select)
|
|
|
|
command! -nargs=0 Format :call CocAction('format')
|
|
command! -nargs=? Fold :call CocAction('fold', <f-args>)
|
|
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
|
|
|
|
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
|
|
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
|
|
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
|
|
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
|
|
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
|
|
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
|
|
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
|
|
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
|
|
|
|
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
|
|
|
|
" 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>'
|