From 320809c21147698a6892f1c859efe9703d2a1ae8 Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Sun, 8 Sep 2013 10:53:01 -0400 Subject: [PATCH 1/4] moving PythonToVimStr to before _catch_exception --- jedi_vim.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/jedi_vim.py b/jedi_vim.py index cf15f71..52b3ffd 100644 --- a/jedi_vim.py +++ b/jedi_vim.py @@ -34,6 +34,27 @@ class VimError(Exception): 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): """ 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.') -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 def get_script(source=None, column=None): jedi.settings.additional_dynamic_modules = [b.name for b in vim.buffers From f405ce625a1500de176634c0756a4c1f860ee1fb Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Sun, 8 Sep 2013 14:07:29 -0400 Subject: [PATCH 2/4] Revert "moving PythonToVimStr to before _catch_exception" This reverts commit 320809c21147698a6892f1c859efe9703d2a1ae8. --- jedi_vim.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/jedi_vim.py b/jedi_vim.py index 52b3ffd..cf15f71 100644 --- a/jedi_vim.py +++ b/jedi_vim.py @@ -34,27 +34,6 @@ class VimError(Exception): 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): """ Interface between vim and python calls back to it. @@ -83,6 +62,27 @@ if not hasattr(jedi, '__version__') or jedi.__version__ < (0, 7, 0): 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 def get_script(source=None, column=None): jedi.settings.additional_dynamic_modules = [b.name for b in vim.buffers From d1f8a91fd395501daee1a5de63bfc68292f89f1e Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Sun, 8 Sep 2013 14:14:19 -0400 Subject: [PATCH 3/4] moving if to end of file --- jedi_vim.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jedi_vim.py b/jedi_vim.py index cf15f71..1f1d056 100644 --- a/jedi_vim.py +++ b/jedi_vim.py @@ -58,10 +58,6 @@ def echo_highlight(msg): vim_command('echohl WarningMsg | echom "%s" | echohl None' % msg) -if not hasattr(jedi, '__version__') or jedi.__version__ < (0, 7, 0): - echo_highlight('Please update your Jedi version, it is to old.') - - class PythonToVimStr(unicode): """ Vim has a different string implementation of single quotes """ __slots__ = [] @@ -459,3 +455,7 @@ def escape_file_path(path): def print_to_stdout(level, str_out): print(str_out) + +if not hasattr(jedi, '__version__') or jedi.__version__ < (0, 7, 0): + echo_highlight('Please update your Jedi version, it is to old.') + From dd89f6ba6b7f5910d7b4c371e834396d8631d164 Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Sun, 8 Sep 2013 14:15:22 -0400 Subject: [PATCH 4/4] adding self to authors --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 0c7bb33..42b825a 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -31,6 +31,7 @@ Tin Tvrtković (@Tinche) Zekeriya Koc (@zekzekus) ethinx (@ethinx) Wouter Overmeire (@lodagro) +Stephen J. Fuhry (@fuhrysteve) @something are github user names.