From 16a651924c63d3a85f023d07e2de9ac9f74b55f8 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Fri, 16 Mar 2012 00:06:21 +0900 Subject: [PATCH] - Fixed snippets indentation. --- .../sources/snippets_complete.vim | 26 ++++++++++++------- .../sources/snippets_complete/c.snip | 10 +++---- doc/neocomplcache-snippets-complete.txt | 3 +++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/autoload/neocomplcache/sources/snippets_complete.vim b/autoload/neocomplcache/sources/snippets_complete.vim index 0218f08..513d73c 100644 --- a/autoload/neocomplcache/sources/snippets_complete.vim +++ b/autoload/neocomplcache/sources/snippets_complete.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: snippets_complete.vim " AUTHOR: Shougo Matsushita -" Last Modified: 15 Mar 2012. +" Last Modified: 16 Mar 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 @@ -443,7 +443,7 @@ function! s:load_snippets(snippet, snippets_file)"{{{ let snippet_pattern.word = matchstr(line, '^\s\+\zs.*$') else let snippet_pattern.word .= "\n" - \ . matchstr(line, '^\s\+\zs.*$') + \ . matchstr(line, '^\%(\t\| *\)\zs.*$') endif elseif line =~ '^$' " Blank line. @@ -607,22 +607,28 @@ function! s:indent_snippet(begin, end)"{{{ let equalprg = &l:equalprg setlocal equalprg= + let pos = getpos('.') + + let base_indent = matchstr(getline(a:begin), '^\s\+') for line_nr in range(a:begin, a:end) call cursor(line_nr, 0) - if &l:expandtab && getline('.') =~ '^\t\+' - " Expand tab. - cal setline('.', substitute(getline('.'), - \ '^\t\+', repeat(' ', &shiftwidth * - \ len(matchstr(getline('.'), '^\t\+'))), '')) + if getline('.') =~ '^\t\+' + if &l:expandtab + " Expand tab. + cal setline('.', substitute(getline('.'), + \ '^\t\+', repeat(' ', &shiftwidth * + \ len(matchstr(getline('.'), '^\t\+'))), '')) + elseif line_nr != a:begin + call setline('.', base_indent . getline('.')) + endif else - let pos = getpos('.') - startinsert! silent normal! == - call setpos('.', pos) endif endfor + call setpos('.', pos) + let &l:equalprg = equalprg endfunction"}}} diff --git a/autoload/neocomplcache/sources/snippets_complete/c.snip b/autoload/neocomplcache/sources/snippets_complete/c.snip index 4cce280..441e75a 100644 --- a/autoload/neocomplcache/sources/snippets_complete/c.snip +++ b/autoload/neocomplcache/sources/snippets_complete/c.snip @@ -75,11 +75,11 @@ abbr enum {} # main function. snippet main - int main(int argc, char const* argv[]) - { - ${0} - return 0; - } + int main(int argc, char const* argv[]) + { + ${0} + return 0; + } # #include <...> snippet inc diff --git a/doc/neocomplcache-snippets-complete.txt b/doc/neocomplcache-snippets-complete.txt index 37fa862..6430c4d 100644 --- a/doc/neocomplcache-snippets-complete.txt +++ b/doc/neocomplcache-snippets-complete.txt @@ -295,6 +295,9 @@ snippet *neocomplcache-snippets-complete-unite-action-snippet* ============================================================================== CHANGELOG *neocomplcache-snippets-complete-changelog* +2012-03-16 +- Fixed snippets indentation. + 2012-03-15 - Improved search snippet markers behavior. - Don't conceal default codes.