diff --git a/autoload/SpaceVim/api/bash/complete.vim b/autoload/SpaceVim/api/bash/complete.vim index 0f761ad87..f40225413 100644 --- a/autoload/SpaceVim/api/bash/complete.vim +++ b/autoload/SpaceVim/api/bash/complete.vim @@ -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 diff --git a/autoload/SpaceVim/autocmds.vim b/autoload/SpaceVim/autocmds.vim index 596871d05..0a242f114 100644 --- a/autoload/SpaceVim/autocmds.vim +++ b/autoload/SpaceVim/autocmds.vim @@ -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 diff --git a/autoload/SpaceVim/plugins/bashcomplete.vim b/autoload/SpaceVim/plugins/bashcomplete.vim index 8a98429ce..40d8f0d27 100644 --- a/autoload/SpaceVim/plugins/bashcomplete.vim +++ b/autoload/SpaceVim/plugins/bashcomplete.vim @@ -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') diff --git a/config/plugins/deoplete.vim b/config/plugins/deoplete.vim index d1ebc572c..9da643390 100644 --- a/config/plugins/deoplete.vim +++ b/config/plugins/deoplete.vim @@ -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', '')