forked from VimPlug/jedi-vim
pep8 styling
This commit is contained in:
@@ -23,4 +23,3 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
vim.command('echoerr "Please install Jedi if you want to use jedi_vim."')
|
vim.command('echoerr "Please install Jedi if you want to use jedi_vim."')
|
||||||
sys.path.pop(1)
|
sys.path.pop(1)
|
||||||
|
|
||||||
|
|||||||
22
jedi_vim.py
22
jedi_vim.py
@@ -61,6 +61,7 @@ def echo_highlight(msg):
|
|||||||
class PythonToVimStr(unicode):
|
class PythonToVimStr(unicode):
|
||||||
""" Vim has a different string implementation of single quotes """
|
""" Vim has a different string implementation of single quotes """
|
||||||
__slots__ = []
|
__slots__ = []
|
||||||
|
|
||||||
def __new__(cls, obj, encoding='UTF-8'):
|
def __new__(cls, obj, encoding='UTF-8'):
|
||||||
if is_py3k or isinstance(obj, unicode):
|
if is_py3k or isinstance(obj, unicode):
|
||||||
return unicode.__new__(cls, obj)
|
return unicode.__new__(cls, obj)
|
||||||
@@ -81,8 +82,8 @@ class PythonToVimStr(unicode):
|
|||||||
|
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def get_script(source=None, column=None):
|
def get_script(source=None, column=None):
|
||||||
jedi.settings.additional_dynamic_modules = [b.name for b in vim.buffers
|
jedi.settings.additional_dynamic_modules = \
|
||||||
if b.name is not None and b.name.endswith('.py')]
|
[b.name for b in vim.buffers if b.name is not None and b.name.endswith('.py')]
|
||||||
if source is None:
|
if source is None:
|
||||||
source = '\n'.join(vim.current.buffer)
|
source = '\n'.join(vim.current.buffer)
|
||||||
row = vim.current.window.cursor[0]
|
row = vim.current.window.cursor[0]
|
||||||
@@ -172,8 +173,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
|
|||||||
d = list(definitions)[0]
|
d = list(definitions)[0]
|
||||||
if d.in_builtin_module():
|
if d.in_builtin_module():
|
||||||
if d.is_keyword:
|
if d.is_keyword:
|
||||||
echo_highlight(
|
echo_highlight("Cannot get the definition of Python keywords.")
|
||||||
"Cannot get the definition of Python keywords.")
|
|
||||||
else:
|
else:
|
||||||
echo_highlight("Builtin modules cannot be displayed (%s)."
|
echo_highlight("Builtin modules cannot be displayed (%s)."
|
||||||
% d.module_path)
|
% d.module_path)
|
||||||
@@ -189,8 +189,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
|
|||||||
lst = []
|
lst = []
|
||||||
for d in definitions:
|
for d in definitions:
|
||||||
if d.in_builtin_module():
|
if d.in_builtin_module():
|
||||||
lst.append(dict(text=
|
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
|
||||||
PythonToVimStr('Builtin ' + d.description)))
|
|
||||||
else:
|
else:
|
||||||
lst.append(dict(filename=PythonToVimStr(d.module_path),
|
lst.append(dict(filename=PythonToVimStr(d.module_path),
|
||||||
lnum=d.line, col=d.column + 1,
|
lnum=d.line, col=d.column + 1,
|
||||||
@@ -217,8 +216,8 @@ def show_documentation():
|
|||||||
echo_highlight('No documentation found for that.')
|
echo_highlight('No documentation found for that.')
|
||||||
vim.command('return')
|
vim.command('return')
|
||||||
else:
|
else:
|
||||||
docs = ['Docstring for %s\n%s\n%s' % (d.desc_with_module, '='*40, d.doc) if d.doc
|
docs = ['Docstring for %s\n%s\n%s' % (d.desc_with_module, '=' * 40, d.doc)
|
||||||
else '|No Docstring for %s|' % d for d in definitions]
|
if d.doc else '|No Docstring for %s|' % d for d in definitions]
|
||||||
text = ('\n' + '-' * 79 + '\n').join(docs)
|
text = ('\n' + '-' * 79 + '\n').join(docs)
|
||||||
vim.command('let l:doc = %s' % repr(PythonToVimStr(text)))
|
vim.command('let l:doc = %s' % repr(PythonToVimStr(text)))
|
||||||
vim.command('let l:doc_lines = %s' % len(text.split('\n')))
|
vim.command('let l:doc_lines = %s' % len(text.split('\n')))
|
||||||
@@ -232,9 +231,9 @@ def clear_call_signatures():
|
|||||||
for i, line in enumerate(vim.current.buffer):
|
for i, line in enumerate(vim.current.buffer):
|
||||||
match = re.search(r'%s' % regex, line)
|
match = re.search(r'%s' % regex, line)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
vim_regex = r'\v' + regex.replace('=', r'\=') + '.{%s}' % \
|
vim_regex = r'\v' + regex.replace('=', r'\=') + '.{%s}' \
|
||||||
int(match.group(1))
|
% int(match.group(1))
|
||||||
vim_command(r'try | %s,%ss/%s/\2/g | catch | endtry' \
|
vim_command(r'try | %s,%ss/%s/\2/g | catch | endtry'
|
||||||
% (i + 1, i + 1, vim_regex))
|
% (i + 1, i + 1, vim_regex))
|
||||||
vim_eval('histdel("search", -1)')
|
vim_eval('histdel("search", -1)')
|
||||||
vim_command('let @/ = histget("search", -1)')
|
vim_command('let @/ = histget("search", -1)')
|
||||||
@@ -470,4 +469,3 @@ def print_to_stdout(level, str_out):
|
|||||||
|
|
||||||
if not hasattr(jedi, '__version__') or jedi.__version__ < (0, 7, 0):
|
if not hasattr(jedi, '__version__') or jedi.__version__ < (0, 7, 0):
|
||||||
echo_highlight('Please update your Jedi version, it is to old.')
|
echo_highlight('Please update your Jedi version, it is to old.')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user