diff options
author | Christian Clason <c.clason@uni-graz.at> | 2022-09-06 08:57:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-06 08:57:53 +0200 |
commit | 4bf005e9fdfb57397475b2663a3651faa83886ff (patch) | |
tree | 2b690743460445cdfdcc215c0866ce2275e82290 /runtime/indent/vim.vim | |
parent | 5b7213ad7fdac47345b7d9d9a008db23eed4d17c (diff) | |
download | rneovim-4bf005e9fdfb57397475b2663a3651faa83886ff.tar.gz rneovim-4bf005e9fdfb57397475b2663a3651faa83886ff.tar.bz2 rneovim-4bf005e9fdfb57397475b2663a3651faa83886ff.zip |
vim-patch:partial 0daafaa7d99e (#20083)
Update runtime files
https://github.com/vim/vim/commit/0daafaa7d99ef500f76b1b12f5fe8153e2fcaea0
skip vim9script ftplugin
create userfunc.txt from Neovim content (skip section 3, needs 9.0.0379)
Diffstat (limited to 'runtime/indent/vim.vim')
-rw-r--r-- | runtime/indent/vim.vim | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 8076b2df07..3beb70d255 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -33,7 +33,9 @@ function GetVimIndent() endtry endfunc -let s:lineContPat = '^\s*\(\\\|"\\ \)' +" Legacy script line continuation and Vim9 script operators that must mean an +" expression that continues from the previous line. +let s:lineContPat = '^\s*\(\\\|"\\ \|->\)' function GetVimIndentIntern() " If the current line has line continuation and the previous one too, use @@ -133,15 +135,15 @@ function GetVimIndentIntern() endif endif - " For a line starting with "}" find the matching "{". If it is at the start - " of the line align with it, probably end of a block. + " For a line starting with "}" find the matching "{". Align with that line, + " it is either the matching block start or dictionary start. " Use the mapped "%" from matchit to find the match, otherwise we may match " a { inside a comment or string. if cur_text =~ '^\s*}' if maparg('%') != '' exe v:lnum silent! normal % - if line('.') < v:lnum && getline('.') =~ '^\s*{' + if line('.') < v:lnum let ind = indent('.') endif else @@ -149,19 +151,33 @@ function GetVimIndentIntern() endif endif - " Below a line starting with "}" find the matching "{". If it is at the - " end of the line we must be below the end of a dictionary. - if prev_text =~ '^\s*}' - if maparg('%') != '' - exe lnum - silent! normal % - if line('.') == lnum || getline('.') !~ '^\s*{' - let ind = ind - shiftwidth() + " Look back for a line to align with + while lnum > 1 + " Below a line starting with "}" find the matching "{". + if prev_text =~ '^\s*}' + if maparg('%') != '' + exe lnum + silent! normal % + if line('.') < lnum + let lnum = line('.') + let ind = indent(lnum) + let prev_text = getline(lnum) + else + break + endif + else + " todo: use searchpair() to find a match + break endif + elseif prev_text =~ s:lineContPat + " looks like a continuation like, go back one line + let lnum = lnum - 1 + let ind = indent(lnum) + let prev_text = getline(lnum) else - " todo: use searchpair() to find a match + break endif - endif + endwhile " Below a line starting with "]" we must be below the end of a list. " Include a "}" and "},} in case a dictionary ends too. |