summaryrefslogtreecommitdiffstats
path: root/indent
diff options
context:
space:
mode:
Diffstat (limited to 'indent')
-rw-r--r--indent/html.vim4
-rw-r--r--indent/less.vim32
2 files changed, 34 insertions, 2 deletions
diff --git a/indent/html.vim b/indent/html.vim
index 466c6bd8..1c34cf68 100644
--- a/indent/html.vim
+++ b/indent/html.vim
@@ -130,12 +130,14 @@ call add(s:tags, 'rt')
call add(s:tags, 'ruby')
call add(s:tags, 'section')
call add(s:tags, 'summary')
-call add(s:tags, 'template')
call add(s:tags, 'time')
call add(s:tags, 'video')
call add(s:tags, 'bdi')
call add(s:tags, 'data')
+" Web Component
+call add(s:tags, 'template')
+
" Common inline used SVG elements
call add(s:tags, 'clipPath')
call add(s:tags, 'defs')
diff --git a/indent/less.vim b/indent/less.vim
index fea8846d..6161c93c 100644
--- a/indent/less.vim
+++ b/indent/less.vim
@@ -6,6 +6,36 @@
if exists("b:did_indent")
finish
endif
+let b:did_indent = 1
+
+setlocal autoindent sw=2 et
+setlocal indentexpr=GetLessIndent()
+setlocal indentkeys=o,O,*<Return>,<:>,!^F
+
+" Only define the function once.
+if exists("*GetLessIndent")
+ finish
+endif
+
+let s:property = '^\s*:\|^\s*[[:alnum:]#{}-]\+\%(:\|\s*=\)'
+
+function! GetLessIndent()
+ let lnum = prevnonblank(v:lnum-1)
+ let line = substitute(getline(lnum),'\s\+$','','')
+ let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
+ let lastcol = strlen(line)
+ let line = substitute(line,'^\s\+','','')
+ let indent = indent(lnum)
+ let cindent = indent(v:lnum)
+ if line !~ s:property && cline =~ s:property
+ return indent + &sw
+ "elseif line =~ s:property && cline !~ s:property
+ "return indent - &sw
+ else
+ return -1
+ endif
+endfunction
+
+" vim:set sw=2:
-runtime! indent/css.vim