summaryrefslogtreecommitdiff
path: root/runtime/indent
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-05-21 12:05:36 +0200
committerBram Moolenaar <Bram@vim.org>2010-05-21 12:05:36 +0200
commit7a329911b9ae2b97453fd995bc3a6523cf3aab53 (patch)
treeb75f6a117f48fe0c441b67cca09490f623233a74 /runtime/indent
parentc6af8125c7593b3ca104bf1feac0d814fe76d92d (diff)
downloadvim-git-7a329911b9ae2b97453fd995bc3a6523cf3aab53.tar.gz
Updated runtime files.
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/cucumber.vim1
-rw-r--r--runtime/indent/gitconfig.vim30
-rw-r--r--runtime/indent/haml.vim14
-rw-r--r--runtime/indent/liquid.vim63
-rw-r--r--runtime/indent/sass.vim8
5 files changed, 90 insertions, 26 deletions
diff --git a/runtime/indent/cucumber.vim b/runtime/indent/cucumber.vim
index 8cbbc3974..a19d123f7 100644
--- a/runtime/indent/cucumber.vim
+++ b/runtime/indent/cucumber.vim
@@ -1,6 +1,7 @@
" Vim indent file
" Language: Cucumber
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
+" Last Change: 2010 May 21
if exists("b:did_indent")
finish
diff --git a/runtime/indent/gitconfig.vim b/runtime/indent/gitconfig.vim
index 28d95b7cd..fa57e56ab 100644
--- a/runtime/indent/gitconfig.vim
+++ b/runtime/indent/gitconfig.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: git config file
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
-" Last Change: 2009 Dec 24
+" Last Change: 2010 May 21
if exists("b:did_indent")
finish
@@ -18,18 +18,18 @@ if exists("*GetGitconfigIndent")
endif
function! GetGitconfigIndent()
- let line = getline(prevnonblank(v:lnum-1))
- let cline = getline(v:lnum)
- if line =~ '\\\@<!\%(\\\\\)*\\$'
- " odd number of slashes, in a line continuation
- return 2 * &sw
- elseif cline =~ '^\s*\['
- return 0
- elseif cline =~ '^\s*\a'
- return &sw
- elseif cline == '' && line =~ '^\['
- return &sw
- else
- return -1
- endif
+ let line = getline(prevnonblank(v:lnum-1))
+ let cline = getline(v:lnum)
+ if line =~ '\\\@<!\%(\\\\\)*\\$'
+ " odd number of slashes, in a line continuation
+ return 2 * &sw
+ elseif cline =~ '^\s*\['
+ return 0
+ elseif cline =~ '^\s*\a'
+ return &sw
+ elseif cline == '' && line =~ '^\['
+ return &sw
+ else
+ return -1
+ endif
endfunction
diff --git a/runtime/indent/haml.vim b/runtime/indent/haml.vim
index c1feee09a..079bd0513 100644
--- a/runtime/indent/haml.vim
+++ b/runtime/indent/haml.vim
@@ -1,7 +1,7 @@
" Vim indent file
-" Language: HAML
-" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
-" Last Change: 2007 Dec 16
+" Language: Haml
+" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
+" Last Change: 2008 Sep 11
if exists("b:did_indent")
finish
@@ -44,8 +44,6 @@ function! GetHamlIndent()
if indent == indent(lnum)
let indent = cindent <= indent ? -1 : increase
endif
- "let indent = indent == indent(lnum) ? -1 : indent
- "let indent = indent > indent(lnum) + &sw ? indent(lnum) + &sw : indent
let group = synIDattr(synID(lnum,lastcol,1),'name')
@@ -53,9 +51,11 @@ function! GetHamlIndent()
return indent
elseif line =~ '^/\%(\[[^]]*\]\)\=$'
return increase
- elseif line =~ '^:'
+ elseif group == 'hamlFilter'
return increase
- elseif line =~ '^'.s:tag.'[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do |[^|]*|\s*$\)'
+ elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)'
+ return increase
+ elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$'
return increase
elseif line == '-#'
return increase
diff --git a/runtime/indent/liquid.vim b/runtime/indent/liquid.vim
new file mode 100644
index 000000000..08341b04f
--- /dev/null
+++ b/runtime/indent/liquid.vim
@@ -0,0 +1,63 @@
+" Vim indent file
+" Language: Liquid
+" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
+" Last Change: 2010 May 21
+
+if exists('b:did_indent')
+ finish
+endif
+
+set indentexpr=
+if exists('b:liquid_subtype')
+ exe 'runtime! indent/'.b:liquid_subtype.'.vim'
+else
+ runtime! indent/html.vim
+endif
+unlet! b:did_indent
+
+if &l:indentexpr == ''
+ if &l:cindent
+ let &l:indentexpr = 'cindent(v:lnum)'
+ else
+ let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
+ endif
+endif
+let b:liquid_subtype_indentexpr = &l:indentexpr
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetLiquidIndent()
+setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=endif,=endunless,=endifchanged,=endcase,=endfor,=endtablerow,=endcapture,=else,=elsif,=when,=empty
+
+" Only define the function once.
+if exists('*GetLiquidIndent')
+ finish
+endif
+
+function! s:count(string,pattern)
+ let string = substitute(a:string,'\C'.a:pattern,"\n",'g')
+ return strlen(substitute(string,"[^\n]",'','g'))
+endfunction
+
+function! GetLiquidIndent(...)
+ if a:0 && a:1 == '.'
+ let v:lnum = line('.')
+ elseif a:0 && a:1 =~ '^\d'
+ let v:lnum = a:1
+ endif
+ let vcol = col('.')
+ call cursor(v:lnum,1)
+ exe "let ind = ".b:liquid_subtype_indentexpr
+ let lnum = prevnonblank(v:lnum-1)
+ let line = getline(lnum)
+ let cline = getline(v:lnum)
+ let line = substitute(line,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','')
+ let line .= matchstr(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+')
+ let cline = substitute(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','')
+ let ind += &sw * s:count(line,'{%\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|tablerow\|capture\)\>')
+ let ind -= &sw * s:count(line,'{%\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>')
+ let ind += &sw * s:count(line,'{%\s*\%(elsif\|else\|when\|empty\)\>')
+ let ind -= &sw * s:count(cline,'{%\s*\%(elsif\|else\|when\|empty\)\>')
+ let ind -= &sw * s:count(cline,'{%\s*end\w*$')
+ return ind
+endfunction
diff --git a/runtime/indent/sass.vim b/runtime/indent/sass.vim
index 45ca50f68..4622f00ff 100644
--- a/runtime/indent/sass.vim
+++ b/runtime/indent/sass.vim
@@ -1,7 +1,7 @@
" Vim indent file
-" Language: SASS
-" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
-" Last Change: 2007 Dec 16
+" Language: Sass
+" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
+" Last Change: 2010 May 21
if exists("b:did_indent")
finish
@@ -17,7 +17,7 @@ if exists("*GetSassIndent")
finish
endif
-let s:property = '^\s*:\|^\s*[[:alnum:]-]\+:'
+let s:property = '^\s*:\|^\s*[[:alnum:]-]\+\%(:\|\s*=\)'
function! GetSassIndent()
let lnum = prevnonblank(v:lnum-1)