- Fixed expand bug.

This commit is contained in:
Shougo Matsushita 2012-03-14 08:49:57 +09:00
parent 55803fcfcd
commit 02f0120c06
2 changed files with 31 additions and 12 deletions

View File

@ -89,25 +89,33 @@ function! s:source.initialize()"{{{
" Supported conceal features. " Supported conceal features.
augroup neocomplcache augroup neocomplcache
autocmd BufNewFile,BufRead,ColorScheme * autocmd BufNewFile,BufRead,ColorScheme *
\ syn match neocomplcacheExpandSnippets \ execute 'syn match neocomplcacheExpandSnippets'
\ '\${\d\+\%(:.\{-}\)\?\\\@<!}\|\$<\d\+\%(:.\{-}\)\?\\\@<!>\|\$\d\+' conceal cchar=$ \ "'".s:get_placeholder_marker_pattern(). '\|'
\ .s:get_sync_placeholder_marker_pattern().'\|'
\ .s:get_mirror_placeholder_marker_pattern()."'"
\ 'conceal cchar=$'
augroup END augroup END
else else
augroup neocomplcache augroup neocomplcache
autocmd BufNewFile,BufRead,ColorScheme * autocmd BufNewFile,BufRead,ColorScheme *
\ syn match neocomplcacheExpandSnippets \ execute 'syn match neocomplcacheExpandSnippets'
\ '\${\d\+\%(:.\{-}\)\?\\\@<!}\|\$<\d\+\%(:.\{-}\)\?\\\@<!>\|\$\d\+' \ "'".s:get_placeholder_marker_pattern(). '\|'
\ .s:get_sync_placeholder_marker_pattern().'\|'
\ .s:get_mirror_placeholder_marker_pattern()."'"
augroup END augroup END
endif endif
hi def link NeoComplCacheExpandSnippets Special hi def link NeoComplCacheExpandSnippets Special
command! -nargs=? -complete=customlist,neocomplcache#filetype_complete command! -nargs=? -complete=customlist,neocomplcache#filetype_complete
\ NeoComplCacheEditSnippets call s:edit_snippets(<q-args>, 0) \ NeoComplCacheEditSnippets
\ call s:edit_snippets(<q-args>, 0)
command! -nargs=? -complete=customlist,neocomplcache#filetype_complete command! -nargs=? -complete=customlist,neocomplcache#filetype_complete
\ NeoComplCacheEditRuntimeSnippets call s:edit_snippets(<q-args>, 1) \ NeoComplCacheEditRuntimeSnippets
\ call s:edit_snippets(<q-args>, 1)
command! -nargs=? -complete=customlist,neocomplcache#filetype_complete command! -nargs=? -complete=customlist,neocomplcache#filetype_complete
\ NeoComplCacheCachingSnippets call s:caching_snippets(<q-args>) \ NeoComplCacheCachingSnippets
\ call s:caching_snippets(<q-args>)
" Select mode mappings. " Select mode mappings.
if !exists('g:neocomplcache_disable_select_mode_mappings') if !exists('g:neocomplcache_disable_select_mode_mappings')
@ -543,9 +551,10 @@ function! neocomplcache#sources#snippets_complete#expand(cur_text, col, trigger_
let next_col = len(snippet_lines[-1]) + 1 let next_col = len(snippet_lines[-1]) + 1
let snippet_lines[-1] = snippet_lines[-1] . next_line let snippet_lines[-1] = snippet_lines[-1] . next_line
call setline(line('.'), snippet_lines) call setline(line('.'), snippet_lines[0])
call cursor(0, next_col) if len(snippet_lines) > 1
call append(line('.'), snippet_lines[1:])
endif
call s:indent_snippet(begin_line, end_line) call s:indent_snippet(begin_line, end_line)
if has('folding') && foldclosed(line('.')) if has('folding') && foldclosed(line('.'))
" Open fold. " Open fold.
@ -770,9 +779,18 @@ function! neocomplcache#sources#snippets_complete#get_snippets()"{{{
return snippets return snippets
endfunction"}}} endfunction"}}}
function! s:SID_PREFIX() function! s:get_placeholder_marker_pattern()"{{{
return '\${\d\+\%(:.\{-}\)\?\\\@<!}'
endfunction"}}}
function! s:get_sync_placeholder_marker_pattern()"{{{
return '\$<\d\+\%(:.\{-}\)\?\\\@<!>'
endfunction"}}}
function! s:get_mirror_placeholder_marker_pattern()"{{{
return '\$\d\+'
endfunction"}}}
function! s:SID_PREFIX()"{{{
return matchstr(expand('<sfile>'), '<SNR>\d\+_') return matchstr(expand('<sfile>'), '<SNR>\d\+_')
endfunction endfunction"}}}
" Plugin key-mappings. " Plugin key-mappings.
inoremap <silent><expr> <Plug>(neocomplcache_snippets_expand) inoremap <silent><expr> <Plug>(neocomplcache_snippets_expand)

View File

@ -297,6 +297,7 @@ CHANGELOG *neocomplcache-snippets-complete-changelog*
2012-03-14 2012-03-14
- Refactored expand snippet behavior. - Refactored expand snippet behavior.
- Fixed expand bug.
2012-03-08 2012-03-08
- Use shiftwidth instead of softabstop. - Use shiftwidth instead of softabstop.