mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 08:20:06 +08:00
Add omni for sh file
This commit is contained in:
parent
cce3c9608f
commit
dd36d3beff
@ -4,7 +4,12 @@ let s:completer = fnamemodify(g:Config_Main_Home, ':p:h:h') . '/autoload/SpaceVi
|
|||||||
|
|
||||||
" this is for vim command completion
|
" 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
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ function! SpaceVim#autocmds#init() abort
|
|||||||
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
|
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
|
||||||
autocmd Filetype html setlocal omnifunc=htmlcomplete#CompleteTags
|
autocmd Filetype html setlocal omnifunc=htmlcomplete#CompleteTags
|
||||||
autocmd FileType html,markdown 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 call XmlFileTypeInit()
|
||||||
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
|
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
|
||||||
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
|
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
|
||||||
|
@ -1,10 +1,30 @@
|
|||||||
|
|
||||||
let s:BASH_COMPLETE = SpaceVim#api#import('bash#complete')
|
let s:BASH_COMPLETE = SpaceVim#api#import('bash#complete')
|
||||||
|
|
||||||
|
" complete input
|
||||||
|
|
||||||
function! SpaceVim#plugins#bashcomplete#complete(ArgLead, CmdLine, CursorPos)
|
function! SpaceVim#plugins#bashcomplete#complete(ArgLead, CmdLine, CursorPos)
|
||||||
return s:BASH_COMPLETE.complete_input(a:ArgLead, a:CmdLine, a:CursorPos)
|
return s:BASH_COMPLETE.complete_input(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
endfunction
|
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()
|
function! SpaceVim#plugins#bashcomplete#test()
|
||||||
|
|
||||||
call input('shell:', '', 'customlist,SpaceVim#plugins#bashcomplete#complete')
|
call input('shell:', '', 'customlist,SpaceVim#plugins#bashcomplete#complete')
|
||||||
|
@ -27,6 +27,9 @@ else
|
|||||||
call deoplete#custom#set('omni', 'rank', 9999)
|
call deoplete#custom#set('omni', 'rank', 9999)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" sh
|
||||||
|
let g:deoplete#ignore_sources.sh = get(g:deoplete#ignore_sources, 'sh', ['around', 'member', 'tag', 'syntax'])
|
||||||
|
|
||||||
" go
|
" go
|
||||||
let g:deoplete#ignore_sources.go = get(g:deoplete#ignore_sources, 'go', ['omni'])
|
let g:deoplete#ignore_sources.go = get(g:deoplete#ignore_sources, 'go', ['omni'])
|
||||||
call deoplete#custom#set('go', 'mark', '')
|
call deoplete#custom#set('go', 'mark', '')
|
||||||
|
Loading…
Reference in New Issue
Block a user