# HG changeset patch # User Christian Brabandt # Date 1497370504 -7200 # Node ID 63b0b7b79b25b34bf033c82d71260d5582b6687b # Parent 01330ca5f7f8732a82263c59c4cf7e8edd9c6c72 Update runtime files. commit https://github.com/vim/vim/commit/3ec574f2b549f456f664f689d6da36dc5719aeb9 Author: Bram Moolenaar Date: Tue Jun 13 18:12:01 2017 +0200 Update runtime files. Includes changing &sw to shiftwidth() for all indent scripts. diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt --- a/runtime/doc/channel.txt +++ b/runtime/doc/channel.txt @@ -1,4 +1,4 @@ -*channel.txt* For Vim version 8.0. Last change: 2016 Dec 02 +*channel.txt* For Vim version 8.0. Last change: 2017 Jun 11 VIM REFERENCE MANUAL by Bram Moolenaar @@ -489,6 +489,11 @@ If you want to handle both stderr and st "callback" option: > let job = job_start(command, {"callback": "MyHandler"}) +Depending on the system, starting a job can put Vim in the background, the +started job gets the focus. To avoid that, use the `foreground()` function. +This might not always work when called early, put in the callback handler or +use a timer to call it after the job has started. + You can send a message to the command with ch_evalraw(). If the channel is in JSON or JS mode you can use ch_evalexpr(). diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.0. Last change: 2017 Jun 05 +*eval.txt* For Vim version 8.0. Last change: 2017 Jun 13 VIM REFERENCE MANUAL by Bram Moolenaar @@ -5465,7 +5465,10 @@ line({expr}) The result is a Number, whi < *last-position-jump* This autocommand jumps to the last known position in a file just after opening it, if the '" mark is set: > - :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + :au BufReadPost * + \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' + \ | exe "normal! g`\"" + \ | endif line2byte({lnum}) *line2byte()* Return the byte count from the start of the buffer for line diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -1,4 +1,4 @@ -*pattern.txt* For Vim version 8.0. Last change: 2017 Mar 29 +*pattern.txt* For Vim version 8.0. Last change: 2017 Jun 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1076,12 +1076,16 @@ x A single character, with no special me ":s/[/x/" searches for "[/x" and replaces it with nothing. It does not search for "[" and replaces it with "x"! + *E944* *E945* If the sequence begins with "^", it matches any single character NOT in the collection: "[^xyz]" matches anything but 'x', 'y' and 'z'. - If two characters in the sequence are separated by '-', this is shorthand for the full list of ASCII characters between them. E.g., - "[0-9]" matches any decimal digit. Non-ASCII characters can be - used, but the character values must not be more than 256 apart. + "[0-9]" matches any decimal digit. If the starting character exceeds + the ending character, e.g. [c-a], E944 occurs. Non-ASCII characters + can be used, but the character values must not be more than 256 apart + in the old regexp engine. For example, searching by [\u3000-\u4000] + after setting re=1 emits a E945 error. Prepending \%#=2 will fix it. - A character class expression is evaluated to the set of characters belonging to that character class. The following character classes are supported: diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -4519,6 +4519,8 @@ E940 eval.txt /*E940* E941 eval.txt /*E941* E942 eval.txt /*E942* E943 message.txt /*E943* +E944 pattern.txt /*E944* +E945 pattern.txt /*E945* E95 message.txt /*E95* E96 diff.txt /*E96* E97 diff.txt /*E97* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 8.0. Last change: 2017 Jun 05 +*todo.txt* For Vim version 8.0. Last change: 2017 Jun 13 VIM REFERENCE MANUAL by Bram Moolenaar @@ -113,6 +113,7 @@ With foldmethod=syntax and nofoldenable (Marcin Szewczyk, 2017 Apr 26) ml_get error when using a Python. (Yggdroot, 2017 Jun 1, #1737) +Lemonboy can reproduce (2017 Jun 5) ml_get errors with buggy script. (Dominique, 2017 Apr 30) @@ -144,15 +145,9 @@ Openhab syntax file (mueller, #1678) Use gvimext.dll from the nightly build? (Issue #249) -Patch to remove HAVE_GTK_MULTIHEAD-relevant code. (Kazunobu Kuriyama, 2017 May -5) Update May 11 - 'synmaxcol' works with bytes instead of screen cells. (Llandon, 2017 May 31, #1736) -Patch to pass quickfix list index to functions. (Yegappan Lakshmanan, 2017 May -31) - Problem with using :cd when remotely editing a file. (Gerd Wachsmuth, 2017 May 8, #1690) @@ -168,16 +163,6 @@ manager. Problem with Motif? Bogus characters inserted when triggering indent while changing text. (Vitor Antunes, 2016 Nov 22, #1269) -Patch to have ":stag" respect 'switchbuf'. (Ingo Karkat, 2017 May 5, #1681) - -Patch to improve building with MSVC. (Leonardo Manera, #1747) - -Wrong selection of quoted text (Guraga, #1687) -Patch to fix selection of quoted text. (Christian Brabandt, 2017 May 7, #1687) - -Patch to use separate error message for regex range. (Itchyny, Ken Hamada, -2017 May 16) - Segmentation fault with complete(). (Lifepillar, 2017 Apr 29, #1668) Check for "pat" to be NULL in search_for_exact_line()? How did it get NULL? Comment by Christian, Apr 30. @@ -185,18 +170,8 @@ How did it get NULL? Comment by Christi Is it possible to keep the complete menu open when calling complete()? (Prabir Shrestha, 2017 May 19, #1713) -Calling may_req_ambiguous_char_width() and may_req_bg_color() only after -executing command line commands may not work properly. -(Rastislav Barlink, 2017 May 18) -Set "starting" to 0 earlier, and move the may_req calls above exe_commands()? -No, that's a problem with using "-c quit", not running Vim interactive. - Memory leak in test97? The string is actually freed. Weird. -Patch for shellescape(). (Christian Brabandt, 2017 Apr 20, #1590) - -Patch for flickering redraw. (Hirohito Higashi, 2017 Apr 23, #1637) - New value "uselast" for 'switchbuf'. (Lemonboy, 2017 Apr 23, #1652) Add a toolbar in the terminal. Can be global, above all windows, or specific @@ -212,18 +187,6 @@ Perhaps simpler: actually delete the map mappings (with a lhs prefix, like maparg()), mapdelete() to delete, maprestore() to restore (using the output of maplist(). -Patch to support chinese wordcount in utf-8. (Rain, 2017 May 24, #1722) -Or not? - -"gn" selects one character instead of the searched text. (keyboardfire, #1683) -Patch by Christian, 2017 May 7. - -Wrong memory access using p_fdm, found in patch to add tests for diff mode -(#1658) (Dominique Pelle, 2017 May 6) - -Patch to improve test coverage for diff mode. (Dominique Pelle, 2017 May 11, -#1685) - Add an argument to :mkvimrc (or add aother command) to skip mappings from plugins (source is a Vim script). No need to put these in a .vimrc, they will be defined when the plugin is loaded. @@ -249,6 +212,7 @@ Also get E749 on exit. Another example in #1309 Patch to change all use of &sw to shiftwidth(). (Tyru, 2017 Feb 19) +Takuya Fujiwara Wait until maintainers integrate it. When deleting a mark or register, leave a tombstone, so that it's also deleted @@ -358,6 +322,8 @@ Patch for wrong cursor position on wrapp (Ozaki Kiichi, 2016 Nov 25) Does this also fix #1408 ? +Patch to add "module" to quickfix entries. (Coot, 2017 Jun 8, #1757) + Patch for 'cursorlinenr' option. (Ozaki Kiichi, 2016 Nov 30) When 'completeopt' has "noselect" does not insert a newline. (Lifepillar, 2017 @@ -500,9 +466,6 @@ This does not work: :set cscopequickfix= Possibly wrong value for seq_cur. (Florent Fayolle, 2016 May 15, #806) -Patch to add separate highlighting for quickfix current line. -(anishsane, 2016 Sep 16, #1080) - Filetype plugin for awk. (Doug Kearns, 2016 Sep 5) Patch to improve map documentation. Issue #799. @@ -539,6 +502,9 @@ Because of using the initial buffer? (Du Patch to add the :bvimgrep command. (Christian Brabandt, 2014 Nov 12) Updated 2016 Jun 10, #858 Update 2017 Mar 28: use +Patch to fix that an encoding conversion failure results in a corrupted or +empty file. (Christian Brabandt, #1765, https://github.com/chrisbra/vim-mq-patches/blob/master/conversion_error) + Add redrawtabline command. (Naruhiko Nishino, 2016 Jun 11) Neovim patch for utfc_ptr2char_len() https://github.com/neovim/neovim/pull/4574 @@ -1032,8 +998,6 @@ Patch to handle integer overflow. (Aaron Patch to add "ntab" item in 'listchars' to repeat first character. (Nathaniel Braun, pragm, 2013 Oct 13) A better solution 2014 Mar 5. -/[b-a] gives error E16, should probably be E769. - 7 Windows XP: When using "ClearType" for text smoothing, a column of yellow pixels remains when typing spaces in front of a "D" ('guifont' set to "lucida_console:h8"). diff --git a/runtime/filetype.vim b/runtime/filetype.vim --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2017 Jun 04 +" Last Change: 2017 Jun 12 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -2253,6 +2253,8 @@ func! s:FTtex() let format = tolower(matchstr(firstline, '\a\+')) let format = substitute(format, 'pdf', '', '') if format == 'tex' + let format = 'latex' + elseif format == 'plaintex' let format = 'plain' endif else diff --git a/runtime/indent/ada.vim b/runtime/indent/ada.vim --- a/runtime/indent/ada.vim +++ b/runtime/indent/ada.vim @@ -87,7 +87,7 @@ function s:MainBlockIndent (prev_indent, endwhile endwhile " Fallback - just move back one - return a:prev_indent - &sw + return a:prev_indent - shiftwidth() endfunction MainBlockIndent " Section: s:EndBlockIndent {{{1 @@ -131,7 +131,7 @@ function s:EndBlockIndent( prev_indent, endwhile endwhile " Fallback - just move back one - return a:prev_indent - &sw + return a:prev_indent - shiftwidth() endfunction EndBlockIndent " Section: s:StatementIndent {{{1 @@ -213,15 +213,15 @@ function GetAdaIndent() endif " Move indent in if ! false_match - let ind = ind + &sw + let ind = ind + shiftwidth() endif elseif line =~ '^\s*\(case\|exception\)\>' " Move indent in twice (next 'when' will move back) - let ind = ind + 2 * &sw + let ind = ind + 2 * shiftwidth() elseif line =~ '^\s*end\s*record\>' " Move indent back to tallying 'type' preceeding the 'record'. " Allow indent to be equal to 'end record's. - let ind = s:MainBlockIndent( ind+&sw, lnum, 'type\>', '' ) + let ind = s:MainBlockIndent( ind+shiftwidth(), lnum, 'type\>', '' ) elseif line =~ '\(^\s*new\>.*\)\@' " Multiple line generic instantiation ('package blah is\nnew thingy') - let ind = s:StatementIndent( ind - &sw, lnum ) + let ind = s:StatementIndent( ind - shiftwidth(), lnum ) elseif line =~ ';\s*$' " Statement end (but not 'end' ) - try to find current statement-start indent let ind = s:StatementIndent( ind, lnum ) @@ -256,17 +256,17 @@ function GetAdaIndent() elseif continuation && line =~ '^\s*(' " Don't do this if we've already indented due to the previous line if ind == initind - let ind = ind + &sw + let ind = ind + shiftwidth() endif elseif line =~ '^\s*\(begin\|is\)\>' let ind = s:MainBlockIndent( ind, lnum, '\(procedure\|function\|declare\|package\|task\)\>', 'begin\>' ) elseif line =~ '^\s*record\>' - let ind = s:MainBlockIndent( ind, lnum, 'type\>\|for\>.*\', '' ) + &sw + let ind = s:MainBlockIndent( ind, lnum, 'type\>\|for\>.*\', '' ) + shiftwidth() elseif line =~ '^\s*\(else\|elsif\)\>' let ind = s:MainBlockIndent( ind, lnum, 'if\>', '' ) elseif line =~ '^\s*when\>' " Align 'when' one /in/ from matching block start - let ind = s:MainBlockIndent( ind, lnum, '\(case\|exception\)\>', '' ) + &sw + let ind = s:MainBlockIndent( ind, lnum, '\(case\|exception\)\>', '' ) + shiftwidth() elseif line =~ '^\s*end\>\s*\' " End of if statements let ind = s:EndBlockIndent( ind, lnum, 'if\>', 'end\>\s*\' ) diff --git a/runtime/indent/awk.vim b/runtime/indent/awk.vim --- a/runtime/indent/awk.vim +++ b/runtime/indent/awk.vim @@ -60,7 +60,7 @@ function! GetAwkIndent() " 'pattern { action }' (simple check match on /{/ increases the indent then) if s:Get_brace_balance( prev_data, '{', '}' ) > 0 - return ind + &sw + return ind + shiftwidth() endif let brace_balance = s:Get_brace_balance( prev_data, '(', ')' ) @@ -99,7 +99,7 @@ function! GetAwkIndent() return s:Safe_indent( ind, s:First_word_len(prev_data), getline(v:lnum)) else " if/for/while without '{' - return ind + &sw + return ind + shiftwidth() endif endif endif @@ -140,7 +140,7 @@ function! GetAwkIndent() " Decrease indent if this line contains a '}'. if getline(v:lnum) =~ '^\s*}' - let ind = ind - &sw + let ind = ind - shiftwidth() endif return ind diff --git a/runtime/indent/bst.vim b/runtime/indent/bst.vim --- a/runtime/indent/bst.vim +++ b/runtime/indent/bst.vim @@ -69,7 +69,7 @@ function! GetBstIndent(lnum) abort endif let fakeline = substitute(line,'^}','','').matchstr(cline,'^}') let ind = indent(lnum) - let ind = ind + &sw * s:count(line,'{') - let ind = ind - &sw * s:count(fakeline,'}') + let ind = ind + shiftwidth() * s:count(line,'{') + let ind = ind - shiftwidth() * s:count(fakeline,'}') return ind endfunction diff --git a/runtime/indent/bzl.vim b/runtime/indent/bzl.vim --- a/runtime/indent/bzl.vim +++ b/runtime/indent/bzl.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Bazel (http://bazel.io) " Maintainer: David Barnett (https://github.com/google/vim-ft-bzl) -" Last Change: 2015 Aug 11 +" Last Change: 2017 Jun 13 if exists('b:did_indent') finish @@ -41,11 +41,8 @@ function GetBzlIndent(lnum) abort if exists('g:pyindent_open_paren') let l:pyindent_open_paren = g:pyindent_open_paren endif - " Vim 7.3.693 and later defines a shiftwidth() function to get the effective - " shiftwidth value. Fall back to &shiftwidth if the function doesn't exist. - let l:sw_expr = exists('*shiftwidth') ? 'shiftwidth()' : '&shiftwidth' - let g:pyindent_nested_paren = l:sw_expr . ' * 2' - let g:pyindent_open_paren = l:sw_expr . ' * 2' + let g:pyindent_nested_paren = 'shiftwidth() * 2' + let g:pyindent_open_paren = 'shiftwidth() * 2' endif let l:indent = -1 diff --git a/runtime/indent/cdl.vim b/runtime/indent/cdl.vim --- a/runtime/indent/cdl.vim +++ b/runtime/indent/cdl.vim @@ -47,7 +47,7 @@ fun! CdlGetIndent(lnum) let thisline = getline(a:lnum) if match(thisline, '^\s*\(\k\+\|\[[^]]*]\)\s*\(,\|;\s*$\)') >= 0 " it's an attributes line - return &sw + return shiftwidth() elseif match(thisline, '^\c\s*\([{}]\|\/[*/]\|dimension\|schedule\|group\|hierarchy\|class\)') >= 0 " it's a header or '{' or '}' or a comment return 0 @@ -71,13 +71,13 @@ fun! CdlGetIndent(lnum) let c = line[inicio-1] " ')' and '=' don't change indent and are useless to set 'f' if c == '{' - return &sw + return shiftwidth() elseif c != ')' && c != '=' let f = 1 " all but 'elseif' are followed by a formula if c ==? 'n' || c ==? 'e' " 'then', 'else' - let ind = ind + &sw + let ind = ind + shiftwidth() elseif strpart(line, inicio-6, 6) ==? 'elseif' " elseif, set f to conditional - let ind = ind + &sw + let ind = ind + shiftwidth() let f = 0 end end @@ -98,16 +98,16 @@ fun! CdlGetIndent(lnum) let ind = 0 let f = 1 elseif c == ')' || c== ';' || strpart(line, inicio-5, 5) ==? 'endif' - let ind = ind - &sw + let ind = ind - shiftwidth() elseif c == '(' || c ==? 'f' " '(' or 'if' - let ind = ind + &sw + let ind = ind + shiftwidth() else " c == '=' " if it is an asignment increase indent if f == -1 " we don't know yet, find out let f = CdlAsignment(lnum, strpart(line, 0, inicio)) end if f == 1 " formula increase it - let ind = ind + &sw + let ind = ind + shiftwidth() end end endw @@ -115,13 +115,13 @@ fun! CdlGetIndent(lnum) " CURRENT LINE, if it starts with a closing element, decrease indent " or if it starts with '=' (asignment), increase indent if match(thisline, '^\c\s*\(else\|then\|endif\|[);]\)') >= 0 - let ind = ind - &sw + let ind = ind - shiftwidth() elseif match(thisline, '^\s*=') >= 0 if f == -1 " we don't know yet if is an asignment, find out let f = CdlAsignment(lnum, "") end if f == 1 " formula increase it - let ind = ind + &sw + let ind = ind + shiftwidth() end end diff --git a/runtime/indent/chaiscript.vim b/runtime/indent/chaiscript.vim --- a/runtime/indent/chaiscript.vim +++ b/runtime/indent/chaiscript.vim @@ -31,19 +31,19 @@ function! GetChaiScriptIndent() let flag = 0 let prevline = getline(lnum) if prevline =~ '^.*{.*' - let ind = ind + &shiftwidth + let ind = ind + shiftwidth() let flag = 1 endif " Subtract a 'shiftwidth' after lines containing a { followed by a } " to keep it balanced if flag == 1 && prevline =~ '.*{.*}.*' - let ind = ind - &shiftwidth + let ind = ind - shiftwidth() endif " Subtract a 'shiftwidth' on lines ending with } if getline(v:lnum) =~ '^\s*\%(}\)' - let ind = ind - &shiftwidth + let ind = ind - shiftwidth() endif return ind diff --git a/runtime/indent/clojure.vim b/runtime/indent/clojure.vim --- a/runtime/indent/clojure.vim +++ b/runtime/indent/clojure.vim @@ -261,7 +261,7 @@ if exists("*searchpairpos") call cursor(paren) if s:is_method_special_case(paren) - return [paren[0], paren[1] + &shiftwidth - 1] + return [paren[0], paren[1] + shiftwidth() - 1] endif if s:is_reader_conditional_special_case(paren) @@ -299,19 +299,19 @@ if exists("*searchpairpos") let ww = s:strip_namespace_and_macro_chars(w) if &lispwords =~# '\V\<' . ww . '\>' - return [paren[0], paren[1] + &shiftwidth - 1] + return [paren[0], paren[1] + shiftwidth() - 1] endif if g:clojure_fuzzy_indent \ && !s:match_one(g:clojure_fuzzy_indent_blacklist, ww) \ && s:match_one(g:clojure_fuzzy_indent_patterns, ww) - return [paren[0], paren[1] + &shiftwidth - 1] + return [paren[0], paren[1] + shiftwidth() - 1] endif call search('\v\_s', 'cW') call search('\v\S', 'W') if paren[0] < line(".") - return [paren[0], paren[1] + (g:clojure_align_subforms ? 0 : &shiftwidth - 1)] + return [paren[0], paren[1] + (g:clojure_align_subforms ? 0 : shiftwidth() - 1)] endif call search('\v\S', 'bW') diff --git a/runtime/indent/cmake.vim b/runtime/indent/cmake.vim --- a/runtime/indent/cmake.vim +++ b/runtime/indent/cmake.vim @@ -68,19 +68,19 @@ fun! CMakeGetIndent(lnum) let ind = ind else if previous_line =~? cmake_indent_begin_regex - let ind = ind + &sw + let ind = ind + shiftwidth() endif if previous_line =~? cmake_indent_open_regex - let ind = ind + &sw + let ind = ind + shiftwidth() endif endif " Subtract if this_line =~? cmake_indent_end_regex - let ind = ind - &sw + let ind = ind - shiftwidth() endif if previous_line =~? cmake_indent_close_regex - let ind = ind - &sw + let ind = ind - shiftwidth() endif return ind diff --git a/runtime/indent/cobol.vim b/runtime/indent/cobol.vim --- a/runtime/indent/cobol.vim +++ b/runtime/indent/cobol.vim @@ -52,11 +52,11 @@ function! s:optionalblock(lnum,ind,block if getline(lastclause) =~? clauses && s:stripped(lastclause) !~? '^'.begin let ind = indent(lastclause) elseif lastclause > 0 - let ind = indent(lastclause) + &sw - "let ind = ind + &sw + let ind = indent(lastclause) + shiftwidth() + "let ind = ind + shiftwidth() endif elseif line =~? clauses && cline !~? end - let ind = ind + &sw + let ind = ind + shiftwidth() endif return ind endfunction @@ -98,8 +98,8 @@ function! GetCobolIndent(lnum) abort let num = matchstr(line,'^\s*\zs\d\+\>') if 0+cnum == num return lindent - elseif 0+cnum > num && default < lindent + &sw - let default = lindent + &sw + elseif 0+cnum > num && default < lindent + shiftwidth() + let default = lindent + shiftwidth() endif elseif lindent < bshft && lindent >= ashft break @@ -135,13 +135,13 @@ function! GetCobolIndent(lnum) abort if line =~? '^PERFORM\>' let perfline = substitute(line, '\c^PERFORM\s*', "", "") if perfline =~? '^\%(\k\+\s\+TIMES\)\=\s*$' - let ind = ind + &sw + let ind = ind + shiftwidth() elseif perfline =~? '^\%(WITH\s\+TEST\|VARYING\|UNTIL\)\>.*[^.]$' - let ind = ind + &sw + let ind = ind + shiftwidth() endif endif if line =~? '^\%(IF\|THEN\|ELSE\|READ\|EVALUATE\|SEARCH\|SELECT\)\>' - let ind = ind + &sw + let ind = ind + shiftwidth() endif let ind = s:optionalblock(a:lnum,ind,'ADD\|COMPUTE\|DIVIDE\|MULTIPLY\|SUBTRACT','ON\s\+SIZE\s\+ERROR') let ind = s:optionalblock(a:lnum,ind,'STRING\|UNSTRING\|ACCEPT\|DISPLAY\|CALL','ON\s\+OVERFLOW\|ON\s\+EXCEPTION') @@ -157,10 +157,10 @@ function! GetCobolIndent(lnum) abort "&& s:stripped(lastclause) !~? '^\%(SEARCH\|EVALUATE\|READ\)\>' let ind = indent(lastclause) elseif lastclause > 0 - let ind = indent(lastclause) + &sw + let ind = indent(lastclause) + shiftwidth() endif elseif line =~? '^WHEN\>' - let ind = ind + &sw + let ind = ind + shiftwidth() endif "I'm not sure why I had this "if line =~? '^ELSE\>-\@!' && line !~? '\.$' @@ -168,7 +168,7 @@ function! GetCobolIndent(lnum) abort "endif if cline =~? '^\(END\)\>-\@!' " On lines with just END, 'guess' a simple shift left - let ind = ind - &sw + let ind = ind - shiftwidth() elseif cline =~? '^\(END-IF\|THEN\|ELSE\)\>-\@!' call cursor(a:lnum,indent(a:lnum)) let match = searchpair('\c-\@','\c-\@','\c-\@\zs','bnW',s:skip) @@ -209,7 +209,7 @@ function! GetCobolIndent(lnum) abort if match > 0 let ind = indent(match) elseif cline =~? '^\(END-\(READ\|EVALUATE\|SEARCH\|PERFORM\)\)\>' - let ind = ind - &sw + let ind = ind - shiftwidth() endif endif return ind < bshft ? bshft : ind diff --git a/runtime/indent/cucumber.vim b/runtime/indent/cucumber.vim --- a/runtime/indent/cucumber.vim +++ b/runtime/indent/cucumber.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Cucumber " Maintainer: Tim Pope -" Last Change: 2016 Aug 29 +" Last Change: 2017 Jun 13 if exists("b:did_indent") finish @@ -27,7 +27,7 @@ function! GetCucumberIndent() let line = getline(prevnonblank(v:lnum-1)) let cline = getline(v:lnum) let nline = getline(nextnonblank(v:lnum+1)) - let sw = exists('*shiftwidth') ? shiftwidth() : &sw + let sw = exists('*shiftwidth') ? shiftwidth() : shiftwidth() let syn = s:syn(prevnonblank(v:lnum-1)) let csyn = s:syn(v:lnum) let nsyn = s:syn(nextnonblank(v:lnum+1)) diff --git a/runtime/indent/dylan.vim b/runtime/indent/dylan.vim --- a/runtime/indent/dylan.vim +++ b/runtime/indent/dylan.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Dylan " Version: 0.01 -" Last Change: 2003 Feb 04 +" Last Change: 2017 Jun 13 " Maintainer: Brent A. Fulgham " Only load this indent file when no other was loaded. @@ -45,13 +45,13 @@ function DylanGetIndent() " If previous line was a 'define', indent if prevline =~? '\(^\s*\(begin\|block\|case\|define\|else\|elseif\|for\|finally\|if\|select\|unless\|while\)\|\s*\S*\s*=>$\)' - let chg = &sw + let chg = shiftwidth() " local methods indent the shift-width, plus 6 for the 'local' elseif prevline =~? '^\s*local' - let chg = &sw + 6 + let chg = shiftwidth() + 6 " If previous line was a let with no closing semicolon, indent elseif prevline =~? '^\s*let.*[^;]\s*$' - let chg = &sw + let chg = shiftwidth() " If previous line opened a parenthesis, and did not close it, indent elseif prevline =~ '^.*(\s*[^)]*\((.*)\)*[^)]*$' return = match( prevline, '(.*\((.*)\|[^)]\)*.*$') + 1 @@ -75,13 +75,13 @@ function DylanGetIndent() " line doesn't start with an indentable command: let curr_str = getline(curr_line) if curr_str =~? '^\s*\(begin\|block\|case\|define\|else\|elseif\|for\|finally\|if\|select\|unless\|while\)' - let chg = &sw + let chg = shiftwidth() endif endif " If a line starts with end, un-indent (even if we just indented!) if cline =~? '^\s*\(cleanup\|end\|else\|elseif\|exception\|finally\|otherwise\)' - let chg = chg - &sw + let chg = chg - shiftwidth() endif return ind + chg diff --git a/runtime/indent/erlang.vim b/runtime/indent/erlang.vim --- a/runtime/indent/erlang.vim +++ b/runtime/indent/erlang.vim @@ -669,7 +669,7 @@ function! s:BeginningOfClauseFound(stack call s:Pop(a:stack) if empty(a:stack) call s:Log(' Stack is ["when"], so LTI is in a guard -> return') - return [1, a:stored_vcol + &sw + 2] + return [1, a:stored_vcol + shiftwidth() + 2] else return [1, s:UnexpectedToken(a:token, a:stack)] endif @@ -678,7 +678,7 @@ function! s:BeginningOfClauseFound(stack call s:Pop(a:stack) if empty(a:stack) call s:Log(' Stack is ["->"], so LTI is in function body -> return') - return [1, a:stored_vcol + &sw] + return [1, a:stored_vcol + shiftwidth()] elseif a:stack[0] ==# ';' call s:Pop(a:stack) if empty(a:stack) @@ -797,7 +797,7 @@ function! s:ErlangCalcIndent2(lnum, stac elseif token ==# 'begin' let [ret, res] = s:BeginElementFound(stack, token, curr_vcol, - \stored_vcol, 'end', &sw) + \stored_vcol, 'end', shiftwidth()) if ret | return res | endif " case EXPR of BRANCHES end @@ -848,11 +848,11 @@ function! s:ErlangCalcIndent2(lnum, stac elseif stack == ['->'] call s:Log(' LTI is in a branch after ' . \'"of/receive/after/if/catch" -> return') - return stored_vcol + &sw + return stored_vcol + shiftwidth() elseif stack == ['when'] call s:Log(' LTI is in a guard after ' . \'"of/receive/after/if/catch" -> return') - return stored_vcol + &sw + return stored_vcol + shiftwidth() else return s:UnexpectedToken(token, stack) endif @@ -888,7 +888,7 @@ function! s:ErlangCalcIndent2(lnum, stac if empty(stack) call s:Log(' LTI is in a condition; matching ' . \'"case/if/try/receive" found') - let stored_vcol = curr_vcol + &sw + let stored_vcol = curr_vcol + shiftwidth() elseif stack[0] ==# 'align_to_begin_element' call s:Pop(stack) let stored_vcol = curr_vcol @@ -897,23 +897,23 @@ function! s:ErlangCalcIndent2(lnum, stac \'"case/if/try/receive" found') call s:Pop(stack) call s:Pop(stack) - let stored_vcol = curr_vcol + &sw + let stored_vcol = curr_vcol + shiftwidth() elseif stack[0] ==# '->' call s:Log(' LTI is in a branch; matching ' . \'"case/if/try/receive" found') call s:Pop(stack) - let stored_vcol = curr_vcol + 2 * &sw + let stored_vcol = curr_vcol + 2 * shiftwidth() elseif stack[0] ==# 'when' call s:Log(' LTI is in a guard; matching ' . \'"case/if/try/receive" found') call s:Pop(stack) - let stored_vcol = curr_vcol + 2 * &sw + 2 + let stored_vcol = curr_vcol + 2 * shiftwidth() + 2 endif endif let [ret, res] = s:BeginElementFound(stack, token, curr_vcol, - \stored_vcol, 'end', &sw) + \stored_vcol, 'end', shiftwidth()) if ret | return res | endif elseif token ==# 'fun' @@ -930,7 +930,7 @@ function! s:ErlangCalcIndent2(lnum, stac " stack = ['when'] => LTI is in a guard if empty(stack) call s:Log(' LTI is in a condition; matching "fun" found') - let stored_vcol = curr_vcol + &sw + let stored_vcol = curr_vcol + shiftwidth() elseif len(stack) > 1 && stack[0] ==# '->' && stack[1] ==# ';' call s:Log(' LTI is in a condition; matching "fun" found') call s:Pop(stack) @@ -938,15 +938,15 @@ function! s:ErlangCalcIndent2(lnum, stac elseif stack[0] ==# '->' call s:Log(' LTI is in a branch; matching "fun" found') call s:Pop(stack) - let stored_vcol = curr_vcol + 2 * &sw + let stored_vcol = curr_vcol + 2 * shiftwidth() elseif stack[0] ==# 'when' call s:Log(' LTI is in a guard; matching "fun" found') call s:Pop(stack) - let stored_vcol = curr_vcol + 2 * &sw + 2 + let stored_vcol = curr_vcol + 2 * shiftwidth() + 2 endif let [ret, res] = s:BeginElementFound(stack, token, curr_vcol, - \stored_vcol, 'end', &sw) + \stored_vcol, 'end', shiftwidth()) if ret | return res | endif else " Pass: we have a function reference (e.g. "fun f/0") @@ -1220,7 +1220,7 @@ function! s:ErlangCalcIndent2(lnum, stac " when A, " LTI let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol, - \stored_vcol, &sw) + \stored_vcol, shiftwidth()) if ret | return res | endif else " Example: @@ -1252,7 +1252,7 @@ function! s:ErlangCalcIndent2(lnum, stac " If LTI is between an 'after' and the corresponding " 'end', then let's return let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol, - \stored_vcol, &sw) + \stored_vcol, shiftwidth()) if ret | return res | endif endif diff --git a/runtime/indent/eruby.vim b/runtime/indent/eruby.vim --- a/runtime/indent/eruby.vim +++ b/runtime/indent/eruby.vim @@ -47,11 +47,7 @@ set cpo&vim function! GetErubyIndent(...) " The value of a single shift-width - if exists('*shiftwidth') - let sw = shiftwidth() - else - let sw = &sw - endif + let sw = shiftwidth() if a:0 && a:1 == '.' let v:lnum = line('.') diff --git a/runtime/indent/falcon.vim b/runtime/indent/falcon.vim --- a/runtime/indent/falcon.vim +++ b/runtime/indent/falcon.vim @@ -339,7 +339,7 @@ function FalconGetIndent(...) " If the previous line ended with a block opening, add a level of indent. if s:Match(lnum, s:block_regex) - return indent(s:GetMSL(lnum)) + &sw + return indent(s:GetMSL(lnum)) + shiftwidth() endif " If it contained hanging closing brackets, find the rightmost one, find its @@ -350,20 +350,20 @@ function FalconGetIndent(...) if opening.pos != -1 if opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 if col('.') + 1 == col('$') - return ind + &sw + return ind + shiftwidth() else return virtcol('.') endif else let nonspace = matchend(line, '\S', opening.pos + 1) - 1 - return nonspace > 0 ? nonspace : ind + &sw + return nonspace > 0 ? nonspace : ind + shiftwidth() endif elseif closing.pos != -1 call cursor(lnum, closing.pos + 1) normal! % if s:Match(line('.'), s:falcon_indent_keywords) - return indent('.') + &sw + return indent('.') + shiftwidth() else return indent('.') endif @@ -392,7 +392,7 @@ function FalconGetIndent(...) let col = s:Match(lnum, s:falcon_indent_keywords) if col > 0 call cursor(lnum, col) - let ind = virtcol('.') - 1 + &sw + let ind = virtcol('.') - 1 + shiftwidth() " TODO: make this better (we need to count them) (or, if a searchpair " fails, we know that something is lacking an end and thus we indent a " level @@ -422,9 +422,9 @@ function FalconGetIndent(...) " TODO: this does not take into account contrived things such as " module Foo; class Bar; end if s:Match(lnum, s:falcon_indent_keywords) - let ind = msl_ind + &sw + let ind = msl_ind + shiftwidth() if s:Match(lnum, s:end_end_regex) - let ind = ind - &sw + let ind = ind - shiftwidth() endif return ind endif @@ -433,7 +433,7 @@ function FalconGetIndent(...) " closing bracket, indent one extra level. if s:Match(lnum, s:non_bracket_continuation_regex) && !s:Match(lnum, '^\s*\([\])}]\|end\)') if lnum == p_lnum - let ind = msl_ind + &sw + let ind = msl_ind + shiftwidth() else let ind = msl_ind endif diff --git a/runtime/indent/gitconfig.vim b/runtime/indent/gitconfig.vim --- a/runtime/indent/gitconfig.vim +++ b/runtime/indent/gitconfig.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: git config file " Maintainer: Tim Pope -" Last Change: 2016 Aug 29 +" Last Change: 2017 Jun 13 if exists("b:did_indent") finish @@ -20,7 +20,7 @@ if exists("*GetGitconfigIndent") endif function! GetGitconfigIndent() - let sw = exists('*shiftwidth') ? shiftwidth() : &sw + let sw = shiftwidth() let line = getline(prevnonblank(v:lnum-1)) let cline = getline(v:lnum) if line =~ '\\\@ -" Last Change: 2011-12-24 +" Last Change: 2017 Jun 13 if exists("b:did_indent") finish @@ -27,11 +27,11 @@ function! GetGitoliteIndent() let cline = getline(v:lnum) if cline =~ '^\s*\(C\|R\|RW\|RW+\|RWC\|RW+C\|RWD\|RW+D\|RWCD\|RW+CD\|-\)[ \t=]' - return &sw + return shiftwidth() elseif cline =~ '^\s*config\s' - return &sw + return shiftwidth() elseif pline =~ '^\s*repo\s' && cline =~ '^\s*\(#.*\)\?$' - return &sw + return shiftwidth() elseif cline =~ '^\s*#' return indent(prevln) elseif cline =~ '^\s*$' diff --git a/runtime/indent/go.vim b/runtime/indent/go.vim --- a/runtime/indent/go.vim +++ b/runtime/indent/go.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Go " Maintainer: David Barnett (https://github.com/google/vim-ft-go) -" Last Change: 2014 Aug 16 +" Last Change: 2017 Jun 13 " " TODO: " - function invocations split across lines @@ -23,18 +23,6 @@ if exists('*GoIndent') finish endif -" The shiftwidth() function is relatively new. -" Don't require it to exist. -if exists('*shiftwidth') - function s:sw() abort - return shiftwidth() - endfunction -else - function s:sw() abort - return &shiftwidth - endfunction -endif - function! GoIndent(lnum) let l:prevlnum = prevnonblank(a:lnum-1) if l:prevlnum == 0 @@ -51,17 +39,17 @@ function! GoIndent(lnum) if l:prevl =~ '[({]\s*$' " previous line opened a block - let l:ind += s:sw() + let l:ind += shiftwidth() endif if l:prevl =~# '^\s*\(case .*\|default\):$' " previous line is part of a switch statement - let l:ind += s:sw() + let l:ind += shiftwidth() endif " TODO: handle if the previous line is a label. if l:thisl =~ '^\s*[)}]' " this line closed a block - let l:ind -= s:sw() + let l:ind -= shiftwidth() endif " Colons are tricky. @@ -69,7 +57,7 @@ function! GoIndent(lnum) " We ignore trying to deal with jump labels because (a) they're rare, and " (b) they're hard to disambiguate from a composite literal key. if l:thisl =~# '^\s*\(case .*\|default\):$' - let l:ind -= s:sw() + let l:ind -= shiftwidth() endif return l:ind diff --git a/runtime/indent/haml.vim b/runtime/indent/haml.vim --- a/runtime/indent/haml.vim +++ b/runtime/indent/haml.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Haml " Maintainer: Tim Pope -" Last Change: 2016 Aug 29 +" Last Change: 2017 Jun 13 if exists("b:did_indent") finish @@ -37,7 +37,7 @@ function! GetHamlIndent() let line = substitute(line,'^\s\+','','') let indent = indent(lnum) let cindent = indent(v:lnum) - let sw = exists('*shiftwidth') ? shiftwidth() : &sw + let sw = shiftwidth() if cline =~# '\v^-\s*%(elsif|else|when)>' let indent = cindent < indent ? cindent : indent - sw endif diff --git a/runtime/indent/hamster.vim b/runtime/indent/hamster.vim --- a/runtime/indent/hamster.vim +++ b/runtime/indent/hamster.vim @@ -27,13 +27,13 @@ function HamGetIndent(lnum) " Add a shiftwidth to statements following if, else, elseif, " case, select, default, do, until, while, for, start if prevline =~? '^\s*\<\(if\|else\%(if\)\?\|for\|repeat\|do\|while\|sub\)\>' - let ind = ind + &sw + let ind = ind + shiftwidth() endif " Subtract a shiftwidth from else, elseif, end(if|while|for), until let line = getline(v:lnum) if line =~? '^\s*\(else\|elseif\|loop\|until\|end\%(if\|while\|for\|sub\)\)\>' - let ind = ind - &sw + let ind = ind - shiftwidth() endif return ind diff --git a/runtime/indent/hog.vim b/runtime/indent/hog.vim --- a/runtime/indent/hog.vim +++ b/runtime/indent/hog.vim @@ -47,7 +47,7 @@ function GetHogIndent() " Continuation of a line that wasn't indented let prevline = getline(prevlnum) if prevline =~ '^\k\+.*\\\s*$' - return &sw + return shiftwidth() endif " Continuation of a line that was indented @@ -58,13 +58,13 @@ function GetHogIndent() " Indent the next line if previous line contained a start of a block " definition ('{' or '('). if prevline =~ '^\k\+[^#]*{}\@!\s*$' " TODO || prevline =~ '^\k\+[^#]*()\@!\s*$' - return &sw + return shiftwidth() endif " Match inside of a block if s:IsInBlock(v:lnum) if prevline =~ "^\k\+.*$" - return &sw + return shiftwidth() else return indent(prevlnum) endif diff --git a/runtime/indent/html.vim b/runtime/indent/html.vim --- a/runtime/indent/html.vim +++ b/runtime/indent/html.vim @@ -2,7 +2,7 @@ " Header: "{{{ " Maintainer: Bram Moolenaar " Original Author: Andy Wokula -" 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:f 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