- Use head instead of prev_word.

This commit is contained in:
Shougo Matsushita 2012-10-21 21:13:26 +09:00
parent fdc6880600
commit f79f3df531
9 changed files with 35 additions and 30 deletions

View File

@ -64,7 +64,7 @@ snippet bfun
snippet cla snippet cla
abbr cla abbr cla
prev_word '^' options head
class ${1:ClassName}${2: extends ${3:Ancestor\}} class ${1:ClassName}${2: extends ${3:Ancestor\}}
constructor: (${4:args}) -> constructor: (${4:args}) ->

View File

@ -43,7 +43,7 @@ abbr static_assert(,"")
delete namespace delete namespace
snippet namespace snippet namespace
abbr namespace {} abbr namespace {}
prev_word '^' options head
namespace ${1:name} namespace ${1:name}
${0} ${0}
} // namespace $1 } // namespace $1

View File

@ -1,13 +1,13 @@
snippet class snippet class
abbr class Class(...): ... abbr class Class(...): ...
prev_word '^' options head
class ${1:name}(${2:object}): class ${1:name}(${2:object}):
def __init__(self, ${3}): def __init__(self, ${3}):
${0} ${0}
snippet classd snippet classd
abbr class Class(...): "..." abbr class Class(...): "..."
prev_word '^' options head
class ${1:name}(${2:object}): class ${1:name}(${2:object}):
"""${3:class documentation}""" """${3:class documentation}"""
def __init__(self, ${4}): def __init__(self, ${4}):
@ -16,45 +16,45 @@ prev_word '^'
snippet def snippet def
abbr def function(...): ... abbr def function(...): ...
prev_word '^' options head
def ${1:name}(${2}): def ${1:name}(${2}):
${0} ${0}
snippet defd snippet defd
abbr def function(...): """...""" abbr def function(...): """..."""
prev_word '^' options head
def ${1:name}(${2}): def ${1:name}(${2}):
"""${3:function documentation}""" """${3:function documentation}"""
${0} ${0}
snippet defm snippet defm
abbr def method(self, ...): ... abbr def method(self, ...): ...
prev_word '^' options head
def ${1:name}(self, ${2}): def ${1:name}(self, ${2}):
${0} ${0}
snippet defmd snippet defmd
abbr def method(self, ...): "..." abbr def method(self, ...): "..."
prev_word '^' options head
def ${1:name}(self, ${2}): def ${1:name}(self, ${2}):
"""${3:method documentation}""" """${3:method documentation}"""
${0} ${0}
snippet elif snippet elif
abbr elif ...: ... abbr elif ...: ...
prev_word '^' options head
elif ${1:condition}: elif ${1:condition}:
${0} ${0}
snippet else snippet else
abbr else: ... abbr else: ...
prev_word '^' options head
else: else:
${0} ${0}
snippet fileidiom snippet fileidiom
abbr f = None try: f = open(...) finally: ... abbr f = None try: f = open(...) finally: ...
prev_word '^' options head
${1:f} = None ${1:f} = None
try: try:
$1 = open(${2}) $1 = open(${2})
@ -65,25 +65,25 @@ prev_word '^'
snippet for snippet for
abbr for ... in ...: ... abbr for ... in ...: ...
prev_word '^' options head
for ${1:value} in ${2:list}: for ${1:value} in ${2:list}:
${0} ${0}
snippet if snippet if
abbr if ...: ... abbr if ...: ...
prev_word '^' options head
if ${1:condition}: if ${1:condition}:
${0} ${0}
snippet ifmain snippet ifmain
abbr if __name__ == '__main__': ... abbr if __name__ == '__main__': ...
prev_word '^' options head
if __name__ == '__main__': if __name__ == '__main__':
${0} ${0}
snippet tryexcept snippet tryexcept
abbr try: ... except ...: ... abbr try: ... except ...: ...
prev_word '^' options head
try: try:
${1} ${1}
except ${2:ExceptionClass}: except ${2:ExceptionClass}:
@ -91,7 +91,7 @@ prev_word '^'
snippet tryfinally snippet tryfinally
abbr try: ... finally: ... abbr try: ... finally: ...
prev_word '^' options head
try: try:
${1} ${1}
finally: finally:
@ -99,7 +99,7 @@ prev_word '^'
snippet while snippet while
abbr while ...: ... abbr while ...: ...
prev_word '^' options head
while ${1:condition}: while ${1:condition}:
${0} ${0}

