From debef2b1a7a0940c43cd4454d4e1691affcec0cb Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Tue, 10 Apr 2018 23:26:12 +0200 Subject: [PATCH] Remove long unused .bzrignore. (#968) --- .bzrignore | 2 -- .../UltiSnips/snippet/source/file/snipmate.py | 4 +-- .../snippet/source/file/ulti_snips.py | 32 ++++++++++++------- 3 files changed, 23 insertions(+), 15 deletions(-) delete mode 100644 .bzrignore diff --git a/.bzrignore b/.bzrignore deleted file mode 100644 index a64bfd0..0000000 --- a/.bzrignore +++ /dev/null @@ -1,2 +0,0 @@ -doc/tags -.bzr-repo diff --git a/pythonx/UltiSnips/snippet/source/file/snipmate.py b/pythonx/UltiSnips/snippet/source/file/snipmate.py index 1791243..f6b15e3 100644 --- a/pythonx/UltiSnips/snippet/source/file/snipmate.py +++ b/pythonx/UltiSnips/snippet/source/file/snipmate.py @@ -32,7 +32,7 @@ def _splitall(path): return allparts -def snipmate_files_for(ft): +def _snipmate_files_for(ft): """Returns all snipMate files we need to look at for 'ft'.""" if ft == 'all': ft = '_' @@ -116,7 +116,7 @@ class SnipMateFileSource(SnippetFileSource): """Manages all snipMate snippet definitions found in rtp.""" def _get_all_snippet_files_for(self, ft): - return snipmate_files_for(ft) + return _snipmate_files_for(ft) def _parse_snippet_file(self, filedata, filename): if filename.lower().endswith('snippet'): diff --git a/pythonx/UltiSnips/snippet/source/file/ulti_snips.py b/pythonx/UltiSnips/snippet/source/file/ulti_snips.py index fb66dab..63013ef 100644 --- a/pythonx/UltiSnips/snippet/source/file/ulti_snips.py +++ b/pythonx/UltiSnips/snippet/source/file/ulti_snips.py @@ -25,20 +25,19 @@ def find_snippet_files(ft, directory): ret.add(os.path.realpath(fn)) return ret +def _find_all_snippet_directories(): + """Returns a list of the absolute path of all snippet directories to + search.""" -def find_all_snippet_files(ft): - """Returns all snippet files matching 'ft' in the given runtime path - directory.""" if _vim.eval("exists('b:UltiSnipsSnippetDirectories')") == '1': 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() + return snippet_dirs + + all_dirs = [] + check_dirs = _vim.eval('&runtimepath').split(',') for rtp in check_dirs: for snippet_dir in snippet_dirs: if snippet_dir == 'snippets': @@ -48,9 +47,20 @@ def find_all_snippet_files(ft): 'directory for UltiSnips snippets.') pth = os.path.realpath(os.path.expanduser( os.path.join(rtp, snippet_dir))) - for pattern in patterns: - for fn in glob.glob(os.path.join(pth, pattern % ft)): - ret.add(fn) + if os.path.isdir(pth): + all_dirs.append(pth) + return all_dirs + + +def find_all_snippet_files(ft): + """Returns all snippet files matching 'ft' in the given runtime path + directory.""" + patterns = ['%s.snippets', '%s_*.snippets', os.path.join('%s', '*')] + ret = set() + for directory in _find_all_snippet_directories(): + for pattern in patterns: + for fn in glob.glob(os.path.join(directory, pattern % ft)): + ret.add(fn) return ret