Skip to content

Commit

Permalink
vim-patch:3ec574f2b549
Browse files Browse the repository at this point in the history
Update runtime files.

Includes changing &sw to shiftwidth() for all indent scripts.

vim/vim@3ec574f
  • Loading branch information
justinmk committed Nov 7, 2017
1 parent 599170d commit a39bf01
Show file tree
Hide file tree
Showing 62 changed files with 328 additions and 376 deletions.
5 changes: 4 additions & 1 deletion runtime/doc/eval.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5157,7 +5157,10 @@ line({expr}) The result is a Number, which is the line number of the file
< *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
Expand Down
8 changes: 6 additions & 2 deletions runtime/doc/pattern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1058,12 +1058,16 @@ x A single character, with no special meaning, matches itself
":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:
Expand Down
4 changes: 3 additions & 1 deletion runtime/filetype.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2017 May 27
" Last Change: 2017 Jun 12

" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
Expand Down Expand Up @@ -2229,6 +2229,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
Expand Down
22 changes: 11 additions & 11 deletions runtime/indent/ada.vim
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function s:MainBlockIndent (prev_indent, prev_lnum, blockstart, stop_at)
endwhile
endwhile
" Fallback - just move back one
return a:prev_indent - &sw
return a:prev_indent - shiftwidth()
endfunction MainBlockIndent

" Section: s:EndBlockIndent {{{1
Expand Down Expand Up @@ -131,7 +131,7 @@ function s:EndBlockIndent( prev_indent, prev_lnum, blockstart, blockend )
endwhile
endwhile
" Fallback - just move back one
return a:prev_indent - &sw
return a:prev_indent - shiftwidth()
endfunction EndBlockIndent

" Section: s:StatementIndent {{{1
Expand Down Expand Up @@ -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' preceding the '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\>.*\)\@<!)\s*[;,]\s*$'
" Revert to indent of line that started this parenthesis pair
exe lnum
Expand All @@ -235,10 +235,10 @@ function GetAdaIndent()
exe v:lnum
elseif line =~ '[.=(]\s*$'
" A statement continuation - move in one
let ind = ind + &sw
let ind = ind + shiftwidth()
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 )
Expand All @@ -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\>.*\<use\>', '' ) + &sw
let ind = s:MainBlockIndent( ind, lnum, 'type\>\|for\>.*\<use\>', '' ) + 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*\<if\>'
" End of if statements
let ind = s:EndBlockIndent( ind, lnum, 'if\>', 'end\>\s*\<if\>' )
Expand Down
6 changes: 3 additions & 3 deletions runtime/indent/awk.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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, '(', ')' )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions runtime/indent/bst.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 3 additions & 6 deletions runtime/indent/bzl.vim
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions runtime/indent/cdl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -98,30 +98,30 @@ 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

" 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

Expand Down
6 changes: 3 additions & 3 deletions runtime/indent/chaiscript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions runtime/indent/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions runtime/indent/cmake.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions runtime/indent/cobol.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function! s:optionalblock(lnum,ind,blocks,clauses)
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -157,18 +157,18 @@ 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 !~? '\.$'
"let ind = indent(s:prevgood(lnum))
"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-\@<!\<IF\>','\c-\@<!\%(THEN\|ELSE\)\>','\c-\@<!\<END-IF\>\zs','bnW',s:skip)
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit a39bf01

Please sign in to comment.