diff --git a/plugin/UltiSnips/Compatibility.py b/plugin/UltiSnips/Compatibility.py index 3fe7176..7fbc43d 100644 --- a/plugin/UltiSnips/Compatibility.py +++ b/plugin/UltiSnips/Compatibility.py @@ -10,7 +10,7 @@ import sys __all__ = ['as_unicode'] -if sys.version_info > (2,8): +if sys.version_info >= (3,0): def as_unicode(s): if isinstance(s, bytes): return s.decode("utf-8") diff --git a/plugin/UltiSnips/Langmap.py b/plugin/UltiSnips/Langmap.py index 5c09b1c..9bb07d2 100644 --- a/plugin/UltiSnips/Langmap.py +++ b/plugin/UltiSnips/Langmap.py @@ -12,8 +12,6 @@ for example if 'j' is remapped, but nothing is mapped back to 'j', then moving one line down is no longer possible and UltiSnips will fail. """ -import string - import vim class Real_LangMapTranslator(object): @@ -34,7 +32,7 @@ class Real_LangMapTranslator(object): from_chars += c[::2] to_chars += c[1::2] - self._maps[langmap] = string.maketrans(to_chars, from_chars) + self._maps[langmap] = (from_chars, to_chars) def translate(self, s): langmap = vim.eval("&langmap").strip() @@ -44,7 +42,9 @@ class Real_LangMapTranslator(object): if langmap not in self._maps: self._create_translation(langmap) - return s.translate(self._maps[langmap]) + for f,t in zip(*self._maps[langmap]): + s = s.replace(f,t) + return s class Dummy_LangMapTranslator(object): """