More style cleanup; added docstrings
This commit is contained in:
parent
9695633b21
commit
e9c00a746b
@ -1448,6 +1448,7 @@ Contributors listed in chronological order:
|
|||||||
Bernhard Vallant (lazerscience)
|
Bernhard Vallant (lazerscience)
|
||||||
Von Welch (von)
|
Von Welch (von)
|
||||||
Nikola Petrov (nikolavp)
|
Nikola Petrov (nikolavp)
|
||||||
|
Brian Mock (saikobee)
|
||||||
|
|
||||||
Thank you for your support.
|
Thank you for your support.
|
||||||
|
|
||||||
|
@ -17,43 +17,42 @@ from UltiSnips.util import IndentUtil
|
|||||||
import UltiSnips._vim as _vim
|
import UltiSnips._vim as _vim
|
||||||
|
|
||||||
def _plugin_dir():
|
def _plugin_dir():
|
||||||
|
""" Calculates the plugin directory for UltiSnips. This depends on the
|
||||||
|
current file being 3 levels deep from the plugin directory, so it needs to
|
||||||
|
be updated if the code moves.
|
||||||
|
"""
|
||||||
d = __file__
|
d = __file__
|
||||||
for i in xrange(3):
|
for i in xrange(3):
|
||||||
d = os.path.dirname(d)
|
d = os.path.dirname(d)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _snippets_dir_is_before_plugin_dir():
|
def _snippets_dir_is_before_plugin_dir():
|
||||||
def no_slash(path):
|
""" Returns True if the snippets directory comes before the plugin
|
||||||
path_dir, path_base = os.path.split(path)
|
directory in Vim's runtime path. False otherwise.
|
||||||
|
"""
|
||||||
if path_base == "":
|
|
||||||
return path_dir
|
|
||||||
else:
|
|
||||||
return path
|
|
||||||
|
|
||||||
paths = [ no_slash(os.path.expanduser(p))
|
|
||||||
for p in _vim.eval("&runtimepath").split(',') ]
|
|
||||||
|
|
||||||
home = _vim.eval("$HOME")
|
|
||||||
|
|
||||||
def vim_path_index(suffix):
|
def vim_path_index(suffix):
|
||||||
path = no_slash(os.path.join(home, suffix))
|
path = os.path.join(home, suffix).rstrip(os.path.sep)
|
||||||
try:
|
try:
|
||||||
return paths.index(path)
|
return paths.index(path)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return -1
|
return -1
|
||||||
|
paths = [ os.path.expanduser(p).rstrip(os.path.sep)
|
||||||
|
for p in _vim.eval("&runtimepath").split(',') ]
|
||||||
|
home = _vim.eval("$HOME")
|
||||||
try:
|
try:
|
||||||
vim_dir_index = max(vim_path_index(".vim"), vim_path_index("vimfiles"))
|
real_vim_path_index = max(vim_path_index(".vim"), vim_path_index("vimfiles"))
|
||||||
return paths.index(_plugin_dir()) < vim_dir_index
|
return paths.index(_plugin_dir()) < real_vim_path_index
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _should_reverse_search_path():
|
def _should_reverse_search_path():
|
||||||
|
""" If the user defined g:UltiSnipsDontReverseSearchPath then return True
|
||||||
|
or False based on the value of that variable, else defer to
|
||||||
|
_snippets_dir_is_before_plugin_dir to determine whether this is True or
|
||||||
|
False.
|
||||||
|
"""
|
||||||
if _vim.eval("exists('g:UltiSnipsDontReverseSearchPath')") != "0":
|
if _vim.eval("exists('g:UltiSnipsDontReverseSearchPath')") != "0":
|
||||||
return _vim.eval("g:UltiSnipsDontReverseSearchPath") != "0"
|
return _vim.eval("g:UltiSnipsDontReverseSearchPath") != "0"
|
||||||
|
|
||||||
return not _snippets_dir_is_before_plugin_dir()
|
return not _snippets_dir_is_before_plugin_dir()
|
||||||
|
|
||||||
def err_to_scratch_buffer(f):
|
def err_to_scratch_buffer(f):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user