diff --git a/vim/ftplugin/go.vim b/vim/ftplugin/go.vim index c6240f2..ea51ced 100644 --- a/vim/ftplugin/go.vim +++ b/vim/ftplugin/go.vim @@ -1 +1,2 @@ let g:argwrap_tail_comma = 1 +let g:ale_fix_on_save = 1 diff --git a/vim/rc/plugins.rc.vim b/vim/rc/plugins.rc.vim index ec07228..422033a 100644 --- a/vim/rc/plugins.rc.vim +++ b/vim/rc/plugins.rc.vim @@ -69,40 +69,7 @@ let g:dash_map = { 'apex' : 'apex', 'visualforce' : 'vf' } " Lint and completion if (g:vim_as_an_ide && !g:gui.has_linter_features) && (has('nvim') || v:version >= 800) - " Install ALE - Plug 'dense-analysis/ale' - let g:airline#extensions#ale#enabled = 1 - " Speed up first load time - let g:ale_lint_on_enter = 0 - - " NOTE: Some of these are installed when bootstrapping environment, outside of vim setup - let g:ale_linters = { - \ 'go': ['gopls', 'golint', 'golangci-lint'], - \ 'python': ['pyls', 'mypy'], - \ 'rust': ['rls', 'cargo'], - \ 'sh': ['language_server', 'shell', 'shellcheck'], - \ 'text': ['proselint', 'alex'], - \} - let g:ale_linter_aliases = { - \ 'markdown': ['text'], - \} - " More than a few languages use the same fixers - let s:ale_pretty_trim_fixer = ['prettier', 'trim_whitespace', 'remove_trailing_lines'] - let g:ale_fixers = { - \ '*': ['trim_whitespace', 'remove_trailing_lines'], - \ 'go': ['gofmt', 'goimports'], - \ 'json': s:ale_pretty_trim_fixer, - \ 'rust': ['rustfmt'], - \ 'python': [ 'black', 'autopep8', 'reorder-python-imports', 'remove_trailing_lines', 'trim_whitespace'], - \ 'markdown': s:ale_pretty_trim_fixer, - \ 'yaml': ['prettier', 'remove_trailing_lines'], - \ 'css': s:ale_pretty_trim_fixer, - \ 'javascript': s:ale_pretty_trim_fixer, - \} - let g:ale_python_flake8_options = '--max-line-length 80' - - " Create shortcut for ALEFix - nnoremap :ALEFix + call s:smart_source_rc('plugins/ale') " Enable autocomplete from ale and asyncomplete if !g:gui.has_autocomplete_features @@ -144,6 +111,8 @@ end " Custom go let g:go_def_mapping_enabled = 0 let g:go_version_warning = 0 +let g:go_fmt_autosave = 0 +let g:go_imports_autosave = 0 Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' } " Custom rust let g:rustfmt_autosave = 1 diff --git a/vim/rc/plugins/ale.rc.vim b/vim/rc/plugins/ale.rc.vim new file mode 100644 index 0000000..3ec604c --- /dev/null +++ b/vim/rc/plugins/ale.rc.vim @@ -0,0 +1,38 @@ +" Install ALE +Plug 'dense-analysis/ale' +let g:airline#extensions#ale#enabled = 1 +" Speed up first load time for quick editing +let g:ale_lint_on_enter = 0 + +" NOTE: Some of these are installed when bootstrapping environment, outside of vim setup +let g:ale_linters = { + \ 'go': ['gopls', 'golint', 'golangci-lint'], + \ 'python': ['pyls', 'mypy'], + \ 'rust': ['rls', 'cargo'], + \ 'sh': ['language_server', 'shell', 'shellcheck'], + \ 'text': ['proselint', 'alex'], + \} +let g:ale_linter_aliases = { + \ 'markdown': ['text'], + \} +" More than a few languages use the same fixers +let s:ale_pretty_trim_fixer = ['prettier', 'trim_whitespace', 'remove_trailing_lines'] +let g:ale_fixers = { + \ '*': ['trim_whitespace', 'remove_trailing_lines'], + \ 'go': ['gofmt', 'goimports'], + \ 'json': s:ale_pretty_trim_fixer, + \ 'rust': ['rustfmt'], + \ 'python': [ 'black', 'autopep8', 'reorder-python-imports', 'remove_trailing_lines', 'trim_whitespace'], + \ 'markdown': s:ale_pretty_trim_fixer, + \ 'yaml': ['prettier', 'remove_trailing_lines'], + \ 'css': s:ale_pretty_trim_fixer, + \ 'javascript': s:ale_pretty_trim_fixer, + \} + +" Language specific options +let g:ale_python_flake8_options = '--max-line-length 88' +let g:ale_go_golangci_lint_options = '' +let g:ale_go_golangci_lint_package = 1 + +" Create shortcut for ALEFix +nnoremap :ALEFix