WIP: Switch to ALE with a few LS setup

This commit is contained in:
ViViDboarder 2019-10-24 12:40:10 -07:00
parent 2b6b13fcda
commit 6a51d76881
5 changed files with 119 additions and 26 deletions

47
install-language-servers.sh Executable file
View File

@ -0,0 +1,47 @@
#! /bin/bash
## Language servers
# bash
npm install -g bash-language-server
# Kotlin
# https://github.com/fwcd/kotlin-language-server/blob/master/BUILDING.md
# Python
pip install --user python-language-server
pip3 install --user python-language-server
# Rust
rustup component add rls rust-analysis rust-src
## Linters
# Python
pip install flake8 mypy
# CSS
npm install -g csslint
# Vim
pip install --user vim-vint
pip3 install --user vim-vint
# YAML
pip install --user yamllint
pip3 install --user yamllint
# Makefile
# https://github.com/mrtazz/checkmake
## Fixers
# CSS/JS/HTML/JSON/YAML/Markdown/and more!
npm install -g prettier
# Python
pip install --user black autopep8 reorder-python-imports
pip3 install --user black autopep8 reorder-python-imports
# Rust
rustup component add rustfmt

View File

@ -34,9 +34,16 @@ cmap cd. lcd %:p:h
" Bind Make to F5 like other IDEs
nnoremap <F5> :make<CR>
" Remap Ctrl+Space for auto Complete
inoremap <C-Space> <C-n>
inoremap <Nul> <C-n>
" Ctrl-Space for omnicompletions
inoremap <silent><expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
\ "\<lt>C-n>" :
\ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
\ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
\ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
imap <C-@> <C-Space>
augroup close_docs
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
augroup end
" Toggle highlighting with \hr (highlight row)
nnoremap <leader>hr :set cursorline!<CR>

View File

@ -33,36 +33,79 @@ endif
" }} Searching
" Programming {{
Plug 'FooSoft/vim-argwrap'
" TODO: Maybe replace with coc.nvim. If I'm doing a lot of development, I will
" have latest versions of vim or nvim
" Only need one fallback, maybe neocomplcache
call s:smart_source_rc('plugins/omnicompletion')
if !g:vim_as_an_ide || g:gui.has_autocomplete_features
" We'll keep Oni's autocomplete with Language Server
elseif (has('nvim') || v:version >= 800) && has('python3')
call s:smart_source_rc('plugins/deoplete')
else
call s:smart_source_rc('plugins/neocomplcache')
Plug 'tomtom/tcomment_vim', { 'on': ['TComment', 'TCommentBlock'] }
nnoremap // :TComment<CR>
vnoremap // :TCommentBlock<CR>
" Install ALE
if !g:vim_as_an_ide || g:gui.has_linter_features
" We'll keep skip adding any of these features
elseif has('nvim') || v:version >= 800
Plug 'dense-analysis/ale'
set omnifunc=ale#completion#OmniFunc
let g:airline#extensions#ale#enabled = 1
let g:ale_lint_on_enter = 0
" TODO: Maybe move this to something per language
" TODO: Handle installing of language servers on setup (see ./install-language-servers.sh)
" NOTE: Some of these are installed when bootstrapping environment,
" outside of vim setup
let g:ale_linters = {
\ 'python': ['pyls', 'flake8', 'mypy', 'pylint'],
\ 'go': ['gopls', 'golint', 'gometalinter'],
\ 'rust': ['rls', 'cargo'],
\ 'sh': ['language_server', 'shell', 'shellcheck'],
\}
let g:ale_fixers = {
\ 'go': ['gofmt', 'goimports'],
\ 'rust': ['rustfmt'],
\}
" Auto-complete from ALE, possible alternative to asyncomplete
" let g:ale_completion_enabled = 1
" Enable asyncomplete
Plug 'prabirshrestha/asyncomplete.vim'
" Add ALE to asyncomplete
augroup acomp_setup
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#ale#get_source_options({
\ 'priority': 10,
\ }))
augroup end
" let g:asyncomplete_auto_popup = 0
" Make asyncomplete manually triggered
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~? '\s'
endfunction
inoremap <silent><expr> <C-Space>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ asyncomplete#force_refresh()
end
call s:smart_source_rc('plugins/tcomment_vim')
" TODO: Figure out if this is needed or if the ale completions are sufficient
" call s:smart_source_rc('plugins/omnicompletion')
if g:vim_as_an_ide && (v:version > 703) && !g:gui.has_ctags_features
call s:smart_source_rc('plugins/tagbar')
Plug 'ludovicchabant/vim-gutentags' " Auto generate tags files
command! TagsUpdate :GutentagsUpdate<CR>
command! TagsUpdate :GutentagsUpdate
end
" TODO: Maybe ALE. Similar reason as coc.nvim. Probably only using latest vim
" if developing seriously
if !g:vim_as_an_ide
" Do nothing
elseif (has('nvim') || v:version >= 800)
call s:smart_source_rc('plugins/neomake')
else
call s:smart_source_rc('plugins/syntastic')
endif
" if !g:vim_as_an_ide || g:ale_completion_enabled
" " Do nothing
" elseif (has('nvim') || v:version >= 800)
" call s:smart_source_rc('plugins/neomake')
" else
" call s:smart_source_rc('plugins/syntastic')
" endif
" }}
" GUI {{

View File

@ -1,4 +1,3 @@
Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' }
nnoremap <silent> <F8> :TagbarToggle<CR>
let g:tagbar_autofocus = 1 " Autofocus tagbar

View File

@ -1,3 +0,0 @@
Plug 'tomtom/tcomment_vim', { 'on': ['TComment', 'TCommentBlock'] }
nnoremap // :TComment<CR>
vnoremap // :TCommentBlock<CR>