From 3b2eb436b70af5ae0b61a258655291ded7cca60e Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Wed, 19 Jun 2013 08:00:52 +0200 Subject: [PATCH] Buffer local overwrite for snippet directory. Patch by jszakmeister. --- doc/UltiSnips.txt | 5 +++++ plugin/UltiSnips/__init__.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index 5922a1f..5797fcd 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -331,6 +331,10 @@ If you do not want to use the snippets that come with UltiSnips, define the variable accordingly. > let g:UltiSnipsSnippetDirectories=["mycoolsnippets"] +You can also redefine the search path on a buffer by buffer basis by setting +the variable b:UltiSnipsSnippetDirectories. This variable takes precedence +over the global variable. + UltiSnips searches in 'runtimepath' for snippet directories but traverses 'runtimepath' in reverse order (last item first). If you would like to have UltiSnips traverse 'runtimepath' in the standard order, add this to your vimrc @@ -1363,6 +1367,7 @@ Contributors listed in chronological order: David Briscoe - DavidBriscoe Keith Welch - paralogiki Zhao Cai - zhaocai + John Szakmeister - jszakmeister 8.2 Snippets *UltiSnips-contrisnippets* diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index badc125..2a10f19 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -937,7 +937,10 @@ class SnippetManager(object): the filetype. """ - snippet_dirs = _vim.eval("g:UltiSnipsSnippetDirectories") + if _vim.eval("exists('b:UltiSnipsSnippetDirectories')") == "1": + snippet_dirs = _vim.eval("b:UltiSnipsSnippetDirectories") + else: + snippet_dirs = _vim.eval("g:UltiSnipsSnippetDirectories") base_snippets = os.path.realpath(os.path.join(__file__, "../../../UltiSnips")) ret = []