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