diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2019-08-01 22:45:59 +0200 |
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2019-08-01 22:48:28 +0200 |
| commit | 2cdbbe50a4a695004adce50d7502869bb2410928 (patch) | |
| tree | b85ddd40c86b73c3bbf748c923b744a7a89e3716 /runtime/indent | |
| parent | 41fe644124140c4a303de4a5a84e28efec918274 (diff) | |
| download | rneovim-2cdbbe50a4a695004adce50d7502869bb2410928.tar.gz rneovim-2cdbbe50a4a695004adce50d7502869bb2410928.tar.bz2 rneovim-2cdbbe50a4a695004adce50d7502869bb2410928.zip | |
vim-patch:63b74a8362b1
Update runtime files.
https://github.com/vim/vim/commit/63b74a8362b14576b21d342dc424d0396ca8ea27
Diffstat (limited to 'runtime/indent')
| -rw-r--r-- | runtime/indent/cobol.vim | 11 | ||||
| -rw-r--r-- | runtime/indent/html.vim | 11 | ||||
| -rw-r--r-- | runtime/indent/sh.vim | 4 | ||||
| -rw-r--r-- | runtime/indent/testdir/html.ok | 6 | ||||
| -rw-r--r-- | runtime/indent/testdir/xml.ok | 4 | ||||
| -rw-r--r-- | runtime/indent/xml.vim | 63 |
6 files changed, 71 insertions, 28 deletions
diff --git a/runtime/indent/cobol.vim b/runtime/indent/cobol.vim index c08444ac40..590a729df4 100644 --- a/runtime/indent/cobol.vim +++ b/runtime/indent/cobol.vim @@ -1,7 +1,12 @@ " Vim indent file " Language: cobol -" Author: Tim Pope <vimNOSPAM@tpope.info> +" Maintainer: Ankit Jain <ajatkj@yahoo.co.in> +" (formerly Tim Pope <vimNOSPAM@tpope.info>) " $Id: cobol.vim,v 1.1 2007/05/05 18:08:19 vimboss Exp $ +" Last Update: By Ankit Jain on 22.03.2019 +" Ankit Jain 22.03.2019 Changes & fixes: +" Allow chars in 1st 6 columns +" #C22032019 if exists("b:did_indent") finish @@ -66,7 +71,9 @@ function! GetCobolIndent(lnum) abort let ashft = minshft + 1 let bshft = ashft + 4 " (Obsolete) numbered lines - if getline(a:lnum) =~? '^\s*\d\{6\}\%($\|[ */$CD-]\)' + " #C22032019: Columns 1-6 could have alphabets as well as numbers + "if getline(a:lnum) =~? '^\s*\d\{6\}\%($\|[ */$CD-]\)' + if getline(a:lnum) =~? '^\s*[a-zA-Z0-9]\{6\}\%($\|[ */$CD-]\)' return 0 endif let cline = s:stripped(a:lnum) diff --git a/runtime/indent/html.vim b/runtime/indent/html.vim index 1a8177050a..1d2043ae9e 100644 --- a/runtime/indent/html.vim +++ b/runtime/indent/html.vim @@ -2,7 +2,7 @@ " Header: "{{{ " Maintainer: Bram Moolenaar " Original Author: Andy Wokula <anwoku@yahoo.de> -" Last Change: 2018 Mar 28 +" Last Change: 2019 Mar 20 " Version: 1.0 " Description: HTML indent script with cached state for faster indenting on a " range of lines. @@ -902,12 +902,19 @@ func! s:InsideTag(foundHtmlString) "{{{ if a:foundHtmlString " Inside an attribute string. - " Align with the previous line or use an external function. + " Align with the opening quote or use an external function. let lnum = v:lnum - 1 if lnum > 1 if exists('b:html_indent_tag_string_func') return b:html_indent_tag_string_func(lnum) endif + " If there is a double quote in the previous line, indent with the + " character after it. + if getline(lnum) =~ '"' + call cursor(lnum, 0) + normal f" + return virtcol('.') + endif return indent(lnum) endif endif diff --git a/runtime/indent/sh.vim b/runtime/indent/sh.vim index c93be31958..0396b4eb94 100644 --- a/runtime/indent/sh.vim +++ b/runtime/indent/sh.vim @@ -7,6 +7,8 @@ " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-sh-indent " Changelog: +" 20190316 - Make use of searchpairpos for nested if sections +" fixes #11 " 20190201 - Better check for closing if sections " 20180724 - make check for zsh syntax more rigid (needs word-boundaries) " 20180326 - better support for line continuation @@ -115,7 +117,7 @@ function! GetShIndent() " Current line is a endif line, so get indent from start of "if condition" line " TODO: should we do the same for other "end" lines? if curline =~ '^\s*\%(fi\)\s*\%(#.*\)\=$' - let previous_line = search('if.\{-\};\s*then\s*\%(#.*\)\=$', 'bnW') + let previous_line = searchpair('\<if\>', '', '\<fi\>', 'bnW') if previous_line > 0 let ind = indent(previous_line) endif diff --git a/runtime/indent/testdir/html.ok b/runtime/indent/testdir/html.ok index 524d57bb6c..ad819333cc 100644 --- a/runtime/indent/testdir/html.ok +++ b/runtime/indent/testdir/html.ok @@ -9,17 +9,17 @@ </div> <div - class="foo bar"> + class="foo bar"> text </div> <div class="foo bar" - data="something"> + data="something"> text </div> <div class="foo - bar"> + bar"> text </div> diff --git a/runtime/indent/testdir/xml.ok b/runtime/indent/testdir/xml.ok index 529198572a..cfdf701c11 100644 --- a/runtime/indent/testdir/xml.ok +++ b/runtime/indent/testdir/xml.ok @@ -10,11 +10,11 @@ <!-- text comment --> <!-- - text comment + text comment --> </tag1> <!-- - text comment + text comment end coment --> </tag0> <!-- END_INDENT --> diff --git a/runtime/indent/xml.vim b/runtime/indent/xml.vim index 29069bab84..ad22de1d50 100644 --- a/runtime/indent/xml.vim +++ b/runtime/indent/xml.vim @@ -1,9 +1,11 @@ " Language: xml " Repository: https://github.com/chrisbra/vim-xml-ftplugin -" Last Changed: Jan 28, 2019 +" Last Changed: Feb 04, 2019 " Maintainer: Christian Brabandt <cb@256bit.org> " Previous Maintainer: Johannes Zellner <johannes@zellner.org> " Last Change: +" 20190204 - correctly handle wrap tags +" https://github.com/chrisbra/vim-xml-ftplugin/issues/5 " 20190128 - Make sure to find previous tag " https://github.com/chrisbra/vim-xml-ftplugin/issues/4 " 20181116 - Fix indentation when tags start with a colon or an underscore @@ -74,13 +76,20 @@ fun! <SID>XmlIndentSynCheck(lnum) endfun " [-- return the sum of indents of a:lnum --] -fun! <SID>XmlIndentSum(lnum, style, add) - let line = getline(a:lnum) - if a:style == match(line, '^\s*</') +fun! <SID>XmlIndentSum(line, style, add) + if <SID>IsXMLContinuation(a:line) && a:style == 0 + " no complete tag, add one additional indent level + " but only for the current line + return a:add + shiftwidth() + elseif <SID>HasNoTagEnd(a:line) + " no complete tag, return initial indent + return a:add + endif + if a:style == match(a:line, '^\s*</') return (shiftwidth() * - \ (<SID>XmlIndentWithPattern(line, b:xml_indent_open) - \ - <SID>XmlIndentWithPattern(line, b:xml_indent_close) - \ - <SID>XmlIndentWithPattern(line, '.\{-}/>'))) + a:add + \ (<SID>XmlIndentWithPattern(a:line, b:xml_indent_open) + \ - <SID>XmlIndentWithPattern(a:line, b:xml_indent_close) + \ - <SID>XmlIndentWithPattern(a:line, '.\{-}/>'))) + a:add else return a:add endif @@ -89,19 +98,24 @@ endfun " Main indent function fun! XmlIndentGet(lnum, use_syntax_check) " Find a non-empty line above the current line. - let plnum = prevnonblank(a:lnum - 1) - " Hit the start of the file, use zero indent. - if plnum == 0 + if prevnonblank(a:lnum - 1) == 0 + " Hit the start of the file, use zero indent. return 0 endif " Find previous line with a tag (regardless whether open or closed, " but always start restrict the match to a line before the current one + " Note: xml declaration: <?xml version="1.0"?> + " won't be found, as it is not a legal tag name let ptag_pattern = '\%(.\{-}<[/:A-Z_a-z]\)'. '\%(\&\%<'. line('.').'l\)' - let ptag = search(ptag_pattern, 'bnw') + let ptag = search(ptag_pattern, 'bnW') + " no previous tag + if ptag == 0 + return 0 + endif let syn_name = '' if a:use_syntax_check - let check_lnum = <SID>XmlIndentSynCheck(plnum) + let check_lnum = <SID>XmlIndentSynCheck(ptag) let check_alnum = <SID>XmlIndentSynCheck(a:lnum) if check_lnum == 0 || check_alnum == 0 return indent(a:lnum) @@ -113,18 +127,31 @@ fun! XmlIndentGet(lnum, use_syntax_check) return <SID>XmlIndentComment(a:lnum) endif + let pline = getline(ptag) + let pind = indent(ptag) " Get indent from previous tag line - let ind = <SID>XmlIndentSum(ptag, -1, indent(ptag)) + let ind = <SID>XmlIndentSum(pline, -1, pind) + let t_ind = ind " Determine indent from current line - let ind = <SID>XmlIndentSum(a:lnum, 0, ind) + let ind = <SID>XmlIndentSum(getline(a:lnum), 0, ind) return ind endfun +func! <SID>IsXMLContinuation(line) + " Checks, whether or not the line matches a start-of-tag + return a:line !~ '^\s*<' +endfunc + +func! <SID>HasNoTagEnd(line) + " Checks whether or not the line matches '>' (so finishes a tag) + return a:line !~ '>\s*$' +endfunc + " return indent for a commented line, " the middle part might be indented on additional level func! <SID>XmlIndentComment(lnum) - let ptagopen = search(b:xml_indent_open, 'bnw') - let ptagclose = search(b:xml_indent_close, 'bnw') + let ptagopen = search(b:xml_indent_open, 'bnW') + let ptagclose = search(b:xml_indent_close, 'bnW') if getline(a:lnum) =~ '<!--' " if previous tag was a closing tag, do not add " one additional level of indent @@ -136,10 +163,10 @@ func! <SID>XmlIndentComment(lnum) endif elseif getline(a:lnum) =~ '-->' " end of comment, same as start of comment - return indent(search('<!--', 'bnw')) + return indent(search('<!--', 'bnW')) else " middle part of comment, add one additional level - return indent(search('<!--', 'bnw')) + shiftwidth() + return indent(search('<!--', 'bnW')) + shiftwidth() endif endfunc |