add all param to UltiSnips#SnippetsInCurrentScope

This commit is contained in:
chemzqm 2015-12-28 20:01:26 +08:00
parent dbd43ad27c
commit 6a69a44154
2 changed files with 22 additions and 4 deletions

View File

@ -89,9 +89,13 @@ function! UltiSnips#ListSnippets()
return ""
endfunction
function! UltiSnips#SnippetsInCurrentScope()
function! UltiSnips#SnippetsInCurrentScope(...)
let g:current_ulti_dict = {}
exec g:_uspy "UltiSnips_Manager.snippets_in_current_scope()"
let all = get(a:, 1, 0)
if all
let g:current_ulti_dict_all = {}
endif
exec g:_uspy "UltiSnips_Manager.snippets_in_current_scope(" . all . ")"
return g:current_ulti_dict
endfunction

View File

@ -185,10 +185,10 @@ class SnippetManager(object):
self._handle_failure(self.expand_trigger)
@err_to_scratch_buffer
def snippets_in_current_scope(self):
def snippets_in_current_scope(self, searchAll):
"""Returns the snippets that could be expanded to Vim as a global
variable."""
before = _vim.buf.line_till_cursor
before = '' if searchAll else _vim.buf.line_till_cursor
snippets = self._snips(before, True)
# Sort snippets alphabetically
@ -197,6 +197,8 @@ class SnippetManager(object):
description = snip.description[snip.description.find(snip.trigger) +
len(snip.trigger) + 2:]
location = snip.location if snip.location else ''
key = as_unicode(snip.trigger)
description = as_unicode(description)
@ -211,6 +213,18 @@ class SnippetManager(object):
key=key.replace("'", "''"),
val=description.replace("'", "''")))
if searchAll:
_vim.command(as_unicode(
("let g:current_ulti_dict_all['{key}'] = {{"
"'description': '{description}',"
"'location': '{location}',"
"}}")).format(
key=key.replace("'", "''"),
location=location.replace("'", "''"),
description=description.replace("'", "''")))
@err_to_scratch_buffer
def list_snippets(self):
"""Shows the snippets that could be expanded to the User and let her