Update runtime files.
This commit is contained in:
@ -1,15 +1,73 @@
|
||||
" Vim indent file
|
||||
" Language: C#
|
||||
" Maintainer: Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change: Fri, 15 Mar 2002 07:53:54 CET
|
||||
" Language: C#
|
||||
" Maintainer: Nick Jensen <nickspoon@gmail.com>
|
||||
" Former Maintainers: Aquila Deus
|
||||
" Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change: 2018-11-21
|
||||
" Filenames: *.cs
|
||||
" License: Vim (see :h license)
|
||||
" Repository: https://github.com/nickspoons/vim-cs
|
||||
"
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
" C# is like indenting C
|
||||
setlocal cindent
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
let b:undo_indent = "setl cin<"
|
||||
|
||||
setlocal indentexpr=GetCSIndent(v:lnum)
|
||||
|
||||
function! s:IsCompilerDirective(line)
|
||||
return a:line =~? '^\s*#'
|
||||
endf
|
||||
|
||||
function! s:IsAttributeLine(line)
|
||||
return a:line =~? '^\s*\[[A-Za-z]' && a:line =~? '\]$'
|
||||
endf
|
||||
|
||||
function! s:FindPreviousNonCompilerDirectiveLine(start_lnum)
|
||||
for delta in range(0, a:start_lnum)
|
||||
let lnum = a:start_lnum - delta
|
||||
let line = getline(lnum)
|
||||
let is_directive = s:IsCompilerDirective(line)
|
||||
if !is_directive
|
||||
return lnum
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endf
|
||||
|
||||
function! GetCSIndent(lnum) abort
|
||||
" Hit the start of the file, use zero indent.
|
||||
if a:lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let this_line = getline(a:lnum)
|
||||
|
||||
" Compiler directives use zero indent if so configured.
|
||||
let is_first_col_macro = s:IsCompilerDirective(this_line) && stridx(&l:cinkeys, '0#') >= 0
|
||||
if is_first_col_macro
|
||||
return cindent(a:lnum)
|
||||
endif
|
||||
|
||||
let lnum = s:FindPreviousNonCompilerDirectiveLine(a:lnum - 1)
|
||||
let previous_code_line = getline(lnum)
|
||||
if s:IsAttributeLine(previous_code_line)
|
||||
let ind = indent(lnum)
|
||||
return ind
|
||||
else
|
||||
return cindent(a:lnum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let b:undo_indent = 'setlocal indentexpr<'
|
||||
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:et:sw=2:sts=2
|
||||
|
||||
@ -216,8 +216,9 @@ endfunc "}}}
|
||||
" Add known tag pairs.
|
||||
" Self-closing tags and tags that are sometimes {{{
|
||||
" self-closing (e.g., <p>) are not here (when encountering </p> we can find
|
||||
" the matching <p>, but not the other way around). Known self-closing tags:
|
||||
" 'p', 'img', 'source'.
|
||||
" the matching <p>, but not the other way around).
|
||||
" Known self-closing tags: " 'p', 'img', 'source', 'area', 'keygen', 'track',
|
||||
" 'wbr'.
|
||||
" Old HTML tags:
|
||||
call s:AddITags(s:indent_tags, [
|
||||
\ 'a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big',
|
||||
@ -232,11 +233,11 @@ call s:AddITags(s:indent_tags, [
|
||||
|
||||
" New HTML5 elements:
|
||||
call s:AddITags(s:indent_tags, [
|
||||
\ 'area', 'article', 'aside', 'audio', 'bdi', 'canvas',
|
||||
\ 'command', 'data', 'datalist', 'details', 'embed', 'figcaption',
|
||||
\ 'figure', 'footer', 'header', 'keygen', 'main', 'mark', 'meter',
|
||||
\ 'nav', 'output', 'picture', 'progress', 'rp', 'rt', 'ruby', 'section',
|
||||
\ 'summary', 'svg', 'time', 'track', 'video', 'wbr'])
|
||||
\ 'article', 'aside', 'audio', 'bdi', 'canvas', 'command', 'data',
|
||||
\ 'datalist', 'details', 'dialog', 'embed', 'figcaption', 'figure',
|
||||
\ 'footer', 'header', 'hgroup', 'main', 'mark', 'meter', 'nav', 'output',
|
||||
\ 'picture', 'progress', 'rp', 'rt', 'ruby', 'section', 'summary',
|
||||
\ 'svg', 'time', 'video'])
|
||||
|
||||
" Tags added for web components:
|
||||
call s:AddITags(s:indent_tags, [
|
||||
@ -934,7 +935,7 @@ func! s:InsideTag(foundHtmlString)
|
||||
let idx = match(text, '<' . s:tagname . '\s\+\zs\w')
|
||||
endif
|
||||
if idx == -1
|
||||
" after just <tag indent one level more
|
||||
" after just "<tag" indent one level more
|
||||
let idx = match(text, '<' . s:tagname . '$')
|
||||
if idx >= 0
|
||||
call cursor(lnum, idx)
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
" Vim indent file
|
||||
" Language: Tcl
|
||||
" Maintainer: Nikolai Weibull <now@bitwi.se>
|
||||
" Latest Revision: 2006-12-20
|
||||
" Language: Tcl
|
||||
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
||||
" Latest Update: Chris Heithoff <chrisheithoff@gmail.com>
|
||||
" Latest Revision: 2018-12-05
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
@ -28,6 +29,15 @@ function s:prevnonblanknoncomment(lnum)
|
||||
return lnum
|
||||
endfunction
|
||||
|
||||
function s:ends_with_backslash(lnum)
|
||||
let line = getline(a:lnum)
|
||||
if line =~ '\\\s*$'
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function s:count_braces(lnum, count_open)
|
||||
let n_open = 0
|
||||
let n_close = 0
|
||||
@ -53,23 +63,39 @@ endfunction
|
||||
|
||||
function GetTclIndent()
|
||||
let line = getline(v:lnum)
|
||||
if line =~ '^\s*\*'
|
||||
return cindent(v:lnum)
|
||||
elseif line =~ '^\s*}'
|
||||
return indent(v:lnum) - shiftwidth()
|
||||
endif
|
||||
|
||||
" Get the line number of the previous non-blank or non-comment line.
|
||||
let pnum = s:prevnonblanknoncomment(v:lnum - 1)
|
||||
if pnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(pnum) + s:count_braces(pnum, 1) * shiftwidth()
|
||||
" ..and the previous line before the previous line.
|
||||
let pnum2 = s:prevnonblanknoncomment(pnum-1)
|
||||
|
||||
let pline = getline(pnum)
|
||||
if pline =~ '}\s*$'
|
||||
let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * shiftwidth()
|
||||
" Default indentation is to preserve the previous indentation.
|
||||
let ind = indent(pnum)
|
||||
|
||||
" ...but if previous line introduces an open brace, then increase current line's indentation
|
||||
if s:count_braces(pnum, 1) > 0
|
||||
let ind += shiftwidth()
|
||||
else
|
||||
" Look for backslash line continuation on the previous two lines.
|
||||
let slash1 = s:ends_with_backslash(pnum)
|
||||
let slash2 = s:ends_with_backslash(pnum2)
|
||||
if slash1 && !slash2
|
||||
" If the previous line begins a line continuation.
|
||||
let ind += shiftwidth()
|
||||
elseif !slash1 && slash2
|
||||
" If two lines ago was the end of a line continuation group of lines.
|
||||
let ind -= shiftwidth()
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the current line begins with a closed brace, then decrease the indentation by one.
|
||||
if line =~ '^\s*}'
|
||||
let ind -= shiftwidth()
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
|
||||
26
runtime/indent/testdir/html.in
Normal file
26
runtime/indent/testdir/html.in
Normal file
@ -0,0 +1,26 @@
|
||||
" vim: set ft=html sw=4 :
|
||||
|
||||
|
||||
" START_INDENT
|
||||
<div>
|
||||
<div>
|
||||
text
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="foo bar">
|
||||
text
|
||||
</div>
|
||||
|
||||
<div class="foo bar"
|
||||
data="something">
|
||||
text
|
||||
</div>
|
||||
|
||||
<div class="foo
|
||||
bar">
|
||||
text
|
||||
</div>
|
||||
|
||||
" END_INDENT
|
||||
26
runtime/indent/testdir/html.ok
Normal file
26
runtime/indent/testdir/html.ok
Normal file
@ -0,0 +1,26 @@
|
||||
" vim: set ft=html sw=4 :
|
||||
|
||||
|
||||
" START_INDENT
|
||||
<div>
|
||||
<div>
|
||||
text
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="foo bar">
|
||||
text
|
||||
</div>
|
||||
|
||||
<div class="foo bar"
|
||||
data="something">
|
||||
text
|
||||
</div>
|
||||
|
||||
<div class="foo
|
||||
bar">
|
||||
text
|
||||
</div>
|
||||
|
||||
" END_INDENT
|
||||
19
runtime/indent/testdir/tcl.in
Normal file
19
runtime/indent/testdir/tcl.in
Normal file
@ -0,0 +1,19 @@
|
||||
# vim: set filetype=tcl shiftwidth=4 tabstop=4:
|
||||
|
||||
# START_INDENT
|
||||
proc abc {} {
|
||||
set a 5
|
||||
if {[some_cmd]==1} {
|
||||
foreach i [list {1 2 3}] {
|
||||
# Does this comment affect anything?
|
||||
puts $i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command_with_a_long_time -arg1 "First" \
|
||||
-arg2 "Second" \
|
||||
-arg3 "Third"
|
||||
|
||||
puts "Move indent back after line continuation is complete"
|
||||
# END_INDENT
|
||||
19
runtime/indent/testdir/tcl.ok
Normal file
19
runtime/indent/testdir/tcl.ok
Normal file
@ -0,0 +1,19 @@
|
||||
# vim: set filetype=tcl shiftwidth=4 tabstop=4:
|
||||
|
||||
# START_INDENT
|
||||
proc abc {} {
|
||||
set a 5
|
||||
if {[some_cmd]==1} {
|
||||
foreach i [list {1 2 3}] {
|
||||
# Does this comment affect anything?
|
||||
puts $i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command_with_a_long_time -arg1 "First" \
|
||||
-arg2 "Second" \
|
||||
-arg3 "Third"
|
||||
|
||||
puts "Move indent back after line continuation is complete"
|
||||
# END_INDENT
|
||||
32
runtime/indent/testdir/xml.in
Normal file
32
runtime/indent/testdir/xml.in
Normal file
@ -0,0 +1,32 @@
|
||||
<!-- vim: set ft=xml ts=2 sw=0 sts=-1 et : -->
|
||||
<!-- START_INDENT -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tag0>
|
||||
<tag1>
|
||||
<!-- comment -->
|
||||
<tag2>
|
||||
<tag3/>
|
||||
</tag2>
|
||||
<!-- text comment -->
|
||||
|
||||
<!--
|
||||
text comment
|
||||
-->
|
||||
</tag1>
|
||||
<!--
|
||||
text comment
|
||||
end coment -->
|
||||
</tag0>
|
||||
<!-- END_INDENT -->
|
||||
|
||||
<!-- START_INDENT -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tag0>
|
||||
<tag1>
|
||||
<!-- comment -->
|
||||
<tag2>
|
||||
<tag3/>
|
||||
</tag2>
|
||||
</tag1>
|
||||
</tag0>
|
||||
<!-- END_INDENT -->
|
||||
32
runtime/indent/testdir/xml.ok
Normal file
32
runtime/indent/testdir/xml.ok
Normal file
@ -0,0 +1,32 @@
|
||||
<!-- vim: set ft=xml ts=2 sw=0 sts=-1 et : -->
|
||||
<!-- START_INDENT -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tag0>
|
||||
<tag1>
|
||||
<!-- comment -->
|
||||
<tag2>
|
||||
<tag3/>
|
||||
</tag2>
|
||||
<!-- text comment -->
|
||||
|
||||
<!--
|
||||
text comment
|
||||
-->
|
||||
</tag1>
|
||||
<!--
|
||||
text comment
|
||||
end coment -->
|
||||
</tag0>
|
||||
<!-- END_INDENT -->
|
||||
|
||||
<!-- START_INDENT -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tag0>
|
||||
<tag1>
|
||||
<!-- comment -->
|
||||
<tag2>
|
||||
<tag3/>
|
||||
</tag2>
|
||||
</tag1>
|
||||
</tag0>
|
||||
<!-- END_INDENT -->
|
||||
Reference in New Issue
Block a user