View File

@ -6,7 +6,7 @@ abbr match {\n case .. => ..
snippet try snippet try
abbr try {} catch { case ... } abbr try {} catch { case ... }
prev_word '^' options head
try { try {
${1} ${1}
} catch { } catch {
@ -23,14 +23,14 @@ abbr println('name, name)
snippet main snippet main
abbr def main(args: Array[String]) { abbr def main(args: Array[String]) {
prev_word '^' options head
def main(args: Array[String]) { def main(args: Array[String]) {
${0} ${0}
} }
snippet hello snippet hello
abbr object HelloWorld { def main(...) } abbr object HelloWorld { def main(...) }
prev_word '^' options head
object HelloWorld { object HelloWorld {
def main(args: Array[String]) { def main(args: Array[String]) {
println("Hello, world!") println("Hello, world!")

View File

@ -1,8 +1,8 @@
snippet snippet snippet snippet
abbr snippet abbr prev_word <snippet code> abbr snippet abbr options <snippet code>
alias snip alias snip
prev_word '^' options head
snippet ${1:trigger} snippet ${1:trigger}
abbr ${2:abbr} abbr ${2:abbr}
prev_word '^' options head
${3:snippet code} ${3:snippet code}

View File

@ -12,7 +12,7 @@ abbr import
snippet vital_import snippet vital_import
abbr let s:M = s:V.import('...') abbr let s:M = s:V.import('...')
prev_word '^' options head
let ${1:s:M} = ${2:s:V}.import('${3:Module}') let ${1:s:M} = ${2:s:V}.import('${3:Module}')
snippet vital_load_without_call snippet vital_load_without_call

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: snippet.vim " FILE: snippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 18 Oct 2012. " Last Modified: 21 Oct 2012.
" License: MIT license {{{ " License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining " Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the " a copy of this software and associated documentation files (the
@ -136,8 +136,12 @@ function! s:action_table.unite__new_candidate.func(candidate)"{{{
call append('$', '') call append('$', '')
endif endif
call append('$', ['snippet ' . trigger, 'abbr ' . trigger, call append('$', [
\ "prev_word '^'", ' ']) \ 'snippet ' . trigger,
\ 'abbr ' . trigger,
\ 'options head',
\ ' '
\ ])
call cursor(line('$'), 0) call cursor(line('$'), 0)
call cursor(0, col('$')) call cursor(0, col('$'))

View File

@ -458,6 +458,7 @@ CHANGELOG *neosnippet-changelog*
- Added options head. - Added options head.
- Added options word. - Added options word.
- Improved options word behavior. - Improved options word behavior.
- Use head instead of prev_word.
2012-10-20 2012-10-20
- Improved scala snip. - Improved scala snip.

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: snippets.vim " FILE: snippets.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 19 Sep 2011. " Last Modified: 21 Oct 2012.
" License: MIT license {{{ " License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining " Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the " a copy of this software and associated documentation files (the
@ -45,8 +45,8 @@ function! SnippetsIndent()"{{{
if prev_line =~ '^\s*$' if prev_line =~ '^\s*$'
return 0 return 0
elseif prev_line =~ '^\%(include\|snippet\|abbr\|prev_word\|rank\|delete\|alias\|condition\)' elseif prev_line =~ '^\%(include\|snippet\|abbr\|prev_word\|delete\|alias\|options\)'
\&& line !~ '^\s*\%(include\|snippet\|abbr\|prev_word\|rank\|delete\|alias\|condition\)' \&& line !~ '^\s*\%(include\|snippet\|abbr\|prev_word\|delete\|alias\|options\)'
return &shiftwidth return &shiftwidth
else else
return match(line, '\S') return match(line, '\S')