1
0
mirror of https://github.com/gryf/snipmate.vim.git synced 2025-12-23 22:52:27 +01:00

added a cleaner fix for supertab

This commit is contained in:
Michael Sanders
2009-03-26 00:21:04 -04:00
parent 80add0f93b
commit 238e937500

View File

@@ -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