- Implemented commented placeholder.

This commit is contained in:
Shougo Matsushita 2012-10-30 05:09:50 +09:00
parent c1cfe686ad
commit 9e96a69061
3 changed files with 29 additions and 9 deletions

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 29 Oct 2012.
" Last Modified: 30 Oct 2012.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@ -735,6 +735,10 @@ function! s:expand_placeholder(start, end, holder_cnt, line)"{{{
\ '\\d\\+', a:holder_cnt, '')
let default = substitute(
\ matchstr(current_line, default_pattern), '\\\ze[^\\]', '', 'g')
let neosnippet = neosnippet#get_current_neosnippet()
let neosnippet.selected_text = default
" Substitute marker.
let default = substitute(default,
\ s:get_placeholder_marker_substitute_pattern(),
@ -973,6 +977,7 @@ function! neosnippet#get_selected_text(type, ...)
let sel_save = &selection
let &selection = 'inclusive'
let reg_save = @@
let pos = getpos('.')
try
" Invoked from Visual mode, use '< and '> marks.
@ -991,6 +996,7 @@ function! neosnippet#get_selected_text(type, ...)
finally
let &selection = sel_save
let @@ = reg_save
call setpos('.', pos)
endtry
endfunction

View File

@ -361,6 +361,16 @@ Placeholder feature is available. The string after ":" is default value.
${2}
endif
<
Commented placeholder feature is available. If the default value starts with
"#:", neosnippet will the delete default value when jump to next placeholder.
>
snippet if
abbr if endif
options head
if ${1:#:condition}
${2}
endif
<
Note: To contain "}" character in default value, you must escape "}".
>
snippet test
@ -454,6 +464,9 @@ snippet *neosnippet-unite-action-snippet*
==============================================================================
CHANGELOG *neosnippet-changelog*
2012-10-30
- Implemented commented placeholder.
2012-10-29
- Improved parse of snippets file.
- Improved syntax of markers.

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 29 Oct 2012.
" Last Modified: 30 Oct 2012.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@ -40,22 +40,23 @@ set cpo&vim
" Plugin key-mappings."{{{
inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
\ neosnippet#expand_or_jump_impl()
snoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
\ neosnippet#expand_or_jump_impl()
inoremap <silent><expr> <Plug>(neosnippet_jump_or_expand)
\ neosnippet#jump_or_expand_impl()
snoremap <silent><expr> <Plug>(neosnippet_jump_or_expand)
\ neosnippet#jump_or_expand_impl()
inoremap <silent><expr> <Plug>(neosnippet_expand)
\ neosnippet#expand_impl()
snoremap <silent><expr> <Plug>(neosnippet_expand)
\ neosnippet#expand_impl()
inoremap <silent><expr> <Plug>(neosnippet_jump)
\ neosnippet#jump_impl()
snoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
\ neosnippet#expand_or_jump_impl()
snoremap <silent><expr> <Plug>(neosnippet_jump_or_expand)
\ neosnippet#jump_or_expand_impl()
snoremap <silent><expr> <Plug>(neosnippet_expand)
\ neosnippet#expand_impl()
snoremap <silent><expr> <Plug>(neosnippet_jump)
\ neosnippet#jump_impl()
" <C-v>:call neosnippet#get_selected_text(visualmode(), 1)<CR><C-v>
xnoremap <silent> <Plug>(neosnippet_get_selected_text)
\ :call neosnippet#get_selected_text(visualmode(), 1)<CR>
imap <silent> <Plug>(neocomplcache_snippets_expand)
\ <Plug>(neosnippet_expand_or_jump)