Improve autocomplete a bit
Would still be good to add nvim native lsp
This commit is contained in:
parent
1d0cf22333
commit
90b505bb34
|
@ -35,12 +35,17 @@ cmap cd. lcd %:p:h
|
||||||
nnoremap <F5> :make<CR>
|
nnoremap <F5> :make<CR>
|
||||||
|
|
||||||
" Ctrl-Space for omnicompletions
|
" Ctrl-Space for omnicompletions
|
||||||
|
inoremap <C-Space> <C-n>
|
||||||
|
inoremap <Nul> <C-n>
|
||||||
inoremap <silent><expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
|
inoremap <silent><expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
|
||||||
\ "\<lt>C-n>" :
|
\ "\<lt>C-n>" :
|
||||||
\ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
|
\ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
|
||||||
\ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
|
\ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
|
||||||
\ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
|
\ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
|
||||||
imap <C-@> <C-Space>
|
imap <C-@> <C-Space>
|
||||||
|
|
||||||
|
" Enable preview window
|
||||||
|
set completeopt+=preview
|
||||||
augroup close_docs
|
augroup close_docs
|
||||||
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
|
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
|
||||||
augroup end
|
augroup end
|
||||||
|
|
|
@ -47,10 +47,11 @@ Plug 'tomtom/tcomment_vim', { 'on': ['TComment', 'TCommentBlock'] }
|
||||||
nnoremap // :TComment<CR>
|
nnoremap // :TComment<CR>
|
||||||
vnoremap // :TCommentBlock<CR>
|
vnoremap // :TCommentBlock<CR>
|
||||||
|
|
||||||
" Install ALE
|
" IDE stuff
|
||||||
if !g:vim_as_an_ide || g:gui.has_linter_features
|
|
||||||
" We'll keep skip adding any of these features
|
" Lint and completion
|
||||||
elseif has('nvim') || v:version >= 800
|
if (g:vim_as_an_ide && !g:gui.has_linter_features) && (has('nvim') || v:version >= 800)
|
||||||
|
" Install ALE
|
||||||
Plug 'dense-analysis/ale'
|
Plug 'dense-analysis/ale'
|
||||||
let g:airline#extensions#ale#enabled = 1
|
let g:airline#extensions#ale#enabled = 1
|
||||||
" Speed up first load time
|
" Speed up first load time
|
||||||
|
@ -70,9 +71,13 @@ elseif has('nvim') || v:version >= 800
|
||||||
" More than a few languages use the same fixers
|
" More than a few languages use the same fixers
|
||||||
let s:ale_pretty_trim_fixer = ['prettier', 'trim_whitespace', 'remove_trailing_lines']
|
let s:ale_pretty_trim_fixer = ['prettier', 'trim_whitespace', 'remove_trailing_lines']
|
||||||
let g:ale_fixers = {
|
let g:ale_fixers = {
|
||||||
|
\ '*': ['trim_whitespace', 'remove_trailing_lines'],
|
||||||
\ 'go': ['gofmt', 'goimports'],
|
\ 'go': ['gofmt', 'goimports'],
|
||||||
\ 'json': s:ale_pretty_trim_fixer,
|
\ 'json': s:ale_pretty_trim_fixer,
|
||||||
\ 'rust': ['rustfmt'],
|
\ 'rust': ['rustfmt'],
|
||||||
|
\ 'python': [
|
||||||
|
\ 'autopep8', 'reorder-python-imports',
|
||||||
|
\ 'remove_trailing_lines', 'trim_whitespace'],
|
||||||
\ 'markdown': s:ale_pretty_trim_fixer,
|
\ 'markdown': s:ale_pretty_trim_fixer,
|
||||||
\ 'yaml': ['prettier', 'remove_trailing_lines'],
|
\ 'yaml': ['prettier', 'remove_trailing_lines'],
|
||||||
\ 'css': s:ale_pretty_trim_fixer,
|
\ 'css': s:ale_pretty_trim_fixer,
|
||||||
|
@ -82,33 +87,34 @@ elseif has('nvim') || v:version >= 800
|
||||||
" Create shortcut for ALEFix
|
" Create shortcut for ALEFix
|
||||||
nnoremap <F4> :ALEFix<CR>
|
nnoremap <F4> :ALEFix<CR>
|
||||||
|
|
||||||
" Set ale completion as omni-func
|
" Enable autocomplete from ale and asyncomplete
|
||||||
set omnifunc=ale#completion#OmniFunc
|
if !g:gui.has_autocomplete_features
|
||||||
" Enable asyncomplete
|
set omnifunc=ale#completion#OmniFunc
|
||||||
Plug 'prabirshrestha/asyncomplete.vim'
|
" Set ale completion as omni-func
|
||||||
" Add ALE to asyncomplete
|
" Enable asyncomplete
|
||||||
augroup acomp_setup
|
Plug 'prabirshrestha/asyncomplete.vim'
|
||||||
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#ale#get_source_options({
|
" Add ALE to asyncomplete
|
||||||
\ 'priority': 10,
|
augroup acomp_setup
|
||||||
\ }))
|
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#ale#get_source_options({
|
||||||
augroup end
|
\ 'priority': 10,
|
||||||
|
\ }))
|
||||||
|
augroup end
|
||||||
|
|
||||||
" let g:asyncomplete_auto_popup = 0
|
let g:asyncomplete_auto_popup = 0
|
||||||
" Make asyncomplete manually triggered
|
" Make asyncomplete manually triggered
|
||||||
function! s:check_back_space() abort
|
function! s:check_back_space() abort
|
||||||
let col = col('.') - 1
|
let col = col('.') - 1
|
||||||
return !col || getline('.')[col - 1] =~? '\s'
|
return !col || getline('.')[col - 1] =~? '\s'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
inoremap <silent><expr> <C-Space>
|
inoremap <silent><expr> <C-Space>
|
||||||
\ pumvisible() ? "\<C-n>" :
|
\ pumvisible() ? "\<C-n>" :
|
||||||
\ <SID>check_back_space() ? "\<TAB>" :
|
\ <SID>check_back_space() ? "\<TAB>" :
|
||||||
\ asyncomplete#force_refresh()
|
\ asyncomplete#force_refresh()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
" TODO: Figure out if this is needed or if the ale completions are sufficient
|
" Programming Tag navigation
|
||||||
" call s:smart_source_rc('plugins/omnicompletion')
|
|
||||||
|
|
||||||
if g:vim_as_an_ide && (v:version > 703) && !g:gui.has_ctags_features
|
if g:vim_as_an_ide && (v:version > 703) && !g:gui.has_ctags_features
|
||||||
call s:smart_source_rc('plugins/tagbar')
|
call s:smart_source_rc('plugins/tagbar')
|
||||||
Plug 'ludovicchabant/vim-gutentags' " Auto generate tags files
|
Plug 'ludovicchabant/vim-gutentags' " Auto generate tags files
|
||||||
|
|
Loading…
Reference in New Issue