comparison runtime/indent/matlab.vim @ 18848:a0e0f0256d0b

Runtime file updates. Commit: https://github.com/vim/vim/commit/32b364fcc09749f35adb441b81291e1e5946dbc2 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 8 15:07:48 2019 +0100 Runtime file updates.
author Bram Moolenaar <Bram@vim.org>
date Sun, 08 Dec 2019 15:15:04 +0100
parents 8b334e4cb97f
children 9c221ad9634a
comparison
equal deleted inserted replaced
18847:6ec9c4c37cc3 18848:a0e0f0256d0b
27 if exists("*GetMatlabIndent") | finish | endif 27 if exists("*GetMatlabIndent") | finish | endif
28 28
29 let s:keepcpo = &cpo 29 let s:keepcpo = &cpo
30 set cpo&vim 30 set cpo&vim
31 31
32 let s:end = '\<end\>\%([^(]*)\)\@!' " Array indexing heuristic 32 let s:end = '\<end\>\%([^({]*[)}]\)\@!' " Array indexing heuristic
33 let s:open_pat = 'for\|if\|parfor\|spmd\|switch\|try\|while\|classdef\|properties\|methods\|events\|enumeration' 33 let s:open_pat = 'for\|if\|parfor\|spmd\|switch\|try\|while\|classdef\|properties\|methods\|events\|enumeration'
34 let s:dedent_pat = '\C^\s*\zs\<\%(end\|else\|elseif\|catch\|\(case\|otherwise\|function\)\)\>' 34 let s:dedent_pat = '\C^\s*\zs\<\%(end\|else\|elseif\|catch\|\(case\|otherwise\|function\)\)\>'
35 let s:start_pat = '\C\<\%(function\|' . s:open_pat . '\)\>' 35 let s:start_pat = '\C\<\%(function\|' . s:open_pat . '\)\>'
36 let s:bracket_pair_pat = '\(\[\|{\)\|\(\]\|}\)' 36 let s:bracket_pair_pat = '\(\[\|{\)\|\(\]\|}\)'
37 let s:zflag = has('patch-7.4.984') ? 'z' : '' 37 let s:zflag = has('patch-7.4.984') ? 'z' : ''
38 38
39 " Returns whether a comment or string envelops the specified column. 39 " Returns whether a comment or string envelops the specified column.
40 function! s:IsCommentOrString(lnum, col) 40 function! s:IsCommentOrString(lnum, col)
41 return synIDattr(synID(a:lnum, a:col, 1), "name") =~# 'matlabComment\|matlabMultilineComment\|matlabString' 41 return synIDattr(synID(a:lnum, a:col, 1), "name") =~# 'matlabComment\|matlabMultilineComment\|matlabCellComment\|matlabString'
42 endfunction 42 endfunction
43 43
44 " Returns whether the specified line continues on the next line. 44 " Returns whether the specified line continues on the next line.
45 function! s:IsLineContinuation(lnum) 45 function! s:IsLineContinuation(lnum)
46 let l = getline(a:lnum) | let c = -3 46 let l = getline(a:lnum) | let c = -3
103 let [lnum, col] = searchpairpos(s:start_pat, '', '\C' . s:end, 'bW', 's:IsCommentOrString(line("."), col("."))') 103 let [lnum, col] = searchpairpos(s:start_pat, '', '\C' . s:end, 'bW', 's:IsCommentOrString(line("."), col("."))')
104 let result = lnum ? indent(lnum) + shiftwidth() * (s:GetOpenCloseCount(lnum, pair_pat, col) + submatch == 2) : 0 104 let result = lnum ? indent(lnum) + shiftwidth() * (s:GetOpenCloseCount(lnum, pair_pat, col) + submatch == 2) : 0
105 else 105 else
106 " Count how many blocks the previous line opens/closes 106 " Count how many blocks the previous line opens/closes
107 " Line continuations/brackets indent once per statement 107 " Line continuations/brackets indent once per statement
108 let result = indent(prevlnum) + shiftwidth() * (open - close 108 let result = (prevlnum > 0) * indent(prevlnum) + shiftwidth() * (open - close
109 \ + (b:MATLAB_bracketlevel ? -!curbracketlevel : !!curbracketlevel) 109 \ + (b:MATLAB_bracketlevel ? -!curbracketlevel : !!curbracketlevel)
110 \ + (curbracketlevel <= 0) * (above_lc - b:MATLAB_waslc)) 110 \ + (curbracketlevel <= 0) * (above_lc - b:MATLAB_waslc))
111 endif 111 endif
112 112
113 let b:MATLAB_waslc = above_lc 113 let b:MATLAB_waslc = above_lc