Move go fmt on safe to ale config

Also move Ale config to a dedicated file
This commit is contained in:
ViViDboarder 2021-04-30 11:27:39 -07:00
parent 2b60626ed3
commit 4e49d8b2d1
3 changed files with 42 additions and 34 deletions

View File

@ -1 +1,2 @@
let g:argwrap_tail_comma = 1 let g:argwrap_tail_comma = 1
let g:ale_fix_on_save = 1

View File

@ -69,40 +69,7 @@ let g:dash_map = { 'apex' : 'apex', 'visualforce' : 'vf' }
" Lint and completion " Lint and completion
if (g:vim_as_an_ide && !g:gui.has_linter_features) && (has('nvim') || v:version >= 800) if (g:vim_as_an_ide && !g:gui.has_linter_features) && (has('nvim') || v:version >= 800)
" Install ALE call s:smart_source_rc('plugins/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 <F4> :ALEFix<CR>
" Enable autocomplete from ale and asyncomplete " Enable autocomplete from ale and asyncomplete
if !g:gui.has_autocomplete_features if !g:gui.has_autocomplete_features
@ -144,6 +111,8 @@ end
" Custom go " Custom go
let g:go_def_mapping_enabled = 0 let g:go_def_mapping_enabled = 0
let g:go_version_warning = 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' } Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
" Custom rust " Custom rust
let g:rustfmt_autosave = 1 let g:rustfmt_autosave = 1

38
vim/rc/plugins/ale.rc.vim Normal file
View File

@ -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 <F4> :ALEFix<CR>