The project now has a name: UltiSnips
This commit is contained in:
parent
5db7148f77
commit
86e7b3a1b5
@ -1,7 +1,7 @@
|
||||
|
||||
"" FUNCTIONS
|
||||
|
||||
function! PyVimSnips_ExpandSnippet()
|
||||
function! UltiSnips_ExpandSnippet()
|
||||
if exists('g:SuperTabMappingForward')
|
||||
if g:SuperTabMappingForward == "<s-tab>"
|
||||
let SuperTabKey = "\<c-n>"
|
||||
@ -20,7 +20,7 @@ function! PyVimSnips_ExpandSnippet()
|
||||
|
||||
" Now, really expand something
|
||||
py << EOF
|
||||
if not PySnipSnippets.try_expand():
|
||||
if not UltiSnips_Manager.try_expand():
|
||||
vim.command("""if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey)
|
||||
endif
|
||||
@ -30,16 +30,16 @@ EOF
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! PyVimSnips_JumpBackwards()
|
||||
function! UltiSnips_JumpBackwards()
|
||||
py << EOF
|
||||
PySnipSnippets.jump(True)
|
||||
UltiSnips_Manager.jump(True)
|
||||
EOF
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! PyVimSnips_JumpForwards()
|
||||
function! UltiSnips_JumpForwards()
|
||||
py << EOF
|
||||
PySnipSnippets.jump()
|
||||
UltiSnips_Manager.jump()
|
||||
EOF
|
||||
return ""
|
||||
endfunction
|
||||
@ -53,25 +53,25 @@ import vim, os, sys
|
||||
|
||||
for p in vim.eval("&runtimepath").split(','):
|
||||
dname = p + os.path.sep + "plugin"
|
||||
if os.path.exists(dname + os.path.sep + "PySnipEmu"):
|
||||
if os.path.exists(dname + os.path.sep + "UltiSnips"):
|
||||
if dname not in sys.path:
|
||||
sys.path.append(dname)
|
||||
break
|
||||
|
||||
from PySnipEmu import PySnipSnippets
|
||||
from UltiSnips import UltiSnips_Manager
|
||||
EOF
|
||||
|
||||
" You can remap these
|
||||
inoremap <Tab> <C-R>=PyVimSnips_ExpandSnippet()<cr>
|
||||
snoremap <Tab> <Esc>:call PyVimSnips_ExpandSnippet()<cr>
|
||||
inoremap <C-k> <C-R>=PyVimSnips_JumpBackwards()<cr>
|
||||
snoremap <C-k> <Esc>:call PyVimSnips_JumpBackwards()<cr>
|
||||
inoremap <C-j> <C-R>=PyVimSnips_JumpForwards()<cr>
|
||||
snoremap <C-j> <Esc>:call PyVimSnips_JumpForwards()<cr>
|
||||
inoremap <Tab> <C-R>=UltiSnips_ExpandSnippet()<cr>
|
||||
snoremap <Tab> <Esc>:call UltiSnips_ExpandSnippet()<cr>
|
||||
inoremap <C-k> <C-R>=UltiSnips_JumpBackwards()<cr>
|
||||
snoremap <C-k> <Esc>:call UltiSnips_JumpBackwards()<cr>
|
||||
inoremap <C-j> <C-R>=UltiSnips_JumpForwards()<cr>
|
||||
snoremap <C-j> <Esc>:call UltiSnips_JumpForwards()<cr>
|
||||
|
||||
" Do not remap this.
|
||||
snoremap <BS> <Esc>:py PySnipSnippets.backspace_while_selected()<cr>
|
||||
snoremap <BS> <Esc>:py UltiSnips_Manager.backspace_while_selected()<cr>
|
||||
|
||||
au CursorMovedI * py PySnipSnippets.cursor_moved()
|
||||
au InsertEnter * py PySnipSnippets.entered_insert_mode()
|
||||
au CursorMovedI * py UltiSnips_Manager.cursor_moved()
|
||||
au InsertEnter * py UltiSnips_Manager.entered_insert_mode()
|
||||
|
@ -2,7 +2,7 @@
|
||||
# encoding: utf-8
|
||||
|
||||
import vim
|
||||
from PySnipEmu.Geometry import Position
|
||||
from UltiSnips.Geometry import Position
|
||||
|
||||
__all__ = [ "TextBuffer", "VimBuffer" ]
|
||||
|
@ -6,8 +6,8 @@ import re
|
||||
import stat
|
||||
import tempfile
|
||||
|
||||
from PySnipEmu.Buffer import TextBuffer
|
||||
from PySnipEmu.Geometry import Span, Position
|
||||
from UltiSnips.Buffer import TextBuffer
|
||||
from UltiSnips.Geometry import Span, Position
|
||||
|
||||
__all__ = [ "Mirror", "Transformation", "SnippetInstance", "StartMarker" ]
|
||||
|
@ -7,9 +7,9 @@ import re
|
||||
import string
|
||||
import vim
|
||||
|
||||
from PySnipEmu.Geometry import Position
|
||||
from PySnipEmu.TextObjects import *
|
||||
from PySnipEmu.Buffer import VimBuffer
|
||||
from UltiSnips.Geometry import Position
|
||||
from UltiSnips.TextObjects import *
|
||||
from UltiSnips.Buffer import VimBuffer
|
||||
|
||||
class Snippet(object):
|
||||
_INDENT = re.compile(r"^[ \t]*")
|
||||
@ -359,7 +359,7 @@ class SnippetManager(object):
|
||||
def _load_snippets_for(self, ft):
|
||||
self._snippets[ft] = {}
|
||||
for p in vim.eval("&runtimepath").split(',')[::-1]:
|
||||
pattern = p + os.path.sep + "PySnippets" + os.path.sep + \
|
||||
pattern = p + os.path.sep + "UltiSnips" + os.path.sep + \
|
||||
"*%s.snippets" % ft
|
||||
|
||||
for fn in glob.glob(pattern):
|
||||
@ -375,5 +375,5 @@ class SnippetManager(object):
|
||||
return snips.get(trigger, [])
|
||||
|
||||
|
||||
PySnipSnippets = SnippetManager()
|
||||
UltiSnips_Manager = SnippetManager()
|
||||
|
20
test.py
20
test.py
@ -54,7 +54,7 @@ class _VimTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.send(ESC)
|
||||
|
||||
self.send(":py PySnipSnippets.reset()\n")
|
||||
self.send(":py UltiSnips_Manager.reset()\n")
|
||||
|
||||
if not isinstance(self.snippets[0],tuple):
|
||||
self.snippets = ( self.snippets, )
|
||||
@ -65,7 +65,7 @@ class _VimTest(unittest.TestCase):
|
||||
if len(s) == 3:
|
||||
descr = s[-1]
|
||||
self.send(''':py << EOF
|
||||
PySnipSnippets.add_snippet("%s","""%s""", "%s")
|
||||
UltiSnips_Manager.add_snippet("%s","""%s""", "%s")
|
||||
EOF
|
||||
''' % (sv,content.encode("string-escape"), descr.encode("string-escape"))
|
||||
)
|
||||
@ -86,7 +86,7 @@ EOF
|
||||
# Execute the command
|
||||
self.type(self.keys)
|
||||
|
||||
handle, fn = tempfile.mkstemp(prefix="PySnipEmuTest",suffix=".txt")
|
||||
handle, fn = tempfile.mkstemp(prefix="UltiSnips_Test",suffix=".txt")
|
||||
os.close(handle)
|
||||
os.unlink(fn)
|
||||
|
||||
@ -749,19 +749,19 @@ if __name__ == '__main__':
|
||||
send(":imapclear\n", options.session)
|
||||
send(":smapclear\n", options.session)
|
||||
|
||||
send(":inoremap <Tab> <C-R>=PyVimSnips_ExpandSnippet()<cr>\n",
|
||||
send(":inoremap <Tab> <C-R>=UltiSnips_ExpandSnippet()<cr>\n",
|
||||
options.session)
|
||||
send(":snoremap <Tab> <Esc>:call PyVimSnips_ExpandSnippet()<cr>\n",
|
||||
send(":snoremap <Tab> <Esc>:call UltiSnips_ExpandSnippet()<cr>\n",
|
||||
options.session)
|
||||
send(":inoremap + <C-R>=PyVimSnips_JumpBackwards()<cr>\n", options.session)
|
||||
send(":snoremap + <Esc>:call PyVimSnips_JumpBackwards()<cr>\n",
|
||||
send(":inoremap + <C-R>=UltiSnips_JumpBackwards()<cr>\n", options.session)
|
||||
send(":snoremap + <Esc>:call UltiSnips_JumpBackwards()<cr>\n",
|
||||
options.session)
|
||||
send(":inoremap ? <C-R>=PyVimSnips_JumpForwards()<cr>\n", options.session)
|
||||
send(":snoremap ? <Esc>:call PyVimSnips_JumpForwards()<cr>\n",
|
||||
send(":inoremap ? <C-R>=UltiSnips_JumpForwards()<cr>\n", options.session)
|
||||
send(":snoremap ? <Esc>:call UltiSnips_JumpForwards()<cr>\n",
|
||||
options.session)
|
||||
|
||||
# Mandatory remapping
|
||||
send(":snoremap <BS> <Esc>:py PySnipSnippets." \
|
||||
send(":snoremap <BS> <Esc>:py UltiSnips_Manager." \
|
||||
"backspace_while_selected()<cr>\n", options.session)
|
||||
|
||||
# Inform all test case which screen session to use
|
||||
|
Loading…
x
Reference in New Issue
Block a user