1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-04 02:40:04 +08:00
SpaceVim/autoload/SpaceVim/plugins/bashcomplete.vim
Wang Shidong 3ccd4e4680
update file head (#1407)
* update file head

Update file head

* Update file head

* Update file head
2018-02-19 22:07:04 +08:00

51 lines
1.3 KiB
VimL

"=============================================================================
" bashcomplete.vim --- bash complete for SpaceVim
" Copyright (c) 2016-2017 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
let s:BASH_COMPLETE = SpaceVim#api#import('bash#complete')
if !exists('g:bashcomplete_debug')
let g:bashcomplete_debug = 0
endif
" 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
"
let s:pos = 0
let s:str = ''
let s:base = ''
function! SpaceVim#plugins#bashcomplete#omnicomplete(findstart, base) abort
if a:findstart
let str = getline('.')[:col('.') - 2]
let s:str = substitute(str, '[^ ]*$', '' , 'g')
let s:pos = len(s:str)
if g:bashcomplete_debug
echom 'pos is ' . s:pos
endif
let s:base = str[s:pos :]
return s:pos
else
if g:bashcomplete_debug
echom 's:base is : "' . s:base . '" ' . 'cmdline is "' . s:str . s:base . '"'
endif
return s:BASH_COMPLETE.complete(a:base, s:str . s:base, col('.'))
endif
endfunction