mirror of
https://github.com/gryf/snipmate.vim.git
synced 2025-12-23 14:42:31 +01:00
added a cleaner fix for supertab
This commit is contained in:
@@ -119,17 +119,21 @@ fun! GetSnippets(dir)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fun! TriggerSnippet()
|
fun! TriggerSnippet()
|
||||||
|
if exists('g:SuperTabMappingForward')
|
||||||
|
if g:SuperTabMappingForward == "<tab>"
|
||||||
|
let g:SuperTabKey = "\<c-n>"
|
||||||
|
elseif g:SuperTabMappingBackward == "<tab>"
|
||||||
|
let g:SuperTabKey = '\<c-p>'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
if pumvisible() " Update snippet if completion is used, or deal with supertab
|
if pumvisible() " Update snippet if completion is used, or deal with supertab
|
||||||
if exists('s:sid')
|
if exists('g:SuperTabKey')
|
||||||
return exists('b:complType') ? b:complType : "\<c-n>"
|
call feedkeys(g:SuperTabKey) | return ''
|
||||||
endif
|
endif
|
||||||
call feedkeys("\<esc>a", 'n') " Close completion menu
|
call feedkeys("\<esc>a", 'n') " Close completion menu
|
||||||
call feedkeys("\<tab>") | return ''
|
call feedkeys("\<tab>") | return ''
|
||||||
endif
|
endif
|
||||||
if !exists('s:sid') && exists('g:SuperTabMappingForward')
|
|
||||||
\ && g:SuperTabMappingForward == "<tab>"
|
|
||||||
call s:GetSuperTabSID()
|
|
||||||
endif
|
|
||||||
|
|
||||||
if exists('g:snipPos') | return snipMate#jumpTabStop() | endif
|
if exists('g:snipPos') | return snipMate#jumpTabStop() | endif
|
||||||
|
|
||||||
@@ -148,14 +152,7 @@ fun! TriggerSnippet()
|
|||||||
sil exe 's/'.escape(trigger, '.^$/\*[]').'\%#//'
|
sil exe 's/'.escape(trigger, '.^$/\*[]').'\%#//'
|
||||||
return snipMate#expandSnip(col)
|
return snipMate#expandSnip(col)
|
||||||
endif
|
endif
|
||||||
return exists('s:sid') ? {s:sid}_SuperTab('n') : "\<tab>"
|
return exists('g:SuperTabKey') ? g:SuperTabKey : "\<tab>"
|
||||||
endf
|
|
||||||
|
|
||||||
fun s:GetSuperTabSID()
|
|
||||||
let old = @a
|
|
||||||
redir @a | sil exe 'fun /SuperTab$' | redir END
|
|
||||||
let s:sid = matchstr(@a, '<SNR>\d\+\ze_SuperTab(command)')
|
|
||||||
let @a = old
|
|
||||||
endf
|
endf
|
||||||
|
|
||||||
" Check if word under cursor is snippet trigger; if it isn't, try checking if
|
" Check if word under cursor is snippet trigger; if it isn't, try checking if
|
||||||
|
|||||||
Reference in New Issue
Block a user