Update runtime files.
Includes changing &sw to shiftwidth() for all indent scripts.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
" Header: "{{{
|
||||
" Maintainer: Bram Moolenaar
|
||||
" Original Author: Andy Wokula <anwoku@yahoo.de>
|
||||
" Last Change: 2017 Jan 17
|
||||
" Last Change: 2017 Jun 13
|
||||
" Version: 1.0
|
||||
" Description: HTML indent script with cached state for faster indenting on a
|
||||
" range of lines.
|
||||
@ -51,15 +51,6 @@ if exists("*HtmlIndent") && !exists('g:force_reload_html')
|
||||
finish
|
||||
endif
|
||||
|
||||
" shiftwidth() exists since patch 7.3.694
|
||||
if exists('*shiftwidth')
|
||||
let s:ShiftWidth = function('shiftwidth')
|
||||
else
|
||||
func! s:ShiftWidth()
|
||||
return &shiftwidth
|
||||
endfunc
|
||||
endif
|
||||
|
||||
" Allow for line continuation below.
|
||||
let s:cpo_save = &cpo
|
||||
set cpo-=C
|
||||
@ -123,7 +114,7 @@ func! HtmlIndent_CheckUserSettings()
|
||||
|
||||
let indone = {"zero": 0
|
||||
\,"auto": "indent(prevnonblank(v:lnum-1))"
|
||||
\,"inc": "b:hi_indent.blocktagind + s:ShiftWidth()"}
|
||||
\,"inc": "b:hi_indent.blocktagind + shiftwidth()"}
|
||||
|
||||
let script1 = ''
|
||||
if exists("b:html_indent_script1")
|
||||
@ -358,7 +349,7 @@ func! s:CheckBlockTag(blocktag, ind)
|
||||
endif
|
||||
let b:hi_newstate.blocklnr = v:lnum
|
||||
" save allover indent for the endtag
|
||||
let b:hi_newstate.blocktagind = b:hi_indent.baseindent + (s:nextrel + s:curind) * s:ShiftWidth()
|
||||
let b:hi_newstate.blocktagind = b:hi_indent.baseindent + (s:nextrel + s:curind) * shiftwidth()
|
||||
if a:ind == 3
|
||||
return "SCRIPT" " all except this must be lowercase
|
||||
" line is to be checked again for the type attribute
|
||||
@ -480,7 +471,7 @@ func! s:FreshState(lnum)
|
||||
let state.blocklnr = stopline
|
||||
" check preceding tags in the line:
|
||||
call s:CountITags(tagline[: stopcol-2])
|
||||
let state.blocktagind = indent(stopline) + (s:curind + s:nextrel) * s:ShiftWidth()
|
||||
let state.blocktagind = indent(stopline) + (s:curind + s:nextrel) * shiftwidth()
|
||||
return state
|
||||
elseif stopline == state.lnum
|
||||
" handle special case: previous line (= state.lnum) contains a
|
||||
@ -490,7 +481,7 @@ func! s:FreshState(lnum)
|
||||
if !swendtag
|
||||
let [bline, bcol] = searchpos('<'.blocktag[1:].'\>', "bnW")
|
||||
call s:CountITags(tolower(getline(bline)[: bcol-2]))
|
||||
let state.baseindent = indent(bline) + (s:curind + s:nextrel) * s:ShiftWidth()
|
||||
let state.baseindent = indent(bline) + (s:curind + s:nextrel) * shiftwidth()
|
||||
return state
|
||||
endif
|
||||
endif
|
||||
@ -511,7 +502,7 @@ func! s:FreshState(lnum)
|
||||
if found == 2
|
||||
let state.baseindent = b:hi_indent.baseindent
|
||||
endif
|
||||
let state.blocktagind = indent(comlnum) + (s:curind + s:nextrel) * s:ShiftWidth()
|
||||
let state.blocktagind = indent(comlnum) + (s:curind + s:nextrel) * shiftwidth()
|
||||
return state
|
||||
endif
|
||||
|
||||
@ -530,7 +521,7 @@ func! s:FreshState(lnum)
|
||||
let text = tolower(getline(comlnum)[: comcol-2])
|
||||
endif
|
||||
call s:CountITags(text)
|
||||
let state.baseindent = indent(comlnum) + (s:curind + s:nextrel) * s:ShiftWidth()
|
||||
let state.baseindent = indent(comlnum) + (s:curind + s:nextrel) * shiftwidth()
|
||||
" TODO check tags that follow "-->"
|
||||
return state
|
||||
endif
|
||||
@ -550,9 +541,9 @@ func! s:FreshState(lnum)
|
||||
let text = getline(start_lnum)
|
||||
let swendtag = match(text, '^\s*</') >= 0
|
||||
call s:CountITags(text[: col('.') - 2])
|
||||
let state.baseindent += s:nextrel * s:ShiftWidth()
|
||||
let state.baseindent += s:nextrel * shiftwidth()
|
||||
if !swendtag
|
||||
let state.baseindent += s:curind * s:ShiftWidth()
|
||||
let state.baseindent += s:curind * shiftwidth()
|
||||
endif
|
||||
endif
|
||||
return state
|
||||
@ -565,9 +556,9 @@ func! s:FreshState(lnum)
|
||||
let text = getline(state.lnum)
|
||||
let swendtag = match(text, '^\s*</') >= 0
|
||||
call s:CountITags(tolower(text))
|
||||
let state.baseindent = indent(state.lnum) + s:nextrel * s:ShiftWidth()
|
||||
let state.baseindent = indent(state.lnum) + s:nextrel * shiftwidth()
|
||||
if !swendtag
|
||||
let state.baseindent += s:curind * s:ShiftWidth()
|
||||
let state.baseindent += s:curind * shiftwidth()
|
||||
endif
|
||||
return state
|
||||
endfunc "}}}
|
||||
@ -646,7 +637,7 @@ func! s:CSSIndent()
|
||||
|
||||
" add indent after {
|
||||
let brace_counts = HtmlIndent_CountBraces(prev_lnum)
|
||||
let extra = brace_counts.c_open * s:ShiftWidth()
|
||||
let extra = brace_counts.c_open * shiftwidth()
|
||||
|
||||
let prev_text = getline(prev_lnum)
|
||||
let below_end_brace = prev_text =~ '}\s*$'
|
||||
@ -663,7 +654,7 @@ func! s:CSSIndent()
|
||||
" if the current line is not a comment or starts with @ (used by template
|
||||
" systems) reduce indent if previous line is a continuation line
|
||||
if !prev_hasfield && !prev_special
|
||||
let extra = -s:ShiftWidth()
|
||||
let extra = -shiftwidth()
|
||||
endif
|
||||
else
|
||||
let cur_hasfield = curtext =~ '^\s*[a-zA-Z0-9-]\+:'
|
||||
@ -671,14 +662,14 @@ func! s:CSSIndent()
|
||||
if !cur_hasfield && (prev_hasfield || prev_unfinished)
|
||||
" Continuation line has extra indent if the previous line was not a
|
||||
" continuation line.
|
||||
let extra = s:ShiftWidth()
|
||||
let extra = shiftwidth()
|
||||
" Align with @if
|
||||
if prev_text =~ '^\s*@if '
|
||||
let extra = 4
|
||||
endif
|
||||
elseif cur_hasfield && !prev_hasfield && !prev_special
|
||||
" less indent below a continuation line
|
||||
let extra = -s:ShiftWidth()
|
||||
let extra = -shiftwidth()
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@ -699,10 +690,10 @@ func! s:CSSIndent()
|
||||
if special
|
||||
" do not reduce indent below @{ ... }
|
||||
if extra < 0
|
||||
let extra += s:ShiftWidth()
|
||||
let extra += shiftwidth()
|
||||
endif
|
||||
else
|
||||
let extra -= (brace_counts.c_close - (prev_text =~ '^\s*}')) * s:ShiftWidth()
|
||||
let extra -= (brace_counts.c_close - (prev_text =~ '^\s*}')) * shiftwidth()
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -710,10 +701,10 @@ func! s:CSSIndent()
|
||||
if extra == 0
|
||||
if brace_counts.p_open > brace_counts.p_close
|
||||
" previous line has more ( than ): add a shiftwidth
|
||||
let extra = s:ShiftWidth()
|
||||
let extra = shiftwidth()
|
||||
elseif brace_counts.p_open < brace_counts.p_close
|
||||
" previous line has more ) than (: subtract a shiftwidth
|
||||
let extra = -s:ShiftWidth()
|
||||
let extra = -shiftwidth()
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -816,7 +807,7 @@ func! s:Alien5()
|
||||
let idx = match(prevtext, '^\s*\zs<!--')
|
||||
if idx >= 0
|
||||
" just below comment start, add a shiftwidth
|
||||
return idx + s:ShiftWidth()
|
||||
return idx + shiftwidth()
|
||||
endif
|
||||
|
||||
" Some files add 4 spaces just below a TODO line. It's difficult to detect
|
||||
@ -837,7 +828,7 @@ func! s:Alien6()
|
||||
return indent(lnum)
|
||||
endif
|
||||
endif
|
||||
return b:hi_indent.baseindent + s:ShiftWidth()
|
||||
return b:hi_indent.baseindent + shiftwidth()
|
||||
endfunc "}}}
|
||||
|
||||
" When the "lnum" line ends in ">" find the line containing the matching "<".
|
||||
@ -947,7 +938,7 @@ func! HtmlIndent()
|
||||
endif
|
||||
|
||||
let curtext = tolower(getline(v:lnum))
|
||||
let indentunit = s:ShiftWidth()
|
||||
let indentunit = shiftwidth()
|
||||
|
||||
let b:hi_newstate = {}
|
||||
let b:hi_newstate.lnum = v:lnum
|
||||
@ -1030,9 +1021,9 @@ func! HtmlIndent()
|
||||
if col('.') > 2
|
||||
let swendtag = match(text, '^\s*</') >= 0
|
||||
call s:CountITags(text[: col('.') - 2])
|
||||
let indent += s:nextrel * s:ShiftWidth()
|
||||
let indent += s:nextrel * shiftwidth()
|
||||
if !swendtag
|
||||
let indent += s:curind * s:ShiftWidth()
|
||||
let indent += s:curind * shiftwidth()
|
||||
endif
|
||||
endif
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user