1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 20:30:05 +08:00

Add omni for sh file

This commit is contained in:
wsdjeg 2017-10-31 23:39:01 +08:00
parent cce3c9608f
commit dd36d3beff
4 changed files with 30 additions and 1 deletions

View File

@ -4,7 +4,12 @@ let s:completer = fnamemodify(g:Config_Main_Home, ':p:h:h') . '/autoload/SpaceVi
" this is for vim command completion
function! s:self.comeplete(Leader, CmdLine, CursorPos) abort
function! s:self.complete(ArgLead, CmdLine, CursorPos) abort
if a:CmdLine =~ '^[^ ]*$'
return systemlist('compgen -c ' . a:CmdLine)
endif
let result = systemlist([s:completer, a:CmdLine])
return map(result, 'substitute(v:val, "[ ]*$", "", "g")')
endfunction

View File

@ -46,6 +46,7 @@ function! SpaceVim#autocmds#init() abort
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd Filetype html setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType sh setlocal omnifunc=SpaceVim#plugins#bashcomplete#omnicomplete
autocmd FileType xml call XmlFileTypeInit()
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS

View File

@ -1,10 +1,30 @@
let s:BASH_COMPLETE = SpaceVim#api#import('bash#complete')
" complete input
function! SpaceVim#plugins#bashcomplete#complete(ArgLead, CmdLine, CursorPos)
return s:BASH_COMPLETE.complete_input(a:ArgLead, a:CmdLine, a:CursorPos)
endfunction
" bash omni
function! SpaceVim#plugins#bashcomplete#omnicomplete(findstart, base)
if a:findstart
let str = getline('.')[:col('.') - 2]
let pos = len(substitute(str, '[^ ]*$', '' , 'g'))
return pos
else
let str = getline('.')[:col('.') - 1] . a:base
return s:BASH_COMPLETE.complete(a:base, str, col('.'))
endif
endfunction
function! SpaceVim#plugins#bashcomplete#test()
call input('shell:', '', 'customlist,SpaceVim#plugins#bashcomplete#complete')

View File

@ -27,6 +27,9 @@ else
call deoplete#custom#set('omni', 'rank', 9999)
endif
" sh
let g:deoplete#ignore_sources.sh = get(g:deoplete#ignore_sources, 'sh', ['around', 'member', 'tag', 'syntax'])
" go
let g:deoplete#ignore_sources.go = get(g:deoplete#ignore_sources, 'go', ['omni'])
call deoplete#custom#set('go', 'mark', '')