fix python3, finally
This commit is contained in:
parent
b50c5c86c3
commit
3c4ac11af3
99
autoload/UltiSnips/bootstrap.vim
Normal file
99
autoload/UltiSnips/bootstrap.vim
Normal file
@ -0,0 +1,99 @@
|
||||
let s:SourcedFile=expand("<sfile>")
|
||||
|
||||
function! UltiSnips#bootstrap#Bootstrap()
|
||||
if exists('s:did_UltiSnips_bootstrap')
|
||||
return
|
||||
endif
|
||||
let s:did_UltiSnips_bootstrap=1
|
||||
|
||||
if !exists("g:UltiSnipsUsePythonVersion")
|
||||
let g:_uspy=":py3 "
|
||||
if !has("python3")
|
||||
if !has("python")
|
||||
if !exists("g:UltiSnipsNoPythonWarning")
|
||||
echohl WarningMsg
|
||||
echom "UltiSnips requires py >= 2.7 or any py3"
|
||||
echohl None
|
||||
endif
|
||||
unlet g:_uspy
|
||||
return
|
||||
endif
|
||||
let g:_uspy=":py "
|
||||
endif
|
||||
let g:UltiSnipsUsePythonVersion = "<tab>"
|
||||
else
|
||||
" Use user-provided value, but check if it's available.
|
||||
" This uses `has()`, because e.g. `exists(":python3")` is always 2.
|
||||
if g:UltiSnipsUsePythonVersion == 2 && has('python')
|
||||
let g:_uspy=":python "
|
||||
elseif g:UltiSnipsUsePythonVersion == 3 && has('python3')
|
||||
let g:_uspy=":python3 "
|
||||
endif
|
||||
if !exists('g:_uspy')
|
||||
echohl WarningMsg
|
||||
echom "UltiSnips: the Python version from g:UltiSnipsUsePythonVersion (".g:UltiSnipsUsePythonVersion.") is not available."
|
||||
echohl None
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
" Expand our path
|
||||
exec g:_uspy "import vim, os, sys"
|
||||
exec g:_uspy "sourced_file = vim.eval('s:SourcedFile')"
|
||||
exec g:_uspy "while not os.path.exists(os.path.join(sourced_file, 'pythonx')):
|
||||
\ sourced_file = os.path.dirname(sourced_file)"
|
||||
exec g:_uspy "module_path = os.path.join(sourced_file, 'pythonx')"
|
||||
exec g:_uspy "vim.command(\"let g:UltiSnipsPythonPath = '%s'\" % module_path)"
|
||||
exec g:_uspy "if not hasattr(vim, 'VIM_SPECIAL_PATH'): sys.path.append(module_path)"
|
||||
exec g:_uspy "from UltiSnips.snippet_manager import UltiSnips_Manager"
|
||||
endfunction
|
||||
|
||||
" The trigger used to expand a snippet.
|
||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
||||
if !exists("g:UltiSnipsExpandTrigger")
|
||||
let g:UltiSnipsExpandTrigger = "<tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to display all triggers that could possible
|
||||
" match in the current position.
|
||||
if !exists("g:UltiSnipsListSnippets")
|
||||
let g:UltiSnipsListSnippets = "<c-tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to jump forward to the next placeholder.
|
||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
||||
if !exists("g:UltiSnipsJumpForwardTrigger")
|
||||
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
|
||||
endif
|
||||
|
||||
" The trigger to jump backward inside a snippet
|
||||
if !exists("g:UltiSnipsJumpBackwardTrigger")
|
||||
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
|
||||
endif
|
||||
|
||||
" Should UltiSnips unmap select mode mappings automagically?
|
||||
if !exists("g:UltiSnipsRemoveSelectModeMappings")
|
||||
let g:UltiSnipsRemoveSelectModeMappings = 1
|
||||
end
|
||||
|
||||
" If UltiSnips should remove Mappings, which should be ignored
|
||||
if !exists("g:UltiSnipsMappingsToIgnore")
|
||||
let g:UltiSnipsMappingsToIgnore = []
|
||||
endif
|
||||
|
||||
" UltiSnipsEdit will use this variable to decide if a new window
|
||||
" is opened when editing. default is "normal", allowed are also
|
||||
" "vertical", "horizontal"
|
||||
if !exists("g:UltiSnipsEditSplit")
|
||||
let g:UltiSnipsEditSplit = 'normal'
|
||||
endif
|
||||
|
||||
" A list of directory names that are searched for snippets.
|
||||
if !exists("g:UltiSnipsSnippetDirectories")
|
||||
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
||||
endif
|
||||
|
||||
" Enable or Disable snipmate snippet expansion.
|
||||
if !exists("g:UltiSnipsEnableSnipMate")
|
||||
let g:UltiSnipsEnableSnipMate = 1
|
||||
endif
|
@ -2,12 +2,3 @@
|
||||
# encoding: utf-8
|
||||
|
||||
"""Entry point for all thinks UltiSnips."""
|
||||
|
||||
import vim # pylint:disable=import-error
|
||||
|
||||
from UltiSnips.snippet_manager import SnippetManager
|
||||
|
||||
UltiSnips_Manager = SnippetManager( # pylint:disable=invalid-name
|
||||
vim.eval('g:UltiSnipsExpandTrigger'),
|
||||
vim.eval('g:UltiSnipsJumpForwardTrigger'),
|
||||
vim.eval('g:UltiSnipsJumpBackwardTrigger'))
|
||||
|
@ -159,8 +159,12 @@ class VimBufferProxy(_vim.VimBuffer):
|
||||
Very fast diffing algorithm when changes are across many lines.
|
||||
"""
|
||||
for line_number in range(start, end):
|
||||
if line_number < 0:
|
||||
line_number = len(self._buffer) + line_number
|
||||
yield ('D', line_number, 0, self._buffer[line_number])
|
||||
|
||||
if start < 0:
|
||||
start = len(self._buffer) + start
|
||||
for line_number in range(0, len(new_value)):
|
||||
yield ('I', start+line_number, 0, new_value[line_number])
|
||||
|
||||
|
@ -8,6 +8,7 @@ from functools import wraps
|
||||
import os
|
||||
import platform
|
||||
import traceback
|
||||
import vim
|
||||
from contextlib import contextmanager
|
||||
|
||||
from UltiSnips import _vim
|
||||
@ -763,3 +764,8 @@ class SnippetManager(object):
|
||||
yield
|
||||
finally:
|
||||
self._inside_action = old_flag
|
||||
|
||||
UltiSnips_Manager = SnippetManager( # pylint:disable=invalid-name
|
||||
vim.eval('g:UltiSnipsExpandTrigger'),
|
||||
vim.eval('g:UltiSnipsJumpForwardTrigger'),
|
||||
vim.eval('g:UltiSnipsJumpBackwardTrigger'))
|
||||
|
@ -10,7 +10,7 @@ from UltiSnips import _vim
|
||||
from UltiSnips.compatibility import as_unicode
|
||||
from UltiSnips.indent_util import IndentUtil
|
||||
from UltiSnips.text_objects._base import NoneditableTextObject
|
||||
import UltiSnips
|
||||
import UltiSnips.snippet_manager
|
||||
|
||||
|
||||
class _Tabs(object):
|
||||
@ -37,7 +37,9 @@ class SnippetUtilForAction(dict):
|
||||
self.__dict__ = self
|
||||
|
||||
def expand_anon(self, *args, **kwargs):
|
||||
UltiSnips.UltiSnips_Manager.expand_anon(*args, **kwargs)
|
||||
UltiSnips.snippet_manager.UltiSnips_Manager.expand_anon(
|
||||
*args, **kwargs
|
||||
)
|
||||
self.cursor.preserve()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user