From b47e686521355121e41143d9eaa871aaffe35083 Mon Sep 17 00:00:00 2001 From: Stanislav Seletskiy Date: Sat, 6 Dec 2014 23:43:46 +0600 Subject: [PATCH] do not walk &rtp if abs path to snips specified --- doc/UltiSnips.txt | 16 ++++++++++++++++ .../UltiSnips/snippet/source/file/ultisnips.py | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index 83023cd..5a886be 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -193,6 +193,13 @@ g:UltiSnipsSnippetsDir directories named "snippets" are reserved for snipMate snippets and cannot be used. + *g:UltiSnipsSnippetDirectories* +g:UltiSnipsSnippetDirectories + Defines the directories for looking for snippets. + Do not mix up this variable with previous one. + More information about that variable can + be found at section |UltiSnips-snippet-search-path|. + *g:UltiSnipsEnableSnipMate* g:UltiSnipsEnableSnipMate Enable looking for SnipMate snippets in @@ -350,6 +357,15 @@ over the global variable. |UltiSnips-adding-snippets| explains which files are parsed for a given filetype. +If only one directory is specified in this variable and this directory is +specified by absolute path, UltiSnips will not look for snippets in +&runtimepath, which can lead to significant speedup. So, the common case is: + + let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/UltiSnips'] + +However, you will not able to use snippets that are shipped with third party +plugins out of the box. You'll need to copy them into your chosen directory. + 3.4 Warning About Select Mode Mappings *UltiSnips-warning-smappings* -------------------------------------- diff --git a/pythonx/UltiSnips/snippet/source/file/ultisnips.py b/pythonx/UltiSnips/snippet/source/file/ultisnips.py index c05d041..d503c84 100644 --- a/pythonx/UltiSnips/snippet/source/file/ultisnips.py +++ b/pythonx/UltiSnips/snippet/source/file/ultisnips.py @@ -32,10 +32,13 @@ def find_all_snippet_files(ft): snippet_dirs = _vim.eval('b:UltiSnipsSnippetDirectories') else: snippet_dirs = _vim.eval('g:UltiSnipsSnippetDirectories') - + if len(snippet_dirs) == 1 and os.path.isabs(snippet_dirs[0]): + check_dirs = [''] + else: + check_dirs = _vim.eval('&runtimepath').split(',') patterns = ['%s.snippets', '%s_*.snippets', os.path.join('%s', '*')] ret = set() - for rtp in _vim.eval('&runtimepath').split(','): + for rtp in check_dirs: for snippet_dir in snippet_dirs: if snippet_dir == 'snippets': raise RuntimeError(