forked from VimPlug/jedi-vim
moving PythonToVimStr to before _catch_exception
This commit is contained in:
42
jedi_vim.py
42
jedi_vim.py
@@ -34,6 +34,27 @@ class VimError(Exception):
|
|||||||
return self.message + '; created by: ' + repr(self.executing)
|
return self.message + '; created by: ' + repr(self.executing)
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
else:
|
||||||
|
return unicode.__new__(cls, obj, encoding)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
# this is totally stupid and makes no sense but vim/python unicode
|
||||||
|
# support is pretty bad. don't ask how I came up with this... It just
|
||||||
|
# works...
|
||||||
|
# It seems to be related to that bug: http://bugs.python.org/issue5876
|
||||||
|
if unicode is str:
|
||||||
|
s = self
|
||||||
|
else:
|
||||||
|
s = self.encode('UTF-8')
|
||||||
|
return '"%s"' % s.replace('\\', '\\\\').replace('"', r'\"')
|
||||||
|
|
||||||
|
|
||||||
def _catch_exception(string, is_eval):
|
def _catch_exception(string, is_eval):
|
||||||
"""
|
"""
|
||||||
Interface between vim and python calls back to it.
|
Interface between vim and python calls back to it.
|
||||||
@@ -62,27 +83,6 @@ 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.')
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
else:
|
|
||||||
return unicode.__new__(cls, obj, encoding)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
# this is totally stupid and makes no sense but vim/python unicode
|
|
||||||
# support is pretty bad. don't ask how I came up with this... It just
|
|
||||||
# works...
|
|
||||||
# It seems to be related to that bug: http://bugs.python.org/issue5876
|
|
||||||
if unicode is str:
|
|
||||||
s = self
|
|
||||||
else:
|
|
||||||
s = self.encode('UTF-8')
|
|
||||||
return '"%s"' % s.replace('\\', '\\\\').replace('"', r'\"')
|
|
||||||
|
|
||||||
|
|
||||||
@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 = [b.name for b in vim.buffers
|
||||||
|
|||||||
Reference in New Issue
Block a user