|
@@ -1,5 +1,3 @@
|
|
|
-" Run the following git commands to get the plugins
|
|
|
|
|
-
|
|
|
|
|
" Plugin manager
|
|
" Plugin manager
|
|
|
if empty(glob('~/.vim/autoload/plug.vim'))
|
|
if empty(glob('~/.vim/autoload/plug.vim'))
|
|
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
|
@@ -7,11 +5,6 @@ if empty(glob('~/.vim/autoload/plug.vim'))
|
|
|
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
|
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
|
|
endif
|
|
endif
|
|
|
|
|
|
|
|
-" Pre-plugin calls
|
|
|
|
|
-let g:ale_completion_enabled = 1
|
|
|
|
|
-let g:ale_hover_to_floating_preview = 1
|
|
|
|
|
-let g:ale_floating_preview = 1
|
|
|
|
|
-
|
|
|
|
|
" Plugins
|
|
" Plugins
|
|
|
call plug#begin('~/.vim/plugged')
|
|
call plug#begin('~/.vim/plugged')
|
|
|
Plug 'preservim/nerdtree'
|
|
Plug 'preservim/nerdtree'
|
|
@@ -30,6 +23,8 @@ Plug 'junegunn/fzf.vim'
|
|
|
Plug 'airblade/vim-gitgutter'
|
|
Plug 'airblade/vim-gitgutter'
|
|
|
Plug 'mxw/vim-jsx'
|
|
Plug 'mxw/vim-jsx'
|
|
|
Plug 'pangloss/vim-javascript'
|
|
Plug 'pangloss/vim-javascript'
|
|
|
|
|
+Plug 'natebosch/vim-lsc'
|
|
|
|
|
+Plug 'tpope/vim-surround'
|
|
|
call plug#end()
|
|
call plug#end()
|
|
|
|
|
|
|
|
filetype plugin indent on
|
|
filetype plugin indent on
|
|
@@ -38,7 +33,7 @@ syntax on
|
|
|
set autoindent
|
|
set autoindent
|
|
|
set backspace=2
|
|
set backspace=2
|
|
|
set background=dark
|
|
set background=dark
|
|
|
-set completeopt=menu,popup
|
|
|
|
|
|
|
+set completeopt=menu,popup,noselect
|
|
|
set cursorcolumn
|
|
set cursorcolumn
|
|
|
set cursorline
|
|
set cursorline
|
|
|
set expandtab
|
|
set expandtab
|
|
@@ -59,101 +54,81 @@ set showmatch
|
|
|
set smartindent
|
|
set smartindent
|
|
|
set smarttab
|
|
set smarttab
|
|
|
set splitright
|
|
set splitright
|
|
|
|
|
+set switchbuf+=usetab,newtab
|
|
|
set termguicolors
|
|
set termguicolors
|
|
|
set tabstop=2
|
|
set tabstop=2
|
|
|
set whichwrap+=<,>,[,],h,l
|
|
set whichwrap+=<,>,[,],h,l
|
|
|
set undofile
|
|
set undofile
|
|
|
set undodir=~/.vim/undo
|
|
set undodir=~/.vim/undo
|
|
|
|
|
|
|
|
-" ALE
|
|
|
|
|
-" ALE linters
|
|
|
|
|
-let g:ale_use_global_executables = 1
|
|
|
|
|
-let g:ale_linters_explicit = 1
|
|
|
|
|
-let g:ale_linters = {}
|
|
|
|
|
-let g:ale_linters.javascript = [ 'eslint', 'tsserver' ]
|
|
|
|
|
-let g:ale_linters.php = [ 'intelephense', 'phpcs' ]
|
|
|
|
|
-
|
|
|
|
|
-let g:ale_phpcs_standard = "PSR2"
|
|
|
|
|
-
|
|
|
|
|
-" ALE fixers
|
|
|
|
|
-let g:ale_fixers = {}
|
|
|
|
|
-let g:ale_fixers.javascript = [ 'prettier', 'eslint' ]
|
|
|
|
|
-
|
|
|
|
|
-" ALE completion
|
|
|
|
|
-let g:ale_completion_autoimport = 1
|
|
|
|
|
-set omnifunc=ale#completion#OmniFunc
|
|
|
|
|
-
|
|
|
|
|
-" ALE messages
|
|
|
|
|
-let g:ale_echo_msg_error_str = 'E'
|
|
|
|
|
-let g:ale_echo_msg_warning_str = 'W'
|
|
|
|
|
-let g:ale_echo_msg_format = '[%linter%] %s'
|
|
|
|
|
-
|
|
|
|
|
-" Ale keymaps
|
|
|
|
|
-nnoremap <C-a>g :ALEGoToDefinition -tab<CR>
|
|
|
|
|
-nnoremap <C-a>G :ALEGoToDefinition<CR>
|
|
|
|
|
-nnoremap <C-a>h :ALEHover<CR>
|
|
|
|
|
-nnoremap <C-a>f :ALEFindReferences<CR>
|
|
|
|
|
-
|
|
|
|
|
-" ALE navigation
|
|
|
|
|
-nmap <silent> <C-k> <Plug>(ale_previous_wrap)
|
|
|
|
|
-nmap <silent> <C-j> <Plug>(ale_next_wrap)
|
|
|
|
|
-let g:material_theme_style = 'darker'
|
|
|
|
|
-let g:material_terminal_italics = 1
|
|
|
|
|
-colorscheme material
|
|
|
|
|
|
|
+" Colorscheme
|
|
|
|
|
+colorscheme minimalist
|
|
|
|
|
+highlight Comment cterm=italic
|
|
|
|
|
|
|
|
" Lightline
|
|
" Lightline
|
|
|
set laststatus=2
|
|
set laststatus=2
|
|
|
set noshowmode
|
|
set noshowmode
|
|
|
let g:lightline = {
|
|
let g:lightline = {
|
|
|
- \ 'colorscheme': 'material_vim',
|
|
|
|
|
- \ 'separator': { 'left': '', 'right': '' },
|
|
|
|
|
|
|
+ \ 'colorscheme': 'minimalist',
|
|
|
|
|
+ \ 'tabline_subseparator': { 'left': '', 'right': '' },
|
|
|
\ 'active': {
|
|
\ 'active': {
|
|
|
\ 'left': [
|
|
\ 'left': [
|
|
|
\ [ 'mode', 'paste' ],
|
|
\ [ 'mode', 'paste' ],
|
|
|
- \ [ 'gitbranch', 'readonly', 'filename', 'tagbar', 'modified' ]
|
|
|
|
|
|
|
+ \ [ 'filestate' ],
|
|
|
|
|
+ \ [ 'gitbranch', 'tagbar' ],
|
|
|
\ ],
|
|
\ ],
|
|
|
\ 'right': [
|
|
\ 'right': [
|
|
|
- \ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ],
|
|
|
|
|
- \ [ 'percent', 'lineinfo', 'offset' ],
|
|
|
|
|
- \ [ 'fileformat', 'fileencoding', 'filetype' ]
|
|
|
|
|
|
|
+ \ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ],
|
|
|
|
|
+ \ [ 'fileformat', 'fileencoding', 'filetype', 'percent', 'lineinfo', 'offset' ],
|
|
|
\ ]
|
|
\ ]
|
|
|
\ },
|
|
\ },
|
|
|
|
|
+ \ 'tabline': {
|
|
|
|
|
+ \ 'left': [ [ 'tabs' ] ],
|
|
|
|
|
+ \ 'right': [ ],
|
|
|
|
|
+ \ },
|
|
|
\ 'component': {
|
|
\ 'component': {
|
|
|
\ 'tagbar': '%{tagbar#currenttag("%s", "", "f", "nearest-stl")}',
|
|
\ 'tagbar': '%{tagbar#currenttag("%s", "", "f", "nearest-stl")}',
|
|
|
\ },
|
|
\ },
|
|
|
\ 'component_function': {
|
|
\ 'component_function': {
|
|
|
- \ 'gitbranch': 'FugitiveHead',
|
|
|
|
|
- \ 'offset': 'FileOffset'
|
|
|
|
|
|
|
+ \ 'filestate': 'LightlineFileState',
|
|
|
|
|
+ \ 'offset': 'LightlineFileOffset',
|
|
|
\ },
|
|
\ },
|
|
|
\ 'component_expand': {
|
|
\ 'component_expand': {
|
|
|
|
|
+ \ 'gitbranch': 'FugitiveHead',
|
|
|
\ 'linter_checking': 'lightline#ale#checking',
|
|
\ 'linter_checking': 'lightline#ale#checking',
|
|
|
\ 'linter_infos': 'lightline#ale#infos',
|
|
\ 'linter_infos': 'lightline#ale#infos',
|
|
|
\ 'linter_warnings': 'lightline#ale#warnings',
|
|
\ 'linter_warnings': 'lightline#ale#warnings',
|
|
|
\ 'linter_errors': 'lightline#ale#errors',
|
|
\ 'linter_errors': 'lightline#ale#errors',
|
|
|
- \ 'linter_ok': 'lightline#ale#ok'
|
|
|
|
|
|
|
+ \ 'linter_ok': 'lightline#ale#ok',
|
|
|
\ },
|
|
\ },
|
|
|
\ 'component_type': {
|
|
\ 'component_type': {
|
|
|
- \ 'linter_checking': 'right',
|
|
|
|
|
- \ 'linter_infos': 'right',
|
|
|
|
|
\ 'linter_warnings': 'warning',
|
|
\ 'linter_warnings': 'warning',
|
|
|
\ 'linter_errors': 'error',
|
|
\ 'linter_errors': 'error',
|
|
|
- \ 'linter_ok': 'right'
|
|
|
|
|
|
|
+ \ 'linter_ok': 'ok',
|
|
|
|
|
+ \ 'linter_infos': 'info',
|
|
|
\ }
|
|
\ }
|
|
|
\ }
|
|
\ }
|
|
|
|
|
|
|
|
-function! FileOffset()
|
|
|
|
|
|
|
+" Lightline helper (concatenate readonly state, filename and modified state)
|
|
|
|
|
+function! LightlineFileState()
|
|
|
|
|
+ if @% == "" | return "[No name]" | endif
|
|
|
|
|
+ let s = expand('%:t')
|
|
|
|
|
+ if &modified | let s = s . "+" | endif
|
|
|
|
|
+ if &readonly | let s = "[RO] " . s | endif
|
|
|
|
|
+ return s
|
|
|
|
|
+endfunction
|
|
|
|
|
+
|
|
|
|
|
+" Lightline helper (get cursor line and character position in file)
|
|
|
|
|
+function! LightlineFileOffset()
|
|
|
return line2byte(line('.')) + col('.') - 1
|
|
return line2byte(line('.')) + col('.') - 1
|
|
|
endfunction
|
|
endfunction
|
|
|
|
|
|
|
|
" NERDtree
|
|
" NERDtree
|
|
|
-" Close NERDTree on opening file
|
|
|
|
|
let NERDTreeQuitOnOpen=1
|
|
let NERDTreeQuitOnOpen=1
|
|
|
-" Show hidden files
|
|
|
|
|
let NERDTreeShowHidden=1
|
|
let NERDTreeShowHidden=1
|
|
|
|
|
|
|
|
|
|
+" NERDTree helper (toggle in current buffer)
|
|
|
function! NERDTreeToggleCustom()
|
|
function! NERDTreeToggleCustom()
|
|
|
-
|
|
|
|
|
- " If NERDTree is open in the current buffer
|
|
|
|
|
if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1)
|
|
if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1)
|
|
|
exe ":NERDTreeClose"
|
|
exe ":NERDTreeClose"
|
|
|
elseif bufname('%') != ""
|
|
elseif bufname('%') != ""
|
|
@@ -161,16 +136,52 @@ function! NERDTreeToggleCustom()
|
|
|
else
|
|
else
|
|
|
exe ":NERDTreeCWD"
|
|
exe ":NERDTreeCWD"
|
|
|
endif
|
|
endif
|
|
|
-
|
|
|
|
|
endfunction
|
|
endfunction
|
|
|
|
|
|
|
|
-" Toggle NERDTree on <space>-o
|
|
|
|
|
|
|
+" NERDTREE Toggle NERDTree on <space>-o
|
|
|
map <Space>o :call NERDTreeToggleCustom()<CR>
|
|
map <Space>o :call NERDTreeToggleCustom()<CR>
|
|
|
|
|
|
|
|
|
|
+" ALE Configuration
|
|
|
|
|
+let g:ale_completion_enabled = 0
|
|
|
|
|
+let g:ale_sign_column_always = 1
|
|
|
|
|
+let g:ale_set_signs = 1
|
|
|
|
|
+let g:ale_set_highlights = 0
|
|
|
|
|
+let g:ale_disable_lsp = 1
|
|
|
|
|
+
|
|
|
|
|
+" ALE linters
|
|
|
|
|
+let g:ale_use_global_executables = 1
|
|
|
|
|
+let g:ale_linters_explicit = 1
|
|
|
|
|
+let g:ale_linters = {}
|
|
|
|
|
+let g:ale_linters.javascript = [ 'eslint' ]
|
|
|
|
|
+let g:ale_linters.php = [ 'intelephense', 'phpcs' ]
|
|
|
|
|
+let g:ale_linters.go = [ 'gopls', 'gofmt', 'gobuild' ]
|
|
|
|
|
+
|
|
|
|
|
+let g:ale_phpcs_standard = "PSR2"
|
|
|
|
|
+
|
|
|
|
|
+" ALE fixers
|
|
|
|
|
+let g:ale_fixers = { '*': [ 'remove_trailing_lines', 'trim_whitespace' ] }
|
|
|
|
|
+let g:ale_fixers.javascript = [ 'prettier', 'eslint' ]
|
|
|
|
|
+let g:ale_fixers.go = [ 'gofmt' ]
|
|
|
|
|
+
|
|
|
|
|
+" ALE message should include responsible linter
|
|
|
|
|
+let g:ale_echo_msg_format = '[%linter%] %s'
|
|
|
|
|
+
|
|
|
|
|
+" Ale keymaps
|
|
|
|
|
+nnoremap <C-a>l :ALELint<CR>
|
|
|
|
|
+nnoremap <C-a>f :ALEFix<CR>
|
|
|
|
|
+nnoremap <C-a>i :ALEInfo<CR>
|
|
|
|
|
+
|
|
|
|
|
+" ALE styling
|
|
|
|
|
+highlight ALEErrorSign ctermbg=237 ctermfg=167
|
|
|
|
|
+highlight ALEWarningSign ctermbg=237 ctermfg=215
|
|
|
|
|
+highlight ALEInfoign ctermbg=237 ctermfg=117
|
|
|
|
|
+" ALE Configuration end
|
|
|
|
|
+
|
|
|
" Tagbar
|
|
" Tagbar
|
|
|
let g:tagbar_autoclose = 1
|
|
let g:tagbar_autoclose = 1
|
|
|
let g:tagbar_autofocus = 1
|
|
let g:tagbar_autofocus = 1
|
|
|
let g:tagbar_map_showproto = ''
|
|
let g:tagbar_map_showproto = ''
|
|
|
|
|
+nmap <Space>t :TagbarToggle<CR>
|
|
|
|
|
|
|
|
" Toggle transparent background
|
|
" Toggle transparent background
|
|
|
let g:is_transparent = 0
|
|
let g:is_transparent = 0
|
|
@@ -186,13 +197,13 @@ function! Toggle_transparent()
|
|
|
endfunction
|
|
endfunction
|
|
|
nnoremap <Space>T :call Toggle_transparent()<CR>
|
|
nnoremap <Space>T :call Toggle_transparent()<CR>
|
|
|
|
|
|
|
|
-" Location list
|
|
|
|
|
-autocmd BufEnter * if !exists("b:location_list") | let b:location_list = 0 | endif
|
|
|
|
|
-let b:location_list = 0
|
|
|
|
|
|
|
+" Location list toggle
|
|
|
function! Toggle_location_list()
|
|
function! Toggle_location_list()
|
|
|
- if b:location_list == 0
|
|
|
|
|
- lopen
|
|
|
|
|
- let b:location_list = 1
|
|
|
|
|
|
|
+ if get(b:, 'location_list', 0) == 0
|
|
|
|
|
+ silent! lopen
|
|
|
|
|
+ if get(getloclist(0, { 'winid': 0 }), 'winid')
|
|
|
|
|
+ let b:location_list = 1
|
|
|
|
|
+ endif
|
|
|
else
|
|
else
|
|
|
lclose
|
|
lclose
|
|
|
let b:location_list = 0
|
|
let b:location_list = 0
|
|
@@ -200,13 +211,13 @@ function! Toggle_location_list()
|
|
|
endfunction
|
|
endfunction
|
|
|
nnoremap <Space>l :call Toggle_location_list()<CR>
|
|
nnoremap <Space>l :call Toggle_location_list()<CR>
|
|
|
|
|
|
|
|
-" Location list
|
|
|
|
|
-autocmd BufEnter * if !exists("b:quick_list") | let b:quick_list = 0 | endif
|
|
|
|
|
-let b:quick_list = 0
|
|
|
|
|
|
|
+" Quickfix list toggle
|
|
|
function! Toggle_quick_list()
|
|
function! Toggle_quick_list()
|
|
|
- if b:quick_list == 0
|
|
|
|
|
- copen
|
|
|
|
|
- let b:quick_list = 1
|
|
|
|
|
|
|
+ if get(b:, 'quick_list', 0) == 0
|
|
|
|
|
+ silent! copen
|
|
|
|
|
+ if get(getqfist(0, { 'winid': 0 }), 'winid')
|
|
|
|
|
+ let b:quick_list = 1
|
|
|
|
|
+ endif
|
|
|
else
|
|
else
|
|
|
cclose
|
|
cclose
|
|
|
let b:quick_list = 0
|
|
let b:quick_list = 0
|
|
@@ -218,7 +229,7 @@ nnoremap <Space>c :call Toggle_quick_list()<CR>
|
|
|
autocmd BufEnter * if !exists("b:git_blame") | let b:git_blame = 0 | endif
|
|
autocmd BufEnter * if !exists("b:git_blame") | let b:git_blame = 0 | endif
|
|
|
function! Toggle_git_blame()
|
|
function! Toggle_git_blame()
|
|
|
if b:git_blame == 0
|
|
if b:git_blame == 0
|
|
|
- :Git blame
|
|
|
|
|
|
|
+ :silent! Git blame
|
|
|
let b:git_blame = 1
|
|
let b:git_blame = 1
|
|
|
else
|
|
else
|
|
|
let winIndex = 1
|
|
let winIndex = 1
|
|
@@ -233,19 +244,14 @@ function! Toggle_git_blame()
|
|
|
endwhile
|
|
endwhile
|
|
|
let b:git_blame = 0
|
|
let b:git_blame = 0
|
|
|
endif
|
|
endif
|
|
|
-
|
|
|
|
|
endfunction
|
|
endfunction
|
|
|
nnoremap <Space>b :call Toggle_git_blame()<CR>
|
|
nnoremap <Space>b :call Toggle_git_blame()<CR>
|
|
|
|
|
|
|
|
-" Key mappings
|
|
|
|
|
-map <C-l>n :cnext<CR>
|
|
|
|
|
-map <C-l>p :cprevious<CR>
|
|
|
|
|
-nnoremap <C-l>c :cclose<CR>
|
|
|
|
|
-
|
|
|
|
|
-nmap <Space>t :TagbarToggle<CR>
|
|
|
|
|
|
|
+" Fuzzy search
|
|
|
nmap <Space>f :Files<CR>
|
|
nmap <Space>f :Files<CR>
|
|
|
-nmap <Space>r :Rg<CR>
|
|
|
|
|
|
|
+nmap <Space>s :Rg<CR>
|
|
|
|
|
|
|
|
|
|
+" Git gutter
|
|
|
nmap <Space>n :GitGutterNextHunk<CR>
|
|
nmap <Space>n :GitGutterNextHunk<CR>
|
|
|
nmap <Space>p :GitGutterPrevHunk<CR>
|
|
nmap <Space>p :GitGutterPrevHunk<CR>
|
|
|
|
|
|
|
@@ -260,21 +266,46 @@ function UpdateTmuxWindow()
|
|
|
call system("tmux rename-window '" . title . "'")
|
|
call system("tmux rename-window '" . title . "'")
|
|
|
endfunction
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
+" Format XML pretty
|
|
|
function! PrettyXML()
|
|
function! PrettyXML()
|
|
|
set filetype=xml
|
|
set filetype=xml
|
|
|
silent %!xmllint --format --encode UTF-8 --recover - 2>/dev/null
|
|
silent %!xmllint --format --encode UTF-8 --recover - 2>/dev/null
|
|
|
endfunction
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
+" Format json pretty
|
|
|
function! PrettyJSON()
|
|
function! PrettyJSON()
|
|
|
set filetype=json
|
|
set filetype=json
|
|
|
silent %!python3 -m json.tool
|
|
silent %!python3 -m json.tool
|
|
|
endfunction
|
|
endfunction
|
|
|
|
|
|
|
|
-command! PrettyXml call PrettyXML()
|
|
|
|
|
-command! PrettyJson call PrettyJSON()
|
|
|
|
|
-
|
|
|
|
|
nmap <Space>x :call PrettyXML()<CR>
|
|
nmap <Space>x :call PrettyXML()<CR>
|
|
|
nmap <Space>j :call PrettyJSON()<CR>
|
|
nmap <Space>j :call PrettyJSON()<CR>
|
|
|
|
|
|
|
|
" Disable bad default keybindings
|
|
" Disable bad default keybindings
|
|
|
inoremap <C-w> <Nop>
|
|
inoremap <C-w> <Nop>
|
|
|
|
|
+
|
|
|
|
|
+" LSP configuration
|
|
|
|
|
+let g:lsc_enable_diagnostics = v:false
|
|
|
|
|
+let g:lsc_auto_map = v:true
|
|
|
|
|
+let g:lsc_autocomplete_length=1
|
|
|
|
|
+set omnifunc=lsc#complete#complete
|
|
|
|
|
+
|
|
|
|
|
+" LSP keymappings
|
|
|
|
|
+nnoremap <C-l>f :LSClientFindReferences<CR>
|
|
|
|
|
+nnoremap <C-l>g :tab LSClientGoToDefinitionSplit<CR>
|
|
|
|
|
+nnoremap <C-l>G :LSClientGoToDefinition<CR>
|
|
|
|
|
+nnoremap <C-l>h :LSClientShowHover<CR>
|
|
|
|
|
+
|
|
|
|
|
+" LSP servers
|
|
|
|
|
+let g:lsc_server_commands = {}
|
|
|
|
|
+let g:lsc_server_commands = {
|
|
|
|
|
+ \ 'javascript': { 'command': 'typescript-language-server --stdio', 'log_level': -1, 'suppress_stderr': v:true },
|
|
|
|
|
+ \ 'javascript.jsx': { 'command': 'typescript-language-server --stdio', 'log_level': -1, 'suppress_stderr': v:true },
|
|
|
|
|
+ \ 'go': { 'command': 'gopls serve', 'log_level': -1, 'suppress_stderr': v:true },
|
|
|
|
|
+ \ 'php': { 'command': 'intelephense --stdio', 'message_hooks': {'initialize': { 'initializationOptions': {'storagePath': '/tmp/intelephense'} } } },
|
|
|
|
|
+ \}
|
|
|
|
|
+
|
|
|
|
|
+" LSP close preview after selecting completion
|
|
|
|
|
+autocmd CompleteDone * silent! pclose
|
|
|
|
|
+" LSP close quickfix list after selection
|
|
|
|
|
+autocmd BufLeave * cclose
|