diff --git a/files/vim/.vim/vimrc b/files/vim/.vim/vimrc index 6241b97..a079408 100644 --- a/files/vim/.vim/vimrc +++ b/files/vim/.vim/vimrc @@ -185,6 +185,51 @@ nnoremap obs :OpenBrowserSearch nmap gx (openbrowser-smart-search) vmap gx (openbrowser-smart-search) +"ale +nnoremap at :ALEToggle +nmap af (ale_fix) +nmap aK (ale_hover) +nmap an (ale_next_wrap) +nmap ap (ale_previous_wrap) + +"lsp +function! s:on_lsp_buffer_enabled() abort + setlocal omnifunc=lsp#complete + setlocal signcolumn=yes + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap gd (lsp-definition) + nmap gs (lsp-document-symbol-search) + nmap gS (lsp-workspace-symbol-search) + nmap gr (lsp-references) + nmap gi (lsp-implementation) + nmap gt (lsp-type-definition) + nmap [g (lsp-previous-diagnostic) + nmap ]g (lsp-next-diagnostic) + nmap gp (lsp-previous-diagnostic) + nmap gn (lsp-next-diagnostic) + nmap K (lsp-hover) + + nmap pdf (lsp-peek-definition) + nmap pdc (lsp-peek-declaration) + nmap pdi (lsp-peek-implementation) + nmap ca (lsp-code-action) + nmap cl (lsp-code-lens) + nmap rn (lsp-rename) + nmap ls (lsp-status) + nmap lt (lsp-stop-server) + nmap di (lsp-document-diagnostics) + nmap df (lsp-document-format) + + inoremap lsp#scroll(+4) + inoremap lsp#scroll(-4) + + " highlight lspReference ctermfg=red guifg=red ctermbg=green guibg=green + + " refer to doc to add more commands + " https://github.com/prabirshrestha/vim-lsp#supported-commands +endfunction + + "vim-emmet let g:user_emmet_leader_key = '' @@ -194,12 +239,12 @@ nnoremap ggt :GitGutterToggle "vim-fugitive nnoremap gw :Gwrite nnoremap gl :Glog -nnoremap g :Git +nnoremap gs :Git nnoremap gd :Gdiffsplit nnoremap gp :Gpush nnoremap ga :Git add % nnoremap ga. :Git add . -nnoremap gcm :Git commit +nnoremap gc :Git commit "fzf nnoremap gf :GitFiles @@ -272,6 +317,7 @@ call plug#begin(pluginDir) " ==== general language support ==== "linting and lsp + Plug 'dense-analysis/ale' Plug 'prabirshrestha/vim-lsp' Plug 'mattn/vim-lsp-settings' @@ -293,46 +339,37 @@ let g:netrw_browsex_viewer = "xdg-open" let g:NetrwIsOpen = 0 "for toggle function let g:netrw_nogx = 1 +"ale +let g:ale_linters = { +\ 'python': ['flake8', 'pylint'], +\ 'javascript': ['eslint'], +\ 'ruby': ['rubocop'], +\ 'markdown': ['mdl', 'write-good'] +\} + +let g:ale_fixers = { +\ '*': ['remove_trailing_lines', 'trim_whitespace'], +\ 'python': ['yapf', 'black'], +\ 'javascript': ['prettier', 'eslint'], +\ 'ruby': ['rubocop'], +\ 'css': ['prettier'], +\ 'scss': ['prettier'], +\ 'html': ['prettier'], +\ 'markdown': ['prettier'] +\} + +let g:ale_sign_error = '->' +let g:ale_sign_warning = '--' +let g:ale_lint_on_save = 1 +let g:ale_fix_on_save_ignore = 1 +highlight clear SignColumn + "vim-lsp -function! s:on_lsp_buffer_enabled() abort - setlocal omnifunc=lsp#complete - setlocal signcolumn=yes - if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif - nmap gd (lsp-definition) - nmap gs (lsp-document-symbol-search) - nmap gS (lsp-workspace-symbol-search) - nmap gr (lsp-references) - nmap gi (lsp-implementation) - nmap gt (lsp-type-definition) - nmap [g (lsp-previous-diagnostic) - nmap ]g (lsp-next-diagnostic) - nmap gp (lsp-previous-diagnostic) - nmap gn (lsp-next-diagnostic) - nmap K (lsp-hover) +let g:lsp_format_sync_timeout = 1000 +let g:lsp_diagnostics_enabled = 0 +let g:lsp_document_highlight_enabled = 0 - nmap pdf (lsp-peek-definition) - nmap pdc (lsp-peek-declaration) - nmap pdi (lsp-peek-implementation) - nmap ca (lsp-code-action) - nmap cl (lsp-code-lens) - nmap r (lsp-rename) - nmap s (lsp-status) - nmap di (lsp-document-diagnostics) - nmap df (lsp-document-format) - - inoremap lsp#scroll(+4) - inoremap lsp#scroll(-4) - - let g:lsp_format_sync_timeout = 1000 - " let g:lsp_document_highlight_enabled = 0 - " let g:lsp_diagnostics_enabled = 0 - " highlight lspReference ctermfg=red guifg=red ctermbg=green guibg=green - - " refer to doc to add more commands - " https://github.com/prabirshrestha/vim-lsp#supported-commands -endfunction - -"lsp-settings configs +"vim-lsp-settings specific configs " let g:lsp_settings = { " \ 'pyls-all': { " \ 'workspace_config': { @@ -345,7 +382,6 @@ endfunction " let g:lsp_settings_filetype_python = ['pyls-all', 'pyright-langserver', 'jedi-language-server'] - "vim-markdown let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_toc_autofit = 1 @@ -452,7 +488,7 @@ if has("autocmd") endfunction function FT_markdown() - " setlocal spell + setlocal spell endfunction function FT_halftab() @@ -513,7 +549,7 @@ endif " colorscheme 1989 " colorscheme PaperColor " colorscheme gruvbox -colorscheme jellybeans +" colorscheme jellybeans " colorscheme molokai " colorscheme Benokai " colorscheme Monokai