- Fixed snippets indentation.

This commit is contained in:
Shougo Matsushita 2012-03-16 00:06:21 +09:00
parent bb74b83c7c
commit 16a651924c
3 changed files with 24 additions and 15 deletions

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: snippets_complete.vim " FILE: snippets_complete.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 15 Mar 2012. " Last Modified: 16 Mar 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
@ -443,7 +443,7 @@ function! s:load_snippets(snippet, snippets_file)"{{{
let snippet_pattern.word = matchstr(line, '^\s\+\zs.*$') let snippet_pattern.word = matchstr(line, '^\s\+\zs.*$')
else else
let snippet_pattern.word .= "\n" let snippet_pattern.word .= "\n"
\ . matchstr(line, '^\s\+\zs.*$') \ . matchstr(line, '^\%(\t\| *\)\zs.*$')
endif endif
elseif line =~ '^$' elseif line =~ '^$'
" Blank line. " Blank line.
@ -607,22 +607,28 @@ function! s:indent_snippet(begin, end)"{{{
let equalprg = &l:equalprg let equalprg = &l:equalprg
setlocal equalprg= setlocal equalprg=
let pos = getpos('.')
let base_indent = matchstr(getline(a:begin), '^\s\+')
for line_nr in range(a:begin, a:end) for line_nr in range(a:begin, a:end)
call cursor(line_nr, 0) call cursor(line_nr, 0)
if &l:expandtab && getline('.') =~ '^\t\+' if getline('.') =~ '^\t\+'
" Expand tab. if &l:expandtab
cal setline('.', substitute(getline('.'), " Expand tab.
\ '^\t\+', repeat(' ', &shiftwidth * cal setline('.', substitute(getline('.'),
\ len(matchstr(getline('.'), '^\t\+'))), '')) \ '^\t\+', repeat(' ', &shiftwidth *
\ len(matchstr(getline('.'), '^\t\+'))), ''))
elseif line_nr != a:begin
call setline('.', base_indent . getline('.'))
endif
else else
let pos = getpos('.')
startinsert!
silent normal! == silent normal! ==
call setpos('.', pos)
endif endif
endfor endfor
call setpos('.', pos)
let &l:equalprg = equalprg let &l:equalprg = equalprg
endfunction"}}} endfunction"}}}

View File

@ -75,11 +75,11 @@ abbr enum {}
# main function. # main function.
snippet main snippet main
int main(int argc, char const* argv[]) int main(int argc, char const* argv[])
{ {
${0} ${0}
return 0; return 0;
} }
# #include <...> # #include <...>
snippet inc snippet inc

View File

@ -295,6 +295,9 @@ snippet *neocomplcache-snippets-complete-unite-action-snippet*
============================================================================== ==============================================================================
CHANGELOG *neocomplcache-snippets-complete-changelog* CHANGELOG *neocomplcache-snippets-complete-changelog*
2012-03-16
- Fixed snippets indentation.
2012-03-15 2012-03-15
- Improved search snippet markers behavior. - Improved search snippet markers behavior.
- Don't conceal default codes. - Don't conceal default codes.