The project now has a name: UltiSnips

This commit is contained in:
Holger Rapp 2009-07-10 12:47:54 +02:00
parent 5db7148f77
commit 86e7b3a1b5
10 changed files with 35 additions and 35 deletions

View File

@ -1,7 +1,7 @@
"" FUNCTIONS "" FUNCTIONS
function! PyVimSnips_ExpandSnippet() function! UltiSnips_ExpandSnippet()
if exists('g:SuperTabMappingForward') if exists('g:SuperTabMappingForward')
if g:SuperTabMappingForward == "<s-tab>" if g:SuperTabMappingForward == "<s-tab>"
let SuperTabKey = "\<c-n>" let SuperTabKey = "\<c-n>"
@ -20,7 +20,7 @@ function! PyVimSnips_ExpandSnippet()
" Now, really expand something " Now, really expand something
py << EOF py << EOF
if not PySnipSnippets.try_expand(): if not UltiSnips_Manager.try_expand():
vim.command("""if exists('SuperTabKey') vim.command("""if exists('SuperTabKey')
call feedkeys(SuperTabKey) call feedkeys(SuperTabKey)
endif endif
@ -30,16 +30,16 @@ EOF
return "" return ""
endfunction endfunction
function! PyVimSnips_JumpBackwards() function! UltiSnips_JumpBackwards()
py << EOF py << EOF
PySnipSnippets.jump(True) UltiSnips_Manager.jump(True)
EOF EOF
return "" return ""
endfunction endfunction
function! PyVimSnips_JumpForwards() function! UltiSnips_JumpForwards()
py << EOF py << EOF
PySnipSnippets.jump() UltiSnips_Manager.jump()
EOF EOF
return "" return ""
endfunction endfunction
@ -53,25 +53,25 @@ import vim, os, sys
for p in vim.eval("&runtimepath").split(','): for p in vim.eval("&runtimepath").split(','):
dname = p + os.path.sep + "plugin" 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: if dname not in sys.path:
sys.path.append(dname) sys.path.append(dname)
break break
from PySnipEmu import PySnipSnippets from UltiSnips import UltiSnips_Manager
EOF EOF
" You can remap these " You can remap these
inoremap <Tab> <C-R>=PyVimSnips_ExpandSnippet()<cr> inoremap <Tab> <C-R>=UltiSnips_ExpandSnippet()<cr>
snoremap <Tab> <Esc>:call PyVimSnips_ExpandSnippet()<cr> snoremap <Tab> <Esc>:call UltiSnips_ExpandSnippet()<cr>
inoremap <C-k> <C-R>=PyVimSnips_JumpBackwards()<cr> inoremap <C-k> <C-R>=UltiSnips_JumpBackwards()<cr>
snoremap <C-k> <Esc>:call PyVimSnips_JumpBackwards()<cr> snoremap <C-k> <Esc>:call UltiSnips_JumpBackwards()<cr>
inoremap <C-j> <C-R>=PyVimSnips_JumpForwards()<cr> inoremap <C-j> <C-R>=UltiSnips_JumpForwards()<cr>
snoremap <C-j> <Esc>:call PyVimSnips_JumpForwards()<cr> snoremap <C-j> <Esc>:call UltiSnips_JumpForwards()<cr>
" Do not remap this. " 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 CursorMovedI * py UltiSnips_Manager.cursor_moved()
au InsertEnter * py PySnipSnippets.entered_insert_mode() au InsertEnter * py UltiSnips_Manager.entered_insert_mode()

View File

@ -2,7 +2,7 @@
# encoding: utf-8 # encoding: utf-8
import vim import vim
from PySnipEmu.Geometry import Position from UltiSnips.Geometry import Position
__all__ = [ "TextBuffer", "VimBuffer" ] __all__ = [ "TextBuffer", "VimBuffer" ]

View File

@ -6,8 +6,8 @@ import re
import stat import stat
import tempfile import tempfile
from PySnipEmu.Buffer import TextBuffer from UltiSnips.Buffer import TextBuffer
from PySnipEmu.Geometry import Span, Position from UltiSnips.Geometry import Span, Position
__all__ = [ "Mirror", "Transformation", "SnippetInstance", "StartMarker" ] __all__ = [ "Mirror", "Transformation", "SnippetInstance", "StartMarker" ]

View File

@ -7,9 +7,9 @@ import re
import string import string
import vim import vim
from PySnipEmu.Geometry import Position from UltiSnips.Geometry import Position
from PySnipEmu.TextObjects import * from UltiSnips.TextObjects import *
from PySnipEmu.Buffer import VimBuffer from UltiSnips.Buffer import VimBuffer
class Snippet(object): class Snippet(object):
_INDENT = re.compile(r"^[ \t]*") _INDENT = re.compile(r"^[ \t]*")
@ -359,7 +359,7 @@ class SnippetManager(object):
def _load_snippets_for(self, ft): def _load_snippets_for(self, ft):
self._snippets[ft] = {} self._snippets[ft] = {}
for p in vim.eval("&runtimepath").split(',')[::-1]: 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 "*%s.snippets" % ft
for fn in glob.glob(pattern): for fn in glob.glob(pattern):
@ -375,5 +375,5 @@ class SnippetManager(object):
return snips.get(trigger, []) return snips.get(trigger, [])
PySnipSnippets = SnippetManager() UltiSnips_Manager = SnippetManager()

20
test.py
View File

@ -54,7 +54,7 @@ class _VimTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.send(ESC) self.send(ESC)
self.send(":py PySnipSnippets.reset()\n") self.send(":py UltiSnips_Manager.reset()\n")
if not isinstance(self.snippets[0],tuple): if not isinstance(self.snippets[0],tuple):
self.snippets = ( self.snippets, ) self.snippets = ( self.snippets, )
@ -65,7 +65,7 @@ class _VimTest(unittest.TestCase):
if len(s) == 3: if len(s) == 3:
descr = s[-1] descr = s[-1]
self.send(''':py << EOF self.send(''':py << EOF
PySnipSnippets.add_snippet("%s","""%s""", "%s") UltiSnips_Manager.add_snippet("%s","""%s""", "%s")
EOF EOF
''' % (sv,content.encode("string-escape"), descr.encode("string-escape")) ''' % (sv,content.encode("string-escape"), descr.encode("string-escape"))
) )
@ -86,7 +86,7 @@ EOF
# Execute the command # Execute the command
self.type(self.keys) 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.close(handle)
os.unlink(fn) os.unlink(fn)
@ -749,19 +749,19 @@ if __name__ == '__main__':
send(":imapclear\n", options.session) send(":imapclear\n", options.session)
send(":smapclear\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) options.session)
send(":snoremap <Tab> <Esc>:call PyVimSnips_ExpandSnippet()<cr>\n", send(":snoremap <Tab> <Esc>:call UltiSnips_ExpandSnippet()<cr>\n",
options.session) options.session)
send(":inoremap + <C-R>=PyVimSnips_JumpBackwards()<cr>\n", options.session) send(":inoremap + <C-R>=UltiSnips_JumpBackwards()<cr>\n", options.session)
send(":snoremap + <Esc>:call PyVimSnips_JumpBackwards()<cr>\n", send(":snoremap + <Esc>:call UltiSnips_JumpBackwards()<cr>\n",
options.session) options.session)
send(":inoremap ? <C-R>=PyVimSnips_JumpForwards()<cr>\n", options.session) send(":inoremap ? <C-R>=UltiSnips_JumpForwards()<cr>\n", options.session)
send(":snoremap ? <Esc>:call PyVimSnips_JumpForwards()<cr>\n", send(":snoremap ? <Esc>:call UltiSnips_JumpForwards()<cr>\n",
options.session) options.session)
# Mandatory remapping # Mandatory remapping
send(":snoremap <BS> <Esc>:py PySnipSnippets." \ send(":snoremap <BS> <Esc>:py UltiSnips_Manager." \
"backspace_while_selected()<cr>\n", options.session) "backspace_while_selected()<cr>\n", options.session)
# Inform all test case which screen session to use # Inform all test case which screen session to use