From 6fdc3647f72e0a1f321ea6bd092ecd01f7c187ba Mon Sep 17 00:00:00 2001 From: Viacheslav Lotsmanov Date: Tue, 1 May 2018 01:01:36 +0500 Subject: [PATCH] feature/docs-improvement-of-is-expandable-func (#975) To deal with space characters. --- doc/UltiSnips.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index 2070d5c..c9be9fa 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -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*