feature/docs-improvement-of-is-expandable-func (#975)

To deal with space characters.
This commit is contained in:
Viacheslav Lotsmanov 2018-05-01 01:01:36 +05:00 committed by UltiBot
parent 30e651fb1f
commit 6fdc3647f7

View File

@ -1790,13 +1790,26 @@ with your plugin so it can be listed in the docs.
6. FAQ *UltiSnips-FAQ*
Q: Do I have to call UltiSnips#ExpandSnippet() to check if a snippet is
expandable ? Is there instead an analog of neosnippet#expandable ?
expandable? Is there instead an analog of neosnippet#expandable?
A: Yes there is, try
function UltiSnips#IsExpandable()
return !empty(UltiSnips#SnippetsInCurrentScope())
endfunction
Consider that UltiSnips#SnippetsInCurrentScope() will return all the
snippets you have if you call it after a space character. If you want
UltiSnips#IsExpandable() to return false when you call it after a space
character use this a bit more complicated implementation:
function UltiSnips#IsExpandable()
return !(
\ col('.') <= 1
\ || !empty(matchstr(getline('.'), '\%' . (col('.') - 1) . 'c\s'))
\ || empty(UltiSnips#SnippetsInCurrentScope())
\ )
endfunction
=============================================================================
7. Helping Out *UltiSnips-helping*