aboutsummaryrefslogtreecommitdiff
path: root/runtime/indent
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
commit931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch)
treed8c1843a95da5ea0bb4acc09f7e37843d9995c86 /runtime/indent
parent142d9041391780ac15b89886a54015fdc5c73995 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-userreg.tar.gz
rneovim-userreg.tar.bz2
rneovim-userreg.zip
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/README.txt11
-rw-r--r--runtime/indent/aap.vim5
-rw-r--r--runtime/indent/bash.vim4
-rw-r--r--runtime/indent/c.vim5
-rw-r--r--runtime/indent/cdl.vim8
-rw-r--r--runtime/indent/ch.vim3
-rw-r--r--runtime/indent/cpp.vim5
-rw-r--r--runtime/indent/cuda.vim5
-rw-r--r--runtime/indent/dts.vim63
-rw-r--r--runtime/indent/dune.vim3
-rw-r--r--runtime/indent/erlang.vim2
-rw-r--r--runtime/indent/fish.vim85
-rw-r--r--runtime/indent/go.vim3
-rw-r--r--runtime/indent/hare.vim3
-rw-r--r--runtime/indent/html.vim4
-rw-r--r--runtime/indent/jsonc.vim3
-rw-r--r--runtime/indent/julia.vim7
-rw-r--r--runtime/indent/kotlin.vim60
-rw-r--r--runtime/indent/krl.vim4
-rw-r--r--runtime/indent/livebook.vim9
-rw-r--r--runtime/indent/logtalk.vim3
-rw-r--r--runtime/indent/lua.vim12
-rw-r--r--runtime/indent/luau.vim14
-rw-r--r--runtime/indent/mail.vim4
-rw-r--r--runtime/indent/nsis.vim2
-rw-r--r--runtime/indent/ocaml.vim5
-rw-r--r--runtime/indent/perl.vim3
-rw-r--r--runtime/indent/php.vim58
-rw-r--r--runtime/indent/python.vim7
-rw-r--r--runtime/indent/qml.vim59
-rw-r--r--runtime/indent/quarto.vim1
-rw-r--r--runtime/indent/r.vim22
-rw-r--r--runtime/indent/raku.vim3
-rw-r--r--runtime/indent/rapid.vim255
-rw-r--r--runtime/indent/rhelp.vim4
-rw-r--r--runtime/indent/rmd.vim6
-rw-r--r--runtime/indent/rnoweb.vim6
-rw-r--r--runtime/indent/rrst.vim4
-rw-r--r--runtime/indent/rst.vim3
-rw-r--r--runtime/indent/ruby.vim4
-rw-r--r--runtime/indent/rust.vim417
-rw-r--r--runtime/indent/scala.vim3
-rw-r--r--runtime/indent/solidity.vim14
-rw-r--r--runtime/indent/systemverilog.vim4
-rw-r--r--runtime/indent/testdir/dts.in46
-rw-r--r--runtime/indent/testdir/dts.ok46
-rw-r--r--runtime/indent/testdir/rapid.in266
-rw-r--r--runtime/indent/testdir/rapid.ok266
-rw-r--r--runtime/indent/testdir/runtest.vim1
-rw-r--r--runtime/indent/tex.vim4
-rw-r--r--runtime/indent/typescript.vim3
-rw-r--r--runtime/indent/typescriptreact.vim2
-rw-r--r--runtime/indent/verilog.vim3
-rw-r--r--runtime/indent/vhdl.vim3
-rw-r--r--runtime/indent/vim.vim5
-rw-r--r--runtime/indent/wat.vim (renamed from runtime/indent/wast.vim)2
-rw-r--r--runtime/indent/xhtml.vim5
-rw-r--r--runtime/indent/zimbu.vim5
58 files changed, 1599 insertions, 263 deletions
diff --git a/runtime/indent/README.txt b/runtime/indent/README.txt
index 649870636e..05ab126c8c 100644
--- a/runtime/indent/README.txt
+++ b/runtime/indent/README.txt
@@ -6,15 +6,16 @@ at ":help indent-expression". Looking at the existing files should give you
inspiration.
If you make a new indent file which would be useful for others, please send it
-to Bram@vim.org. Include instructions for detecting the file type for this
-language, by file name extension or by checking a few lines in the file.
-And please stick to the rules below.
+to the vim-dev mailing list <vim-dev@vim.org>. Include instructions for
+detecting the file type for this language, by file name extension or by
+checking a few lines in the file. And please stick to the rules below.
If you have remarks about an existing file, send them to the maintainer of
-that file. Only when you get no response send a message to Bram@vim.org.
+that file. Only when you get no response send a message to the vim-dev
+mailing list: <vim-dev@vim.org>.
If you are the maintainer of an indent file and make improvements, e-mail the
-new version to Bram@vim.org.
+new version to the vim-dev mailing list: <vim-dev@vim.org>.
Rules for making an indent file:
diff --git a/runtime/indent/aap.vim b/runtime/indent/aap.vim
index 35828b4c1a..23c104985e 100644
--- a/runtime/indent/aap.vim
+++ b/runtime/indent/aap.vim
@@ -1,7 +1,8 @@
" Vim indent file
" Language: Aap recipe
-" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2005 Jun 24
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 10
+" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
diff --git a/runtime/indent/bash.vim b/runtime/indent/bash.vim
index b91640687c..407081232c 100644
--- a/runtime/indent/bash.vim
+++ b/runtime/indent/bash.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: bash
-" Maintainer: Bram
-" Last Change: 2019 Sep 27
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 13
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
diff --git a/runtime/indent/c.vim b/runtime/indent/c.vim
index e224382f63..7f285e1b98 100644
--- a/runtime/indent/c.vim
+++ b/runtime/indent/c.vim
@@ -1,7 +1,8 @@
" Vim indent file
" Language: C
-" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2005 Mar 27
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 10
+" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
diff --git a/runtime/indent/cdl.vim b/runtime/indent/cdl.vim
index 2c0fc7988e..da675698cf 100644
--- a/runtime/indent/cdl.vim
+++ b/runtime/indent/cdl.vim
@@ -21,7 +21,7 @@ endif
" find out if an "...=..." expression is an assignment (or a conditional)
" it scans 'line' first, and then the previous lines
-fun! CdlAsignment(lnum, line)
+fun! CdlAssignment(lnum, line)
let f = -1
let lnum = a:lnum
let line = a:line
@@ -90,7 +90,7 @@ fun! CdlGetIndent(lnum)
end
end
- " remove members [a] of [b]:[c]... (inicio remainds valid)
+ " remove members [a] of [b]:[c]... (inicio remains valid)
let line = substitute(line, '\c\(\[[^]]*]\(\s*of\s*\|:\)*\)\+', ' ', 'g')
while 1
" search for the next interesting element
@@ -111,7 +111,7 @@ fun! CdlGetIndent(lnum)
else " c == '='
" if it is an assignment increase indent
if f == -1 " we don't know yet, find out
- let f = CdlAsignment(lnum, strpart(line, 0, inicio))
+ let f = CdlAssignment(lnum, strpart(line, 0, inicio))
end
if f == 1 " formula increase it
let ind = ind + shiftwidth()
@@ -125,7 +125,7 @@ fun! CdlGetIndent(lnum)
let ind = ind - shiftwidth()
elseif match(thisline, '^\s*=') >= 0
if f == -1 " we don't know yet if is an assignment, find out
- let f = CdlAsignment(lnum, "")
+ let f = CdlAssignment(lnum, "")
end
if f == 1 " formula increase it
let ind = ind + shiftwidth()
diff --git a/runtime/indent/ch.vim b/runtime/indent/ch.vim
index e1bd8a356c..11b1f67790 100644
--- a/runtime/indent/ch.vim
+++ b/runtime/indent/ch.vim
@@ -3,6 +3,7 @@
" Maintainer: SoftIntegration, Inc. <info@softintegration.com>
" URL: http://www.softintegration.com/download/vim/indent/ch.vim
" Last change: 2006 Apr 30
+" 2023 Aug 28 by Vim Project (undo_indent)
" Created based on cpp.vim
"
" Ch is a C/C++ interpreter with many high level extensions
@@ -16,3 +17,5 @@ let b:did_indent = 1
" Ch indenting is built-in, thus this is very simple
setlocal cindent
+
+let b:undo_indent = "setlocal cindent<"
diff --git a/runtime/indent/cpp.vim b/runtime/indent/cpp.vim
index ffa37d7208..bb4dfd185e 100644
--- a/runtime/indent/cpp.vim
+++ b/runtime/indent/cpp.vim
@@ -1,7 +1,8 @@
" Vim indent file
" Language: C++
-" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2008 Nov 29
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 10
+" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
diff --git a/runtime/indent/cuda.vim b/runtime/indent/cuda.vim
index 68ee9cec0c..5980ddda44 100644
--- a/runtime/indent/cuda.vim
+++ b/runtime/indent/cuda.vim
@@ -1,7 +1,8 @@
" Vim indent file
" Language: CUDA
-" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2008 Nov 29
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 10
+" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
diff --git a/runtime/indent/dts.vim b/runtime/indent/dts.vim
new file mode 100644
index 0000000000..e87f8153c7
--- /dev/null
+++ b/runtime/indent/dts.vim
@@ -0,0 +1,63 @@
+" Vim indent file
+" Language: Device Tree
+" Maintainer: Roland Hieber, Pengutronix <rhi@pengutronix.de>
+"
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal autoindent
+setlocal nosmartindent
+setlocal indentkeys=o,O,0},0<>>,!<Ctrl-F>
+setlocal indentexpr=GetDTSIndent()
+setlocal nolisp
+
+let b:undo_indent = 'setl autoindent< smartindent< indentkeys< indentexpr< lisp<'
+
+function GetDTSIndent()
+ let sw = shiftwidth()
+ let lnum = v:lnum
+ let line = getline(lnum)
+ let prevline = getline(prevnonblank(lnum-1))
+ let prevind = indent(prevnonblank(lnum-1))
+
+ if prevnonblank(lnum-1) < 1
+ return 0
+ endif
+
+ " Don't indent header and preprocessor directives
+ if line =~ '^\s*\(/dts-\|#\(include\|define\|undef\|warn\(ing\)\?\|error\|if\(n\?def\)\?\|else\|elif\|endif\)\)'
+ return 0
+
+ " Don't indent /node and &label blocks
+ elseif line =~ '^\s*[/&].\+{\s*$'
+ return 0
+
+ " Indent to matching bracket or remove one shiftwidth if line begins with } or >
+ elseif line =~ '^\s*[}>]'
+ " set cursor to closing bracket on current line
+ let col = matchend(line, '^\s*[>}]')
+ call cursor(lnum, col)
+
+ " determine bracket type, {} or <>
+ let pair = strpart('{}<>', stridx('}>', line[col-1]) * 2, 2)
+
+ " find matching bracket pair
+ let pairline = searchpair(pair[0], '', pair[1], 'bW')
+
+ if pairline > 0
+ return indent(pairline)
+ else
+ return prevind - sw
+ endif
+
+ " else, add one level of indent if line ends in { or < or = or ,
+ elseif prevline =~ '[{<=,]$'
+ return prevind + sw
+
+ else
+ return prevind
+ endif
+
+endfunction
diff --git a/runtime/indent/dune.vim b/runtime/indent/dune.vim
index 0590d66d13..a9349e4e04 100644
--- a/runtime/indent/dune.vim
+++ b/runtime/indent/dune.vim
@@ -3,6 +3,7 @@
" Maintainers: Markus Mottl <markus.mottl@gmail.com>
" URL: https://github.com/ocaml/vim-ocaml
" Last Change: 2021 Jan 01
+" 2023 Aug 28 by Vim Project (undo_indent)
if exists("b:did_indent")
finish
@@ -11,3 +12,5 @@ let b:did_indent = 1
" dune format-dune-file uses 1 space to indent
setlocal softtabstop=1 shiftwidth=1 expandtab
+
+let b:undo_indent = "setl et< sts< sw<"
diff --git a/runtime/indent/erlang.vim b/runtime/indent/erlang.vim
index 7aa38587a6..5682c31ef3 100644
--- a/runtime/indent/erlang.vim
+++ b/runtime/indent/erlang.vim
@@ -1324,7 +1324,7 @@ function! s:ErlangCalcIndent2(lnum, stack)
" maybe A else
" LTI
"
- " Note about Emacs compabitility {{{
+ " Note about Emacs compatibility {{{
"
" It would be fine to indent the examples above the following way:
"
diff --git a/runtime/indent/fish.vim b/runtime/indent/fish.vim
new file mode 100644
index 0000000000..e7678cb7c8
--- /dev/null
+++ b/runtime/indent/fish.vim
@@ -0,0 +1,85 @@
+" Vim indent file
+" Language: fish
+" Maintainer: Nicholas Boyle (github.com/nickeb96)
+" Repository: https://github.com/nickeb96/fish.vim
+" Last Change: February 4, 2023
+" 2023 Aug 28 by Vim Project (undo_indent)
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetFishIndent(v:lnum)
+setlocal indentkeys+==end,=else,=case
+
+let b:undo_indent = "setlocal indentexpr< indentkeys<"
+
+function s:PrevCmdStart(linenum)
+ let l:linenum = a:linenum
+ " look for the first line that isn't a line continuation
+ while l:linenum > 1 && getline(l:linenum - 1) =~# '\\$'
+ let l:linenum = l:linenum - 1
+ endwhile
+ return l:linenum
+endfunction
+
+function GetFishIndent(lnum)
+ let l:shiftwidth = shiftwidth()
+
+ let l:prevlnum = prevnonblank(a:lnum - 1)
+ if l:prevlnum ==# 0
+ return 0
+ endif
+
+ " if the previous line ended with a line continuation
+ if getline(a:lnum - 1) =~# '\\$'
+ if a:lnum ==# 0 || getline(a:lnum - 2) !~# '\\$'
+ " this is the first line continuation in a chain, so indent it
+ return indent(a:lnum - 1) + l:shiftwidth
+ else
+ " use the same indentation as the previous continued line
+ return indent(a:lnum - 1)
+ endif
+ endif
+
+ let l:prevlnum = s:PrevCmdStart(l:prevlnum)
+
+ let l:prevline = getline(l:prevlnum)
+ if l:prevline =~# '^\s*\(begin\|if\|else\|while\|for\|function\|case\|switch\)\>'
+ let l:indent = l:shiftwidth
+ else
+ let l:indent = 0
+ endif
+
+ let l:line = getline(a:lnum)
+ if l:line =~# '^\s*end\>'
+ " find end's matching start
+ let l:depth = 1
+ let l:currentlnum = a:lnum
+ while l:depth > 0 && l:currentlnum > 0
+ let l:currentlnum = s:PrevCmdStart(prevnonblank(l:currentlnum - 1))
+ let l:currentline = getline(l:currentlnum)
+ if l:currentline =~# '^\s*end\>'
+ let l:depth = l:depth + 1
+ elseif l:currentline =~# '^\s*\(begin\|if\|while\|for\|function\|switch\)\>'
+ let l:depth = l:depth - 1
+ endif
+ endwhile
+ if l:currentline =~# '^\s*switch\>'
+ return indent(l:currentlnum)
+ else
+ return indent(l:prevlnum) + l:indent - l:shiftwidth
+ endif
+ elseif l:line =~# '^\s*else\>'
+ return indent(l:prevlnum) + l:indent - l:shiftwidth
+ elseif l:line =~# '^\s*case\>'
+ if getline(l:prevlnum) =~# '^\s*switch\>'
+ return indent(l:prevlnum) + l:indent
+ else
+ return indent(l:prevlnum) + l:indent - l:shiftwidth
+ endif
+ else
+ return indent(l:prevlnum) + l:indent
+ endif
+endfunction
diff --git a/runtime/indent/go.vim b/runtime/indent/go.vim
index bf9ff75e6c..a9b1d8d19b 100644
--- a/runtime/indent/go.vim
+++ b/runtime/indent/go.vim
@@ -2,6 +2,7 @@
" Language: Go
" Maintainer: David Barnett (https://github.com/google/vim-ft-go)
" Last Change: 2017 Jun 13
+" 2023 Aug 28 by Vim Project (undo_indent)
"
" TODO:
" - function invocations split across lines
@@ -19,6 +20,8 @@ setlocal autoindent
setlocal indentexpr=GoIndent(v:lnum)
setlocal indentkeys+=<:>,0=},0=)
+let b:undo_indent = "setl ai< inde< indk< lisp<"
+
if exists('*GoIndent')
finish
endif
diff --git a/runtime/indent/hare.vim b/runtime/indent/hare.vim
index bc4fea4e61..0a9d8dafd8 100644
--- a/runtime/indent/hare.vim
+++ b/runtime/indent/hare.vim
@@ -2,6 +2,7 @@
" Language: Hare
" Maintainer: Amelia Clarke <me@rsaihe.dev>
" Last Change: 2022 Sep 22
+" 2023 Aug 28 by Vim Project (undo_indent)
if exists("b:did_indent")
finish
@@ -40,6 +41,8 @@ setlocal cinwords=if,else,for,switch,match
setlocal indentexpr=GetHareIndent()
+let b:undo_indent = "setl cin< cino< cinw< inde< indk<"
+
function! FloorCindent(lnum)
return cindent(a:lnum) / shiftwidth() * shiftwidth()
endfunction
diff --git a/runtime/indent/html.vim b/runtime/indent/html.vim
index 65e0ffc40c..2fa10cc91e 100644
--- a/runtime/indent/html.vim
+++ b/runtime/indent/html.vim
@@ -1,7 +1,7 @@
" Vim indent script for HTML
-" Maintainer: Bram Moolenaar
+" Maintainer: The Vim Project <https://github.com/vim/vim>
" Original Author: Andy Wokula <anwoku@yahoo.de>
-" Last Change: 2022 Jan 31
+" Last Change: 2023 Aug 13
" Version: 1.0 "{{{
" Description: HTML indent script with cached state for faster indenting on a
" range of lines.
diff --git a/runtime/indent/jsonc.vim b/runtime/indent/jsonc.vim
index bf8e501dd5..058634a6d2 100644
--- a/runtime/indent/jsonc.vim
+++ b/runtime/indent/jsonc.vim
@@ -4,6 +4,7 @@
" Acknowledgement: Based off of vim-json maintained by Eli Parra <eli@elzr.com>
" https://github.com/elzr/vim-json
" Last Change: 2021-07-01
+" 2023 Aug 28 by Vim Project (undo_indent)
" 0. Initialization {{{1
" =================
@@ -20,6 +21,8 @@ setlocal nosmartindent
setlocal indentexpr=GetJSONCIndent()
setlocal indentkeys=0{,0},0),0[,0],!^F,o,O,e
+let b:undo_indent = "setlocal indentexpr< indentkeys< smartindent<"
+
" Only define the function once.
if exists("*GetJSONCIndent")
finish
diff --git a/runtime/indent/julia.vim b/runtime/indent/julia.vim
index 8e4c60322e..efc98a2851 100644
--- a/runtime/indent/julia.vim
+++ b/runtime/indent/julia.vim
@@ -3,7 +3,8 @@
" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
" Homepage: https://github.com/JuliaEditorSupport/julia-vim
" Last Change: 2022 Jun 14
-" Notes: originally based on Bram Molenaar's indent file for vim
+" 2023 Aug 28 by Vim Project (undo_indent)
+" Notes: originally based on Bram Moolenaar's indent file for vim
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -21,6 +22,8 @@ setlocal indentkeys-=0{
setlocal indentkeys-=0}
setlocal nosmartindent
+let b:undo_indent = "setl ai< inde< indk< si<"
+
" Only define the function once.
if exists("*GetJuliaIndent")
finish
@@ -307,7 +310,7 @@ function IsFunctionArgPar(lnum, c)
endfunction
function JumpToMatch(lnum, last_closed_bracket)
- " we use the % command to skip back (tries to ues matchit if possible,
+ " we use the % command to skip back (tries to use matchit if possible,
" otherwise resorts to vim's default, which is buggy but better than
" nothing)
call cursor(a:lnum, a:last_closed_bracket)
diff --git a/runtime/indent/kotlin.vim b/runtime/indent/kotlin.vim
new file mode 100644
index 0000000000..590a5074d1
--- /dev/null
+++ b/runtime/indent/kotlin.vim
@@ -0,0 +1,60 @@
+" Vim indent file
+" Language: Kotlin
+" Maintainer: Alexander Udalov
+" URL: https://github.com/udalov/kotlin-vim
+" Last Change: 7 November 2021
+" 2023 Sep 17 by Vim Project (undo_indent)
+
+if exists('b:did_indent')
+ finish
+endif
+let b:did_indent = 1
+
+setlocal cinoptions& cinoptions+=j1,L0
+setlocal indentexpr=GetKotlinIndent()
+setlocal indentkeys=0},0),!^F,o,O,e,<CR>
+setlocal autoindent " TODO ?
+
+let b:undo_indent = "setlocal autoindent< cinoptions< indentexpr< indentkeys<"
+
+" TODO teach it to count bracket balance, etc.
+function! GetKotlinIndent()
+ if v:lnum == 0
+ return 0
+ endif
+
+ let prev_num = prevnonblank(v:lnum - 1)
+ let prev = getline(prev_num)
+ let prev_indent = indent(prev_num)
+ let cur = getline(v:lnum)
+
+ if cur =~ '^\s*\*'
+ return cindent(v:lnum)
+ endif
+
+ if prev =~ '^\s*\*/'
+ let st = prev
+ while st > 1
+ if getline(st) =~ '^\s*/\*'
+ break
+ endif
+ let st = st - 1
+ endwhile
+ return indent(st)
+ endif
+
+ let prev_open_paren = prev =~ '^.*(\s*$'
+ let cur_close_paren = cur =~ '^\s*).*$'
+ let prev_open_brace = prev =~ '^.*\({\|->\)\s*$'
+ let cur_close_brace = cur =~ '^\s*}.*$'
+
+ if prev_open_paren && !cur_close_paren || prev_open_brace && !cur_close_brace
+ return prev_indent + shiftwidth()
+ endif
+
+ if cur_close_paren && !prev_open_paren || cur_close_brace && !prev_open_brace
+ return prev_indent - shiftwidth()
+ endif
+
+ return prev_indent
+endfunction
diff --git a/runtime/indent/krl.vim b/runtime/indent/krl.vim
index cc3cbd1abb..89f45356ba 100644
--- a/runtime/indent/krl.vim
+++ b/runtime/indent/krl.vim
@@ -41,7 +41,7 @@ function GetKrlIndent() abort
let currentLine = getline(v:lnum)
if currentLine =~? '\v^;(\s*(end)?fold>)@!' && !get(g:, 'krlCommentIndent', 0)
" If current line has a ; in column 1 and is no fold, keep zero indent.
- " This may be usefull if code is commented out at the first column.
+ " This may be useful if code is commented out at the first column.
return 0
endif
@@ -117,7 +117,7 @@ function s:KrlPreNoneBlank(lnum) abort
let nPreNoneBlank = prevnonblank(a:lnum)
while nPreNoneBlank > 0 && getline(nPreNoneBlank) =~? '\v^\s*(\&\w\+|;|continue>)'
- " Previouse none blank line irrelevant. Look further aback.
+ " Previous none blank line irrelevant. Look further aback.
let nPreNoneBlank = prevnonblank(nPreNoneBlank - 1)
endwhile
diff --git a/runtime/indent/livebook.vim b/runtime/indent/livebook.vim
new file mode 100644
index 0000000000..6311050e0e
--- /dev/null
+++ b/runtime/indent/livebook.vim
@@ -0,0 +1,9 @@
+" Placeholder livebook indent file.
+" This simply uses the markdown indenting.
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+runtime! indent/markdown.vim
diff --git a/runtime/indent/logtalk.vim b/runtime/indent/logtalk.vim
index 8e36f86115..f7a8b0387c 100644
--- a/runtime/indent/logtalk.vim
+++ b/runtime/indent/logtalk.vim
@@ -1,5 +1,6 @@
" Maintainer: Paulo Moura <pmoura@logtalk.org>
" Revised on: 2018.08.04
+" 2023 Aug 28 by Vim Project (undo_indent)
" Language: Logtalk
" This Logtalk indent file is a modified version of the Prolog
@@ -16,6 +17,8 @@ setlocal indentexpr=GetLogtalkIndent()
setlocal indentkeys-=:,0#
setlocal indentkeys+=0%,-,0;,>,0)
+let b:undo_indent = "setlocal indentexpr< indentkeys<"
+
" Only define the function once.
if exists("*GetLogtalkIndent")
finish
diff --git a/runtime/indent/lua.vim b/runtime/indent/lua.vim
index 0d1f934a03..35b08d4037 100644
--- a/runtime/indent/lua.vim
+++ b/runtime/indent/lua.vim
@@ -27,6 +27,16 @@ if exists("*GetLuaIndent")
endif
function! GetLuaIndent()
+ let ignorecase_save = &ignorecase
+ try
+ let &ignorecase = 0
+ return GetLuaIndentIntern()
+ finally
+ let &ignorecase = ignorecase_save
+ endtry
+endfunction
+
+function! GetLuaIndentIntern()
" Find a non-blank line above the current line.
let prevlnum = prevnonblank(v:lnum - 1)
@@ -41,7 +51,7 @@ function! GetLuaIndent()
let prevline = getline(prevlnum)
let midx = match(prevline, '^\s*\%(if\>\|for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>\)')
if midx == -1
- let midx = match(prevline, '{\s*$')
+ let midx = match(prevline, '{\s*\%(--\%([^[].*\)\?\)\?$')
if midx == -1
let midx = match(prevline, '\<function\>\s*\%(\k\|[.:]\)\{-}\s*(')
endif
diff --git a/runtime/indent/luau.vim b/runtime/indent/luau.vim
new file mode 100644
index 0000000000..69893f7399
--- /dev/null
+++ b/runtime/indent/luau.vim
@@ -0,0 +1,14 @@
+" Vim filetype indent file
+" Language: Luau
+" Maintainer: None yet
+" Last Change: 2023 Apr 30
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+" Luau is a superset of Lua
+runtime! indent/lua.vim
+
+
diff --git a/runtime/indent/mail.vim b/runtime/indent/mail.vim
index 22bb0f7e12..eec9b4e43d 100644
--- a/runtime/indent/mail.vim
+++ b/runtime/indent/mail.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: Mail
-" Maintainer: Bram Moolenaar
-" Last Change: 2021 Sep 26
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 13
if exists("b:did_indent")
finish
diff --git a/runtime/indent/nsis.vim b/runtime/indent/nsis.vim
index 5d3decca37..3731781201 100644
--- a/runtime/indent/nsis.vim
+++ b/runtime/indent/nsis.vim
@@ -15,7 +15,7 @@ setlocal nosmartindent
setlocal noautoindent
setlocal indentexpr=GetNsisIndent(v:lnum)
setlocal indentkeys=!^F,o,O
-setlocal indentkeys+==~${Else,=~${EndIf,=~${EndUnless,=~${AndIf,=~${AndUnless,=~${OrIf,=~${OrUnless,=~${Case,=~${Default,=~${EndSelect,=~${EndSwith,=~${Loop,=~${Next,=~${MementoSectionEnd,=~FunctionEnd,=~SectionEnd,=~SectionGroupEnd,=~PageExEnd,0=~!macroend,0=~!if,0=~!else,0=~!endif
+setlocal indentkeys+==~${Else,=~${EndIf,=~${EndUnless,=~${AndIf,=~${AndUnless,=~${OrIf,=~${OrUnless,=~${Case,=~${Default,=~${EndSelect,=~${EndSwitch,=~${Loop,=~${Next,=~${MementoSectionEnd,=~FunctionEnd,=~SectionEnd,=~SectionGroupEnd,=~PageExEnd,0=~!macroend,0=~!if,0=~!else,0=~!endif
let b:undo_indent = "setl ai< inde< indk< si<"
diff --git a/runtime/indent/ocaml.vim b/runtime/indent/ocaml.vim
index 19c81f49c4..c9beb8be0b 100644
--- a/runtime/indent/ocaml.vim
+++ b/runtime/indent/ocaml.vim
@@ -4,7 +4,8 @@
" Mike Leary <leary@nwlink.com>
" Markus Mottl <markus.mottl@gmail.com>
" URL: https://github.com/ocaml/vim-ocaml
-" Last Change: 2017 Jun 13
+" Last Change: 2023 Aug 28 - Add undo_indent (Vim Project)
+" 2017 Jun 13
" 2005 Jun 25 - Fixed multiple bugs due to 'else\nreturn ind' working
" 2005 May 09 - Added an option to not indent OCaml-indents specially (MM)
" 2013 June - commented textwidth (Marc Weber)
@@ -24,6 +25,8 @@ setlocal indentkeys+=0=and,0=class,0=constraint,0=done,0=else,0=end,0=exception,
setlocal nolisp
setlocal nosmartindent
+let b:undo_indent = "setl et< inde< indk< lisp< si<"
+
" At least Marc Weber and Markus Mottl do not like this:
" setlocal textwidth=80
diff --git a/runtime/indent/perl.vim b/runtime/indent/perl.vim
index 4c91fa1b33..a97c34da53 100644
--- a/runtime/indent/perl.vim
+++ b/runtime/indent/perl.vim
@@ -4,7 +4,7 @@
" Homepage: https://github.com/vim-perl/vim-perl
" Bugs/requests: https://github.com/vim-perl/vim-perl/issues
" License: Vim License (see :help license)
-" Last Change: 2021 Sep 24
+" Last Change: 2022 Jun 14
" Suggestions and improvements by :
" Aaron J. Sherman (use syntax for hints)
@@ -133,6 +133,7 @@ function! GetPerlIndent()
\ || synid == "perlHereDoc"
\ || synid == "perlBraces"
\ || synid == "perlStatementIndirObj"
+ \ || synid == "perlSubDeclaration"
\ || synid =~ "^perlFiledescStatement"
\ || synid =~ '^perl\(Sub\|Block\|Package\)Fold'
let brace = strpart(line, bracepos, 1)
diff --git a/runtime/indent/php.vim b/runtime/indent/php.vim
index 0e623689d5..377ffd5afb 100644
--- a/runtime/indent/php.vim
+++ b/runtime/indent/php.vim
@@ -3,8 +3,8 @@
" Author: John Wellesz <John.wellesz (AT) gmail (DOT) com>
" URL: https://www.2072productions.com/vim/indent/php.vim
" Home: https://github.com/2072/PHP-Indenting-for-VIm
-" Last Change: 2020 Mar 05
-" Version: 1.70
+" Last Change: 2023 August 18th
+" Version: 1.75
"
"
" Type :help php-indent for available options
@@ -128,7 +128,7 @@ setlocal nolisp
setlocal indentexpr=GetPhpIndent()
setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e,*<Return>,=?>,=<?,=*/
-
+let b:undo_indent = "setl ai< cin< inde< indk< lisp< si<"
let s:searchpairflags = 'bWr'
@@ -142,10 +142,10 @@ if exists("*GetPhpIndent")
endif
-let s:endline = '\s*\%(//.*\|#.*\|/\*.*\*/\s*\)\=$'
+let s:endline = '\s*\%(//.*\|#\[\@!.*\|/\*.*\*/\s*\)\=$'
let s:PHP_validVariable = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
-let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|die\|else\|end\%(if\|while\|for\|foreach\|switch\)\)'
-let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|\%(}\s*\)\?else\>\|do\>\|while\>\|switch\>\|case\>\|default\>\|for\%(each\)\=\>\|declare\>\|class\>\|trait\>\|\%()\s*\)\=use\>\|interface\>\|abstract\>\|final\>\|try\>\|\%(}\s*\)\=catch\>\|\%(}\s*\)\=finally\>\)'
+let s:notPhpHereDoc = '\<\%(break\|return\|continue\|exit\|die\|true\|false\|elseif\|else\|end\%(if\|while\|for\|foreach\|match\|switch\)\)\>'
+let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|\%(}\s*\)\?else\>\|do\>\|while\>\|match\>\|switch\>\|case\>\|default\>\|for\%(each\)\=\>\|declare\>\|class\>\|trait\>\|\%()\s*\)\=use\>\|interface\>\|abstract\>\|final\>\|try\>\|\%(}\s*\)\=catch\>\|\%(}\s*\)\=finally\>\)'
let s:functionDeclPrefix = '\<function\>\%(\s\+&\='.s:PHP_validVariable.'\)\=\s*('
let s:functionDecl = s:functionDeclPrefix.'.*'
let s:multilineFunctionDecl = s:functionDeclPrefix.s:endline
@@ -156,7 +156,8 @@ let s:unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@<!\<e'.'lse\>\)'.s:endl
let s:terminated = '\%(\%(;\%(\s*\%(?>\|}\)\)\=\|<<<\s*[''"]\=\a\w*[''"]\=$\|^\s*}\|^\s*'.s:PHP_validVariable.':\)'.s:endline.'\)'
let s:PHP_startindenttag = '<?\%(.*?>\)\@!\|<script[^>]*>\%(.*<\/script>\)\@!'
-let s:structureHead = '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline . '\|\<new\s\+class\>'
+let s:matchStart = 'match\s*(\s*\$\?'.s:PHP_validVariable.'\s*)\s*{'. s:endline
+let s:structureHead = '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline . '\|\<new\s\+class\>\|' . s:matchStart
let s:escapeDebugStops = 0
@@ -223,7 +224,7 @@ function! GetLastRealCodeLNum(startline) " {{{
while getline(lnum) !~? tofind && lnum > 1
let lnum = lnum - 1
endwhile
- elseif lastline =~ '^\s*[''"`][;,]' || (lastline =~ '^[^''"`]*[''"`][;,]'.s:endline && IslinePHP(lnum, "") == "SpecStringEntrails")
+ elseif lastline =~ '^\s*[''"`][;,]'.s:endline || (lastline =~ '^[^''"`]*[''"`][;,]'.s:endline && IslinePHP(lnum, "") == "SpecStringEntrails")
let tofind=substitute( lastline, '^.*\([''"`]\)[;,].*$', '^[^\1]\\+[\1]$\\|^[^\1]\\+[=([]\\s*[\1]', '')
let trylnum = lnum
@@ -266,7 +267,7 @@ function! Skippmatch2()
let line = getline(".")
- if line =~ "\\([\"']\\).*/\\*.*\\1" || line =~ '\%(//\|#\).*/\*'
+ if line =~ "\\([\"']\\).*/\\*.*\\1" || line =~ '\%(//\|#\[\@!\).*/\*'
return 1
else
return 0
@@ -322,18 +323,22 @@ function! BalanceDirection (str)
endfun
function! StripEndlineComments (line)
- return substitute(a:line,"\\(//\\|#\\)\\(\\(\\([^\"']*\\([\"']\\)[^\"']*\\5\\)\\+[^\"']*$\\)\\|\\([^\"']*$\\)\\)",'','')
+
+ let cleaned = substitute(a:line,'\v(//|#\[\@!)((([^"'']*(["''])[^"'']*\5)+[^"'']*$)|([^"'']*$))','','')
+ if cleaned != a:line
+ endif
+ return cleaned
endfun
function! FindArrowIndent (lnum) " {{{
- let parrentArrowPos = -1
+ let parentArrowPos = -1
let cursorPos = -1
let lnum = a:lnum
while lnum > 1
let last_line = getline(lnum)
if last_line =~ '^\s*->'
- let parrentArrowPos = indent(a:lnum)
+ let parentArrowPos = indent(a:lnum)
break
else
@@ -355,28 +360,28 @@ function! FindArrowIndent (lnum) " {{{
else
endif
else
- let parrentArrowPos = -1
+ let parentArrowPos = -1
break
end
endif
if cleanedLnum =~ '->'
call cursor(lnum, cursorPos == -1 ? strwidth(cleanedLnum) : cursorPos)
- let parrentArrowPos = searchpos('->', 'cWb', lnum)[1] - 1
+ let parentArrowPos = searchpos('->', 'cWb', lnum)[1] - 1
break
else
- let parrentArrowPos = -1
+ let parentArrowPos = -1
break
endif
endif
endwhile
- if parrentArrowPos == -1
- let parrentArrowPos = indent(lnum) + shiftwidth()
+ if parentArrowPos == -1
+ let parentArrowPos = indent(lnum) + shiftwidth()
end
- return parrentArrowPos
+ return parentArrowPos
endfun "}}}
function! FindTheIfOfAnElse (lnum, StopAfterFirstPrevElse) " {{{
@@ -490,7 +495,7 @@ function! ResetPhpOptions()
if ! b:optionsset && &filetype =~ "php"
if b:PHP_autoformatcomment
- setlocal comments=s1:/*,mb:*,ex:*/,://,:#
+ setlocal comments=s1:/*,mb:*,ex:*/,://,f:#[,:#
setlocal formatoptions-=t
setlocal formatoptions+=q
@@ -506,7 +511,7 @@ endfunc
call ResetPhpOptions()
function! GetPhpIndentVersion()
- return "1.70-bundle"
+ return "1.75"
endfun
function! GetPhpIndent()
@@ -650,7 +655,7 @@ function! GetPhpIndent()
let b:InPHPcode_and_script = 1
endif
- elseif last_line =~ '^[^''"`]\+[''"`]$' && last_line !~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)' " a string identifier with nothing after it and no other string identifier before
+ elseif last_line =~ '^[^''"`]\+[''"`]$' && last_line !~ '^\s*\%(//\|#\[\@!\|/\*.*\*/\s*$\)' " a string identifier with nothing after it and no other string identifier before
let b:InPHPcode = -1
let b:InPHPcode_tofind = substitute( last_line, '^.*\([''"`]\).*$', '^[^\1]*\1[;,]$', '')
elseif last_line =~? '<<<\s*[''"]\=\a\w*[''"]\=$'
@@ -674,7 +679,7 @@ function! GetPhpIndent()
" Indent successive // or # comment the same way the first is {{{
let addSpecial = 0
- if cline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)'
+ if cline =~ '^\s*\%(//\|#\[\@!\|/\*.*\*/\s*$\)'
let addSpecial = b:PHP_outdentSLComments
if b:PHP_LastIndentedWasComment == 1
return indent(real_PHP_lastindented)
@@ -715,7 +720,7 @@ function! GetPhpIndent()
return 0
endif
- if cline =~? '^\s*\a\w*;$\|^\a\w*$\|^\s*[''"`][;,]' && cline !~? s:notPhpHereDoc
+ if (cline =~? '^\s*\a\w*;$\|^\a\w*$' || (cline =~? '^\s*[''"`][;,]' && IslinePHP(v:lnum, '[;,]') !~? '^\(phpString[SD]\|phpBacktick\)') ) && cline !~? s:notPhpHereDoc
return 0
endif " }}}
@@ -738,6 +743,9 @@ function! GetPhpIndent()
if cline =~ '^\s*}\%(}}\)\@!'
let ind = indent(FindOpenBracket(v:lnum, 1))
let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
+ if b:PHP_BracesAtCodeLevel
+ let ind = ind + shiftwidth()
+ endif
return ind
endif
@@ -761,7 +769,7 @@ function! GetPhpIndent()
if last_line =~ '[;}]'.endline && last_line !~ '^[)\]]' && last_line !~# s:defaultORcase && last_line !~ '^\s*[''"`][;,]'
if ind==b:PHP_default_indenting
return b:PHP_default_indenting + addSpecial
- elseif b:PHP_indentinghuge && ind==b:PHP_CurrentIndentLevel && cline !~# '^\s*\%(else\|\%(case\|default\).*:\|[})];\=\)' && last_line !~# '^\s*\%(\%(}\s*\)\=else\)' && getline(GetLastRealCodeLNum(lnum - 1))=~';'.endline
+ elseif b:PHP_indentinghuge && ind==b:PHP_CurrentIndentLevel && cline !~# '^\s*\%(else\|\%(case\|default\).*:\|[})];\=\)' && last_line !~# '^\s*\%(\%(}\s*\)\=else\)\|^\(\s*\S\+\s*\)\+}'.endline && getline(GetLastRealCodeLNum(lnum - 1))=~';'.endline
return b:PHP_CurrentIndentLevel + addSpecial
endif
endif
@@ -929,7 +937,7 @@ function! GetPhpIndent()
let ind = ind + shiftwidth()
- elseif AntepenultimateLine =~ '{'.endline && AntepenultimateLine !~? '^\s*use\>' || AntepenultimateLine =~ terminated || AntepenultimateLine =~# s:defaultORcase
+ elseif AntepenultimateLine =~ '{'.endline && AntepenultimateLine !~? '^\s*use\>' && AntepenultimateLine !~? s:matchStart || AntepenultimateLine =~ terminated || AntepenultimateLine =~# s:defaultORcase
let ind = ind + shiftwidth()
endif
diff --git a/runtime/indent/python.vim b/runtime/indent/python.vim
index 8c3d0b0670..42ab4f3778 100644
--- a/runtime/indent/python.vim
+++ b/runtime/indent/python.vim
@@ -1,8 +1,9 @@
" Vim indent file
-" Language: Python
-" Maintainer: Bram Moolenaar <Bram@vim.org>
+" Language: Python
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 10
+" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Original Author: David Bustos <bustos@caltech.edu>
-" Last Change: 2021 Sep 26
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
diff --git a/runtime/indent/qml.vim b/runtime/indent/qml.vim
new file mode 100644
index 0000000000..8c9fa91250
--- /dev/null
+++ b/runtime/indent/qml.vim
@@ -0,0 +1,59 @@
+" Vim indent file
+" Language: QML
+" Maintainer: Chase Knowlden <haroldknowlden@gmail.com>
+" Last Change: 2023 Aug 16
+"
+" Improved JavaScript indent script.
+
+" Indent script in place for this already?
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+let b:undo_indent = "setlocal indentexpr< indentkeys<"
+
+setlocal indentexpr=s:GetQmlIndent()
+setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e,*<Return>,=*/
+
+" Only define functions once per session
+if exists("*s:GetQmlIndent")
+ finish
+endif
+
+" Clean up a line of code by removing trailing '//' and '/* */' comments, and trimming
+" whitespace
+function! s:Trim(line)
+ return substitute(substitute(substitute(a:line, '// .*', '', ''), '/\* .* \*/', '', ''), '^\s*\|\s*$', '', 'g')
+endfunction
+
+function! s:GetQmlIndent()
+ let num = v:lnum
+ let line = s:Trim(getline(num))
+
+ let pnum = prevnonblank(num - 1)
+ if pnum == 0
+ return 0
+ endif
+ let pline = s:Trim(getline(pnum))
+
+ let ind = indent(pnum)
+
+ " bracket/brace/paren blocks
+ if pline =~ '[{[(]$'
+ let ind += &sw
+ endif
+ if line =~ '^[}\])]'
+ let ind -= &sw
+ endif
+
+ " '/*' comments
+ if pline =~ '^/\*.*\*/'
+ " no indent for single-line form
+ elseif pline =~ '^/\*'
+ let ind += 1
+ elseif pline =~ '^\*/'
+ let ind -= 1
+ endif
+
+ return ind
+endfunction
diff --git a/runtime/indent/quarto.vim b/runtime/indent/quarto.vim
new file mode 100644
index 0000000000..586d232d2b
--- /dev/null
+++ b/runtime/indent/quarto.vim
@@ -0,0 +1 @@
+runtime indent/rmd.vim
diff --git a/runtime/indent/r.vim b/runtime/indent/r.vim
index ca85a2e62d..07dfd13881 100644
--- a/runtime/indent/r.vim
+++ b/runtime/indent/r.vim
@@ -2,7 +2,7 @@
" Language: R
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Sun Aug 19, 2018 09:13PM
+" Last Change: Mon Feb 27, 2023 07:16PM
" Only load this indent file when no other was loaded.
@@ -14,6 +14,8 @@ let b:did_indent = 1
setlocal indentkeys=0{,0},:,!^F,o,O,e
setlocal indentexpr=GetRIndent()
+let b:undo_indent = "setl inde< indk<"
+
" Only define the function once.
if exists("*GetRIndent")
finish
@@ -28,7 +30,7 @@ let g:r_indent_ess_comments = get(g:, 'r_indent_ess_comments', 0)
let g:r_indent_comment_column = get(g:, 'r_indent_comment_column', 40)
let g:r_indent_ess_compatible = get(g:, 'r_indent_ess_compatible', 0)
let g:r_indent_op_pattern = get(g:, 'r_indent_op_pattern',
- \ '\(&\||\|+\|-\|\*\|/\|=\|\~\|%\|->\)\s*$')
+ \ '\(&\||\|+\|-\|\*\|/\|=\|\~\|%\|->\||>\)\s*$')
function s:RDelete_quotes(line)
let i = 0
@@ -108,7 +110,7 @@ function s:RDelete_parens(line)
return line1
endfunction
-function! s:Get_paren_balance(line, o, c)
+function s:Get_paren_balance(line, o, c)
let line2 = substitute(a:line, a:o, "", "g")
let openp = strlen(a:line) - strlen(line2)
let line3 = substitute(line2, a:c, "", "g")
@@ -116,7 +118,7 @@ function! s:Get_paren_balance(line, o, c)
return openp - closep
endfunction
-function! s:Get_matching_brace(linenr, o, c, delbrace)
+function s:Get_matching_brace(linenr, o, c, delbrace)
let line = SanitizeRLine(getline(a:linenr))
if a:delbrace == 1
let line = substitute(line, '{$', "", "")
@@ -132,7 +134,7 @@ endfunction
" This function is buggy because there 'if's without 'else'
" It must be rewritten relying more on indentation
-function! s:Get_matching_if(linenr, delif)
+function s:Get_matching_if(linenr, delif)
let line = SanitizeRLine(getline(a:linenr))
if a:delif
let line = substitute(line, "if", "", "g")
@@ -160,7 +162,7 @@ function! s:Get_matching_if(linenr, delif)
endif
endfunction
-function! s:Get_last_paren_idx(line, o, c, pb)
+function s:Get_last_paren_idx(line, o, c, pb)
let blc = a:pb
let line = substitute(a:line, '\t', s:curtabstop, "g")
let theidx = -1
@@ -359,17 +361,19 @@ function GetRIndent()
let olnum = s:Get_prev_line(lnum)
let oline = getline(olnum)
if olnum > 0
- if line =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
- if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
+ if substitute(line, '#.*', '', '') =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
+ if substitute(oline, '#.*', '', '') =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
return indent(lnum)
else
return indent(lnum) + shiftwidth()
endif
else
- if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
+ if substitute(oline, '#.*', '', '') =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
return indent(lnum) - shiftwidth()
endif
endif
+ elseif substitute(line, '#.*', '', '') =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
+ return indent(lnum) + shiftwidth()
endif
let post_fun = 0
diff --git a/runtime/indent/raku.vim b/runtime/indent/raku.vim
index 3f9b49ec77..753a2b04be 100644
--- a/runtime/indent/raku.vim
+++ b/runtime/indent/raku.vim
@@ -4,6 +4,7 @@
" Homepage: https://github.com/vim-perl/vim-perl
" Bugs/requests: https://github.com/vim-perl/vim-perl/issues
" Last Change: 2020 Apr 15
+" 2023 Aug 28 by Vim Project (undo_indent)
" Contributors: Andy Lester <andy@petdance.com>
" Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
"
@@ -47,6 +48,8 @@ if !b:indent_use_syntax
setlocal indentkeys+=0=EO
endif
+let b:undo_indent = "setlocal indentexpr< indentkeys<"
+
let s:cpo_save = &cpo
set cpo-=C
diff --git a/runtime/indent/rapid.vim b/runtime/indent/rapid.vim
new file mode 100644
index 0000000000..b1fa00b8cc
--- /dev/null
+++ b/runtime/indent/rapid.vim
@@ -0,0 +1,255 @@
+" ABB Rapid Command indent file for Vim
+" Language: ABB Rapid Command
+" Maintainer: Patrick Meiser-Knosowski <knosowski@graeffrobotics.de>
+" Version: 2.2.7
+" Last Change: 12. May 2023
+" Credits: Based on indent/vim.vim
+"
+" Suggestions of improvement are very welcome. Please email me!
+"
+" Known bugs: ../doc/rapid.txt
+"
+" TODO
+" * indent wrapped lines which do not end with an ; or special key word,
+" maybe this is a better idea, but then () and [] has to be changed as
+" well
+"
+
+if exists("g:rapidNoSpaceIndent")
+ if !exists("g:rapidSpaceIndent")
+ let g:rapidSpaceIndent = !g:rapidNoSpaceIndent
+ endif
+ unlet g:rapidNoSpaceIndent
+endif
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent") || get(g:,'rapidNoIndent',0)
+ finish
+endif
+let b:did_indent = 1
+
+setlocal nolisp
+setlocal nosmartindent
+setlocal autoindent
+setlocal indentexpr=GetRapidIndent()
+if get(g:,'rapidNewStyleIndent',0)
+ setlocal indentkeys=!^F,o,O,0=~endmodule,0=~error,0=~undo,0=~backward,0=~endproc,0=~endrecord,0=~endtrap,0=~endfunc,0=~else,0=~endif,0=~endtest,0=~endfor,0=~endwhile,:,<[>,<]>,<(>,<)>
+else
+ setlocal indentkeys=!^F,o,O,0=~endmodule,0=~error,0=~undo,0=~backward,0=~endproc,0=~endrecord,0=~endtrap,0=~endfunc,0=~else,0=~endif,0=~endtest,0=~endfor,0=~endwhile,:
+endif
+let b:undo_indent="setlocal lisp< si< ai< inde< indk<"
+
+if get(g:,'rapidSpaceIndent',1)
+ " Use spaces for indention, 2 is enough.
+ " More or even tabs wastes space on the teach pendant.
+ setlocal softtabstop=2
+ setlocal shiftwidth=2
+ setlocal expandtab
+ setlocal shiftround
+ let b:undo_indent = b:undo_indent." sts< sw< et< sr<"
+endif
+
+" Only define the function once.
+if exists("*GetRapidIndent")
+ finish
+endif
+
+let s:keepcpo= &cpo
+set cpo&vim
+
+function GetRapidIndent()
+ let ignorecase_save = &ignorecase
+ try
+ let &ignorecase = 0
+ return s:GetRapidIndentIntern()
+ finally
+ let &ignorecase = ignorecase_save
+ endtry
+endfunction
+
+function s:GetRapidIndentIntern() abort
+
+ let l:currentLineNum = v:lnum
+ let l:currentLine = getline(l:currentLineNum)
+
+ if l:currentLine =~ '^!' && !get(g:,'rapidCommentIndent',0)
+ " If current line is ! line comment, do not change indent
+ " This may be useful if code is commented out at the first column.
+ return 0
+ endif
+
+ " Find a non-blank line above the current line.
+ let l:preNoneBlankLineNum = s:RapidPreNoneBlank(v:lnum - 1)
+ if l:preNoneBlankLineNum == 0
+ " At the start of the file use zero indent.
+ return 0
+ endif
+
+ let l:preNoneBlankLine = getline(l:preNoneBlankLineNum)
+ let l:ind = indent(l:preNoneBlankLineNum)
+
+ " Define add a 'shiftwidth' pattern
+ let l:addShiftwidthPattern = '\c\v^\s*('
+ let l:addShiftwidthPattern .= '((local|task)\s+)?(module|record|proc|func|trap)\s+\k'
+ let l:addShiftwidthPattern .= '|(backward|error|undo)>'
+ let l:addShiftwidthPattern .= ')'
+ "
+ " Define Subtract 'shiftwidth' pattern
+ let l:subtractShiftwidthPattern = '\c\v^\s*('
+ let l:subtractShiftwidthPattern .= 'end(module|record|proc|func|trap)>'
+ let l:subtractShiftwidthPattern .= '|(backward|error|undo)>'
+ let l:subtractShiftwidthPattern .= ')'
+
+ " Add shiftwidth
+ if l:preNoneBlankLine =~ l:addShiftwidthPattern
+ \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "then", 0)>=0
+ \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "else", 0)>=0
+ \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "do", 0)>=0
+ \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "case", 0)>=0
+ \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "default", 0)>=0
+ let l:ind += &sw
+ endif
+
+ " Subtract shiftwidth
+ if l:currentLine =~ l:subtractShiftwidthPattern
+ \|| s:RapidLenTilStr(l:currentLineNum, "endif", 0)>=0
+ \|| s:RapidLenTilStr(l:currentLineNum, "endfor", 0)>=0
+ \|| s:RapidLenTilStr(l:currentLineNum, "endwhile", 0)>=0
+ \|| s:RapidLenTilStr(l:currentLineNum, "endtest", 0)>=0
+ \|| s:RapidLenTilStr(l:currentLineNum, "else", 0)>=0
+ \|| s:RapidLenTilStr(l:currentLineNum, "elseif", 0)>=0
+ \|| s:RapidLenTilStr(l:currentLineNum, "case", 0)>=0
+ \|| s:RapidLenTilStr(l:currentLineNum, "default", 0)>=0
+ let l:ind = l:ind - &sw
+ endif
+
+ " First case (or default) after a test gets the indent of the test.
+ if (s:RapidLenTilStr(l:currentLineNum, "case", 0)>=0 || s:RapidLenTilStr(l:currentLineNum, "default", 0)>=0) && s:RapidLenTilStr(l:preNoneBlankLineNum, "test", 0)>=0
+ let l:ind += &sw
+ endif
+
+ " continued lines with () or []
+ let l:OpenSum = s:RapidLoneParen(l:preNoneBlankLineNum,"(") + s:RapidLoneParen(l:preNoneBlankLineNum,"[")
+ if get(g:,'rapidNewStyleIndent',0)
+ let l:CloseSum = s:RapidLoneParen(l:preNoneBlankLineNum,")") + s:RapidLoneParen(l:currentLineNum,"]")
+ else
+ let l:CloseSum = s:RapidLoneParen(l:preNoneBlankLineNum,")") + s:RapidLoneParen(l:preNoneBlankLineNum,"]")
+ endif
+ if l:OpenSum > l:CloseSum
+ let l:ind += (l:OpenSum * 4 * &sw)
+ elseif l:OpenSum < l:CloseSum
+ let l:ind -= (l:CloseSum * 4 * &sw)
+ endif
+
+ return l:ind
+endfunction
+
+" Returns the length of the line until a:str occur outside a string or
+" comment. Search starts at string index a:startIdx.
+" If a:str is a word also add word boundaries and case insensitivity.
+" Note: rapidTodoComment and rapidDebugComment are not taken into account.
+function s:RapidLenTilStr(lnum, str, startIdx) abort
+
+ let l:line = getline(a:lnum)
+ let l:len = strlen(l:line)
+ let l:idx = a:startIdx
+ let l:str = a:str
+ if l:str =~ '^\k\+$'
+ let l:str = '\c\<' . l:str . '\>'
+ endif
+
+ while l:len > l:idx
+ let l:idx = match(l:line, l:str, l:idx)
+ if l:idx < 0
+ " a:str not found
+ return -1
+ endif
+ let l:synName = synIDattr(synID(a:lnum,l:idx+1,0),"name")
+ if l:synName != "rapidString"
+ \&& l:synName != "rapidConcealableString"
+ \&& (l:synName != "rapidComment" || l:str =~ '^!')
+ " a:str found outside string or line comment
+ return l:idx
+ endif
+ " a:str is part of string or line comment
+ let l:idx += 1 " continue search for a:str
+ endwhile
+
+ " a:str not found or l:len <= a:startIdx
+ return -1
+endfunction
+
+" a:lchar should be one of (, ), [, ], { or }
+" returns the number of opening/closing parentheses which have no
+" closing/opening match in getline(a:lnum)
+function s:RapidLoneParen(lnum,lchar) abort
+ if a:lchar == "(" || a:lchar == ")"
+ let l:opnParChar = "("
+ let l:clsParChar = ")"
+ elseif a:lchar == "[" || a:lchar == "]"
+ let l:opnParChar = "["
+ let l:clsParChar = "]"
+ elseif a:lchar == "{" || a:lchar == "}"
+ let l:opnParChar = "{"
+ let l:clsParChar = "}"
+ else
+ return 0
+ endif
+
+ let l:line = getline(a:lnum)
+
+ " look for the first ! which is not part of a string
+ let l:len = s:RapidLenTilStr(a:lnum,"!",0)
+ if l:len == 0
+ return 0 " first char is !; ignored
+ endif
+
+ let l:opnParen = 0
+ " count opening brackets
+ let l:i = 0
+ while l:i >= 0
+ let l:i = s:RapidLenTilStr(a:lnum, l:opnParChar, l:i)
+ if l:i >= 0
+ let l:opnParen += 1
+ let l:i += 1
+ endif
+ endwhile
+
+ let l:clsParen = 0
+ " count closing brackets
+ let l:i = 0
+ while l:i >= 0
+ let l:i = s:RapidLenTilStr(a:lnum, l:clsParChar, l:i)
+ if l:i >= 0
+ let l:clsParen += 1
+ let l:i += 1
+ endif
+ endwhile
+
+ if (a:lchar == "(" || a:lchar == "[" || a:lchar == "{") && l:opnParen>l:clsParen
+ return (l:opnParen-l:clsParen)
+ elseif (a:lchar == ")" || a:lchar == "]" || a:lchar == "}") && l:clsParen>l:opnParen
+ return (l:clsParen-l:opnParen)
+ endif
+
+ return 0
+endfunction
+
+" This function works almost like prevnonblank() but handles %%%-headers and
+" comments like blank lines
+function s:RapidPreNoneBlank(lnum) abort
+
+ let nPreNoneBlank = prevnonblank(a:lnum)
+
+ while nPreNoneBlank>0 && getline(nPreNoneBlank) =~ '\v\c^\s*(\%\%\%|!)'
+ " Previous none blank line irrelevant. Look further aback.
+ let nPreNoneBlank = prevnonblank(nPreNoneBlank - 1)
+ endwhile
+
+ return nPreNoneBlank
+endfunction
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
+
+" vim:sw=2 sts=2 et
diff --git a/runtime/indent/rhelp.vim b/runtime/indent/rhelp.vim
index cf69ae3392..334802ab78 100644
--- a/runtime/indent/rhelp.vim
+++ b/runtime/indent/rhelp.vim
@@ -2,7 +2,7 @@
" Language: R Documentation (Help), *.Rd
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Tue Apr 07, 2015 04:38PM
+" Last Change: Mon Feb 27, 2023 07:01PM
" Only load this indent file when no other was loaded.
@@ -20,6 +20,8 @@ setlocal nolisp
setlocal indentkeys=0{,0},:,!^F,o,O,e
setlocal indentexpr=GetCorrectRHelpIndent()
+let b:undo_indent = "setl ai< cin< inde< indk< lisp< si<"
+
" Only define the functions once.
if exists("*GetRHelpIndent")
finish
diff --git a/runtime/indent/rmd.vim b/runtime/indent/rmd.vim
index 8fd57257fa..a043b0c994 100644
--- a/runtime/indent/rmd.vim
+++ b/runtime/indent/rmd.vim
@@ -2,7 +2,7 @@
" Language: Rmd
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Sun Mar 28, 2021 08:05PM
+" Last Change: Wed Nov 09, 2022 09:44PM
" Only load this indent file when no other was loaded.
@@ -16,6 +16,8 @@ let b:did_indent = 1
setlocal indentkeys=0{,0},<:>,!^F,o,O,e
setlocal indentexpr=GetRmdIndent()
+let b:undo_indent = "setl inde< indk<"
+
if exists("*GetRmdIndent")
finish
endif
@@ -47,6 +49,8 @@ function s:GetMdIndent()
return indent(v:lnum - 1) + 2
elseif pline =~ '^\s*\d\+\.\s\+'
return indent(v:lnum - 1) + 3
+ elseif pline =~ '^\[\^\S\+\]: '
+ return indent(v:lnum - 1) + shiftwidth()
endif
return indent(prevnonblank(v:lnum - 1))
endfunction
diff --git a/runtime/indent/rnoweb.vim b/runtime/indent/rnoweb.vim
index 73966868b8..668cdb7ddd 100644
--- a/runtime/indent/rnoweb.vim
+++ b/runtime/indent/rnoweb.vim
@@ -2,7 +2,7 @@
" Language: Rnoweb
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Fri Apr 15, 2016 10:58PM
+" Last Change: Mon Feb 27, 2023 07:17PM
" Only load this indent file when no other was loaded.
@@ -11,7 +11,7 @@ if exists("b:did_indent")
endif
runtime indent/tex.vim
-function! s:NoTeXIndent()
+function s:NoTeXIndent()
return indent(line("."))
endfunction
@@ -29,6 +29,8 @@ let b:did_indent = 1
setlocal indentkeys=0{,0},!^F,o,O,e,},=\bibitem,=\item
setlocal indentexpr=GetRnowebIndent()
+let b:undo_indent = "setl inde< indk<"
+
if exists("*GetRnowebIndent")
finish
endif
diff --git a/runtime/indent/rrst.vim b/runtime/indent/rrst.vim
index f3ee53e7fb..585c5e6654 100644
--- a/runtime/indent/rrst.vim
+++ b/runtime/indent/rrst.vim
@@ -2,7 +2,7 @@
" Language: Rrst
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Tue Apr 07, 2015 04:38PM
+" Last Change: Feb 25, 2023
" Only load this indent file when no other was loaded.
@@ -16,6 +16,8 @@ let b:did_indent = 1
setlocal indentkeys=0{,0},:,!^F,o,O,e
setlocal indentexpr=GetRrstIndent()
+let b:undo_indent = "setl inde< indk<"
+
if exists("*GetRrstIndent")
finish
endif
diff --git a/runtime/indent/rst.vim b/runtime/indent/rst.vim
index a31ad8e080..e3c10865a6 100644
--- a/runtime/indent/rst.vim
+++ b/runtime/indent/rst.vim
@@ -4,6 +4,7 @@
" Maintainer: Marshall Ward <marshall.ward@gmail.com>
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2020-03-31
+" 2023 Aug 28 by Vim Project (undo_indent)
if exists("b:did_indent")
finish
@@ -14,6 +15,8 @@ setlocal indentexpr=GetRSTIndent()
setlocal indentkeys=!^F,o,O
setlocal nosmartindent
+let b:undo_indent = "setlocal indentexpr< indentkeys< smartindent<"
+
if exists("*GetRSTIndent")
finish
endif
diff --git a/runtime/indent/ruby.vim b/runtime/indent/ruby.vim
index 6ce8529fd1..ea5a2a7494 100644
--- a/runtime/indent/ruby.vim
+++ b/runtime/indent/ruby.vim
@@ -4,7 +4,7 @@
" Previous Maintainer: Nikolai Weibull <now at bitwi.se>
" URL: https://github.com/vim-ruby/vim-ruby
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
-" Last Change: 2022 Mar 22
+" Last Change: 2022 Jun 30
" 0. Initialization {{{1
" =================
@@ -93,7 +93,7 @@ let s:ruby_indent_keywords =
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>'
" Def without an end clause: def method_call(...) = <expression>
-let s:ruby_endless_def = '\<def\s\+\k\+[!?]\=\%((.*)\|\s\)\s*='
+let s:ruby_endless_def = '\<def\s\+\%(\k\+\.\)\=\k\+[!?]\=\%((.*)\|\s\)\s*='
" Regex used for words that, at the start of a line, remove a level of indent.
let s:ruby_deindent_keywords =
diff --git a/runtime/indent/rust.vim b/runtime/indent/rust.vim
index d30629b64e..7c055ec739 100644
--- a/runtime/indent/rust.vim
+++ b/runtime/indent/rust.vim
@@ -1,213 +1,286 @@
" Vim indent file
" Language: Rust
" Author: Chris Morgan <me@chrismorgan.info>
-" Last Change: 2017 Jun 13
+" Last Change: 2023-09-11
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
- finish
+ finish
endif
let b:did_indent = 1
setlocal cindent
-setlocal cinoptions=L0,(0,Ws,J1,j1
-setlocal cinkeys=0{,0},!^F,o,O,0[,0]
+setlocal cinoptions=L0,(s,Ws,J1,j1,m1
+setlocal cinkeys=0{,0},!^F,o,O,0[,0],0(,0)
" Don't think cinwords will actually do anything at all... never mind
-setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
+setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern,macro
" Some preliminary settings
setlocal nolisp " Make sure lisp indenting doesn't supersede us
setlocal autoindent " indentexpr isn't much help otherwise
" Also do indentkeys, otherwise # gets shoved to column 0 :-/
-setlocal indentkeys=0{,0},!^F,o,O,0[,0]
+setlocal indentkeys=0{,0},!^F,o,O,0[,0],0(,0)
setlocal indentexpr=GetRustIndent(v:lnum)
+let b:undo_indent = "setlocal cindent< cinoptions< cinkeys< cinwords< lisp< autoindent< indentkeys< indentexpr<"
+
" Only define the function once.
if exists("*GetRustIndent")
- finish
+ finish
endif
+" vint: -ProhibitAbbreviationOption
let s:save_cpo = &cpo
set cpo&vim
+" vint: +ProhibitAbbreviationOption
" Come here when loading the script the first time.
function! s:get_line_trimmed(lnum)
- " Get the line and remove a trailing comment.
- " Use syntax highlighting attributes when possible.
- " NOTE: this is not accurate; /* */ or a line continuation could trick it
- let line = getline(a:lnum)
- let line_len = strlen(line)
- if has('syntax_items')
- " If the last character in the line is a comment, do a binary search for
- " the start of the comment. synID() is slow, a linear search would take
- " too long on a long line.
- if synIDattr(synID(a:lnum, line_len, 1), "name") =~ 'Comment\|Todo'
- let min = 1
- let max = line_len
- while min < max
- let col = (min + max) / 2
- if synIDattr(synID(a:lnum, col, 1), "name") =~ 'Comment\|Todo'
- let max = col
- else
- let min = col + 1
- endif
- endwhile
- let line = strpart(line, 0, min - 1)
- endif
- return substitute(line, "\s*$", "", "")
- else
- " Sorry, this is not complete, nor fully correct (e.g. string "//").
- " Such is life.
- return substitute(line, "\s*//.*$", "", "")
- endif
+ " Get the line and remove a trailing comment.
+ " Use syntax highlighting attributes when possible.
+ " NOTE: this is not accurate; /* */ or a line continuation could trick it
+ let line = getline(a:lnum)
+ let line_len = strlen(line)
+ if has('syntax_items')
+ " If the last character in the line is a comment, do a binary search for
+ " the start of the comment. synID() is slow, a linear search would take
+ " too long on a long line.
+ if synIDattr(synID(a:lnum, line_len, 1), "name") =~? 'Comment\|Todo'
+ let min = 1
+ let max = line_len
+ while min < max
+ let col = (min + max) / 2
+ if synIDattr(synID(a:lnum, col, 1), "name") =~? 'Comment\|Todo'
+ let max = col
+ else
+ let min = col + 1
+ endif
+ endwhile
+ let line = strpart(line, 0, min - 1)
+ endif
+ return substitute(line, "\s*$", "", "")
+ else
+ " Sorry, this is not complete, nor fully correct (e.g. string "//").
+ " Such is life.
+ return substitute(line, "\s*//.*$", "", "")
+ endif
endfunction
function! s:is_string_comment(lnum, col)
- if has('syntax_items')
- for id in synstack(a:lnum, a:col)
- let synname = synIDattr(id, "name")
- if synname == "rustString" || synname =~ "^rustComment"
- return 1
- endif
- endfor
- else
- " without syntax, let's not even try
- return 0
- endif
+ if has('syntax_items')
+ for id in synstack(a:lnum, a:col)
+ let synname = synIDattr(id, "name")
+ if synname ==# "rustString" || synname =~# "^rustComment"
+ return 1
+ endif
+ endfor
+ else
+ " without syntax, let's not even try
+ return 0
+ endif
endfunction
+if exists('*shiftwidth')
+ function! s:shiftwidth()
+ return shiftwidth()
+ endfunc
+else
+ function! s:shiftwidth()
+ return &shiftwidth
+ endfunc
+endif
+
function GetRustIndent(lnum)
+ " Starting assumption: cindent (called at the end) will do it right
+ " normally. We just want to fix up a few cases.
+
+ let line = getline(a:lnum)
+
+ if has('syntax_items')
+ let synname = synIDattr(synID(a:lnum, 1, 1), "name")
+ if synname ==# "rustString"
+ " If the start of the line is in a string, don't change the indent
+ return -1
+ elseif synname =~? '\(Comment\|Todo\)'
+ \ && line !~# '^\s*/\*' " not /* opening line
+ if synname =~? "CommentML" " multi-line
+ if line !~# '^\s*\*' && getline(a:lnum - 1) =~# '^\s*/\*'
+ " This is (hopefully) the line after a /*, and it has no
+ " leader, so the correct indentation is that of the
+ " previous line.
+ return GetRustIndent(a:lnum - 1)
+ endif
+ endif
+ " If it's in a comment, let cindent take care of it now. This is
+ " for cases like "/*" where the next line should start " * ", not
+ " "* " as the code below would otherwise cause for module scope
+ " Fun fact: " /*\n*\n*/" takes two calls to get right!
+ return cindent(a:lnum)
+ endif
+ endif
+
+ " cindent gets second and subsequent match patterns/struct members wrong,
+ " as it treats the comma as indicating an unfinished statement::
+ "
+ " match a {
+ " b => c,
+ " d => e,
+ " f => g,
+ " };
+
+ " Search backwards for the previous non-empty line.
+ let prevlinenum = prevnonblank(a:lnum - 1)
+ let prevline = s:get_line_trimmed(prevlinenum)
+ while prevlinenum > 1 && prevline !~# '[^[:blank:]]'
+ let prevlinenum = prevnonblank(prevlinenum - 1)
+ let prevline = s:get_line_trimmed(prevlinenum)
+ endwhile
+
+ " A standalone '{', '}', or 'where'
+ let l:standalone_open = line =~# '\V\^\s\*{\s\*\$'
+ let l:standalone_close = line =~# '\V\^\s\*}\s\*\$'
+ let l:standalone_where = line =~# '\V\^\s\*where\s\*\$'
+ if l:standalone_open || l:standalone_close || l:standalone_where
+ " ToDo: we can search for more items than 'fn' and 'if'.
+ let [l:found_line, l:col, l:submatch] =
+ \ searchpos('\<\(fn\)\|\(if\)\>', 'bnWp')
+ if l:found_line !=# 0
+ " Now we count the number of '{' and '}' in between the match
+ " locations and the current line (there is probably a better
+ " way to compute this).
+ let l:i = l:found_line
+ let l:search_line = strpart(getline(l:i), l:col - 1)
+ let l:opens = 0
+ let l:closes = 0
+ while l:i < a:lnum
+ let l:search_line2 = substitute(l:search_line, '\V{', '', 'g')
+ let l:opens += strlen(l:search_line) - strlen(l:search_line2)
+ let l:search_line3 = substitute(l:search_line2, '\V}', '', 'g')
+ let l:closes += strlen(l:search_line2) - strlen(l:search_line3)
+ let l:i += 1
+ let l:search_line = getline(l:i)
+ endwhile
+ if l:standalone_open || l:standalone_where
+ if l:opens ==# l:closes
+ return indent(l:found_line)
+ endif
+ else
+ " Expect to find just one more close than an open
+ if l:opens ==# l:closes + 1
+ return indent(l:found_line)
+ endif
+ endif
+ endif
+ endif
+
+ " A standalone 'where' adds a shift.
+ let l:standalone_prevline_where = prevline =~# '\V\^\s\*where\s\*\$'
+ if l:standalone_prevline_where
+ return indent(prevlinenum) + 4
+ endif
- " Starting assumption: cindent (called at the end) will do it right
- " normally. We just want to fix up a few cases.
-
- let line = getline(a:lnum)
-
- if has('syntax_items')
- let synname = synIDattr(synID(a:lnum, 1, 1), "name")
- if synname == "rustString"
- " If the start of the line is in a string, don't change the indent
- return -1
- elseif synname =~ '\(Comment\|Todo\)'
- \ && line !~ '^\s*/\*' " not /* opening line
- if synname =~ "CommentML" " multi-line
- if line !~ '^\s*\*' && getline(a:lnum - 1) =~ '^\s*/\*'
- " This is (hopefully) the line after a /*, and it has no
- " leader, so the correct indentation is that of the
- " previous line.
- return GetRustIndent(a:lnum - 1)
- endif
- endif
- " If it's in a comment, let cindent take care of it now. This is
- " for cases like "/*" where the next line should start " * ", not
- " "* " as the code below would otherwise cause for module scope
- " Fun fact: " /*\n*\n*/" takes two calls to get right!
- return cindent(a:lnum)
- endif
- endif
-
- " cindent gets second and subsequent match patterns/struct members wrong,
- " as it treats the comma as indicating an unfinished statement::
- "
- " match a {
- " b => c,
- " d => e,
- " f => g,
- " };
-
- " Search backwards for the previous non-empty line.
- let prevlinenum = prevnonblank(a:lnum - 1)
- let prevline = s:get_line_trimmed(prevlinenum)
- while prevlinenum > 1 && prevline !~ '[^[:blank:]]'
- let prevlinenum = prevnonblank(prevlinenum - 1)
- let prevline = s:get_line_trimmed(prevlinenum)
- endwhile
-
- " Handle where clauses nicely: subsequent values should line up nicely.
- if prevline[len(prevline) - 1] == ","
- \ && prevline =~# '^\s*where\s'
- return indent(prevlinenum) + 6
- endif
-
- if prevline[len(prevline) - 1] == ","
- \ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]'
- \ && prevline !~ '^\s*fn\s'
- \ && prevline !~ '([^()]\+,$'
- \ && s:get_line_trimmed(a:lnum) !~ '^\s*\S\+\s*=>'
- " Oh ho! The previous line ended in a comma! I bet cindent will try to
- " take this too far... For now, let's normally use the previous line's
- " indent.
-
- " One case where this doesn't work out is where *this* line contains
- " square or curly brackets; then we normally *do* want to be indenting
- " further.
- "
- " Another case where we don't want to is one like a function
- " definition with arguments spread over multiple lines:
- "
- " fn foo(baz: Baz,
- " baz: Baz) // <-- cindent gets this right by itself
- "
- " Another case is similar to the previous, except calling a function
- " instead of defining it, or any conditional expression that leaves
- " an open paren:
- "
- " foo(baz,
- " baz);
- "
- " if baz && (foo ||
- " bar) {
- "
- " Another case is when the current line is a new match arm.
- "
- " There are probably other cases where we don't want to do this as
- " well. Add them as needed.
- return indent(prevlinenum)
- endif
-
- if !has("patch-7.4.355")
- " cindent before 7.4.355 doesn't do the module scope well at all; e.g.::
- "
- " static FOO : &'static [bool] = [
- " true,
- " false,
- " false,
- " true,
- " ];
- "
- " uh oh, next statement is indented further!
-
- " Note that this does *not* apply the line continuation pattern properly;
- " that's too hard to do correctly for my liking at present, so I'll just
- " start with these two main cases (square brackets and not returning to
- " column zero)
-
- call cursor(a:lnum, 1)
- if searchpair('{\|(', '', '}\|)', 'nbW',
- \ 's:is_string_comment(line("."), col("."))') == 0
- if searchpair('\[', '', '\]', 'nbW',
- \ 's:is_string_comment(line("."), col("."))') == 0
- " Global scope, should be zero
- return 0
- else
- " At the module scope, inside square brackets only
- "if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum
- if line =~ "^\\s*]"
- " It's the closing line, dedent it
- return 0
- else
- return shiftwidth()
- endif
- endif
- endif
- endif
-
- " Fall back on cindent, which does it mostly right
- return cindent(a:lnum)
+ " Handle where clauses nicely: subsequent values should line up nicely.
+ if prevline[len(prevline) - 1] ==# ","
+ \ && prevline =~# '^\s*where\s'
+ return indent(prevlinenum) + 6
+ endif
+
+ let l:last_prevline_character = prevline[len(prevline) - 1]
+
+ " A line that ends with '.<expr>;' is probably an end of a long list
+ " of method operations.
+ if prevline =~# '\V\^\s\*.' && l:last_prevline_character ==# ';'
+ call cursor(a:lnum - 1, 1)
+ let l:scope_start = searchpair('{\|(', '', '}\|)', 'nbW',
+ \ 's:is_string_comment(line("."), col("."))')
+ if l:scope_start != 0 && l:scope_start < a:lnum
+ return indent(l:scope_start) + 4
+ endif
+ endif
+
+ if l:last_prevline_character ==# ","
+ \ && s:get_line_trimmed(a:lnum) !~# '^\s*[\[\]{})]'
+ \ && prevline !~# '^\s*fn\s'
+ \ && prevline !~# '([^()]\+,$'
+ \ && s:get_line_trimmed(a:lnum) !~# '^\s*\S\+\s*=>'
+ " Oh ho! The previous line ended in a comma! I bet cindent will try to
+ " take this too far... For now, let's normally use the previous line's
+ " indent.
+
+ " One case where this doesn't work out is where *this* line contains
+ " square or curly brackets; then we normally *do* want to be indenting
+ " further.
+ "
+ " Another case where we don't want to is one like a function
+ " definition with arguments spread over multiple lines:
+ "
+ " fn foo(baz: Baz,
+ " baz: Baz) // <-- cindent gets this right by itself
+ "
+ " Another case is similar to the previous, except calling a function
+ " instead of defining it, or any conditional expression that leaves
+ " an open paren:
+ "
+ " foo(baz,
+ " baz);
+ "
+ " if baz && (foo ||
+ " bar) {
+ "
+ " Another case is when the current line is a new match arm.
+ "
+ " There are probably other cases where we don't want to do this as
+ " well. Add them as needed.
+ return indent(prevlinenum)
+ endif
+
+ if !has("patch-7.4.355")
+ " cindent before 7.4.355 doesn't do the module scope well at all; e.g.::
+ "
+ " static FOO : &'static [bool] = [
+ " true,
+ " false,
+ " false,
+ " true,
+ " ];
+ "
+ " uh oh, next statement is indented further!
+
+ " Note that this does *not* apply the line continuation pattern properly;
+ " that's too hard to do correctly for my liking at present, so I'll just
+ " start with these two main cases (square brackets and not returning to
+ " column zero)
+
+ call cursor(a:lnum, 1)
+ if searchpair('{\|(', '', '}\|)', 'nbW',
+ \ 's:is_string_comment(line("."), col("."))') == 0
+ if searchpair('\[', '', '\]', 'nbW',
+ \ 's:is_string_comment(line("."), col("."))') == 0
+ " Global scope, should be zero
+ return 0
+ else
+ " At the module scope, inside square brackets only
+ "if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum
+ if line =~# "^\\s*]"
+ " It's the closing line, dedent it
+ return 0
+ else
+ return &shiftwidth
+ endif
+ endif
+ endif
+ endif
+
+ " Fall back on cindent, which does it mostly right
+ return cindent(a:lnum)
endfunction
+" vint: -ProhibitAbbreviationOption
let &cpo = s:save_cpo
unlet s:save_cpo
+" vint: +ProhibitAbbreviationOption
+
+" vim: set et sw=4 sts=4 ts=8:
diff --git a/runtime/indent/scala.vim b/runtime/indent/scala.vim
index b5eba29543..c6aba4e388 100644
--- a/runtime/indent/scala.vim
+++ b/runtime/indent/scala.vim
@@ -4,6 +4,7 @@
" Modifications By: Derek Wyatt
" URL: https://github.com/derekwyatt/vim-scala
" Last Change: 2016 Aug 26
+" 2023 Aug 28 by Vim Project (undo_indent)
if exists("b:did_indent")
finish
@@ -14,6 +15,8 @@ setlocal autoindent
setlocal indentexpr=GetScalaIndent()
setlocal indentkeys=0{,0},0),!^F,<>>,o,O,e,=case,<CR>
+let b:undo_indent = "setl ai< inde< indk<"
+
if exists("*GetScalaIndent")
finish
endif
diff --git a/runtime/indent/solidity.vim b/runtime/indent/solidity.vim
index caed726c0a..55a07c015a 100644
--- a/runtime/indent/solidity.vim
+++ b/runtime/indent/solidity.vim
@@ -1,9 +1,11 @@
" Vim indent file
-" Language: Solidity
-" Acknowledgement: Based off of vim-javascript
-" Maintainer: Cothi (jiungdev@gmail.com)
-" Original Author: tomlion (https://github.com/tomlion/vim-solidity)
-" Last Changed: 2022 Sep 27
+" Language: Solidity
+" Maintainer: Cothi (jiungdev@gmail.com)
+" Original Author: tomlion (https://github.com/tomlion/vim-solidity)
+" Last Change: 2022 Sep 27
+" 2023 Aug 22 Vim Project (undo_indent)
+"
+" Acknowledgement: Based off of vim-javascript
"
" 0. Initialization {{{1
" =================
@@ -20,6 +22,8 @@ setlocal nosmartindent
setlocal indentexpr=GetSolidityIndent()
setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e
+let b:undo_indent = "setlocal indentexpr< indentkeys< smartindent<"
+
" Only define the function once.
if exists("*GetSolidityIndent")
finish
diff --git a/runtime/indent/systemverilog.vim b/runtime/indent/systemverilog.vim
index a5f4d5b90d..42a05a03aa 100644
--- a/runtime/indent/systemverilog.vim
+++ b/runtime/indent/systemverilog.vim
@@ -78,10 +78,10 @@ function SystemVerilogIndent()
" Multiple-line comment count
if curr_line =~ '^\s*/\*' && curr_line !~ '/\*.\{-}\*/'
let s:multiple_comment += 1
- if vverb | echom vverb_str "Start of multiple-line commnt" | endif
+ if vverb | echom vverb_str "Start of multiple-line comment" | endif
elseif curr_line =~ '\*/\s*$' && curr_line !~ '/\*.\{-}\*/'
let s:multiple_comment -= 1
- if vverb | echom vverb_str "End of multiple-line commnt" | endif
+ if vverb | echom vverb_str "End of multiple-line comment" | endif
return ind
endif
" Maintain indentation during commenting.
diff --git a/runtime/indent/testdir/dts.in b/runtime/indent/testdir/dts.in
new file mode 100644
index 0000000000..64e56e9017
--- /dev/null
+++ b/runtime/indent/testdir/dts.in
@@ -0,0 +1,46 @@
+/* vim: set ft=dts noet sw=8 : */
+
+/* START_INDENT */
+/dts-v1/;
+#include <dt-bindings/pinctrl/pinctrl-imx6q.h>
+ #include "imx6qdl.dtsi"
+#include "imx6qdl-someboard.dtsi"
+
+ /delete-node/ &{/memory@10000000};
+
+ / {
+compatible = "some,board";
+/delete-node/ memory;
+
+ chosen {
+environment = &{usdhc4/partitions/partition@0};
+};
+}
+
+ &iomuxc {
+pinctrl-names = "default";
+pinctrl-0 = <&pinctrl_hog>;
+
+pinctrl_gpiohog: gpiohoggrp {
+fsl,pins = <
+MX6QDL_PAD_GPIO_9__GPIO1_IO09 0x130b0
+MX6QDL_PAD_GPIO_17__GPIO7_IO12 0x130b0
+>;
+};
+}
+
+&usdhc4 {
+partitions {
+compatible = "fixed-partitions";
+
+partition@0 {
+label = "environment";
+reg = <0x0 0xe0000>;
+};
+};
+};
+
+&{/aliases} {
+usb0 = &usb;
+};
+/* END_INDENT */
diff --git a/runtime/indent/testdir/dts.ok b/runtime/indent/testdir/dts.ok
new file mode 100644
index 0000000000..d249766fd4
--- /dev/null
+++ b/runtime/indent/testdir/dts.ok
@@ -0,0 +1,46 @@
+/* vim: set ft=dts noet sw=8 : */
+
+/* START_INDENT */
+/dts-v1/;
+#include <dt-bindings/pinctrl/pinctrl-imx6q.h>
+#include "imx6qdl.dtsi"
+#include "imx6qdl-someboard.dtsi"
+
+/delete-node/ &{/memory@10000000};
+
+/ {
+ compatible = "some,board";
+ /delete-node/ memory;
+
+ chosen {
+ environment = &{usdhc4/partitions/partition@0};
+ };
+}
+
+&iomuxc {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_hog>;
+
+ pinctrl_gpiohog: gpiohoggrp {
+ fsl,pins = <
+ MX6QDL_PAD_GPIO_9__GPIO1_IO09 0x130b0
+ MX6QDL_PAD_GPIO_17__GPIO7_IO12 0x130b0
+ >;
+ };
+}
+
+&usdhc4 {
+ partitions {
+ compatible = "fixed-partitions";
+
+ partition@0 {
+ label = "environment";
+ reg = <0x0 0xe0000>;
+ };
+ };
+};
+
+&{/aliases} {
+ usb0 = &usb;
+};
+/* END_INDENT */
diff --git a/runtime/indent/testdir/rapid.in b/runtime/indent/testdir/rapid.in
new file mode 100644
index 0000000000..515912ed89
--- /dev/null
+++ b/runtime/indent/testdir/rapid.in
@@ -0,0 +1,266 @@
+! vim: set ft=rapid :
+
+! START_INDENT
+
+%%%
+ VERSION:1
+ LANGUAGE:ENGLISH
+%%%
+
+module LowerCaseModule
+
+task pers num n1 := 0;
+local pers num n2 := 1;
+var bool b1 := false;
+var intnum i1;
+
+! put some stuff in those strings that may confuse indentation
+const string st1 := "endmodule (";
+pers string st_Appl_Info{3,3}:=[
+[
+"["
+,
+"default"
+,
+"case"
+],
+[
+"else"
+,
+"then"
+,
+"endif"
+],
+[
+"do"
+,
+"}"
+,
+")"
+],
+];
+
+pers tooldata tTool1:=[TRUE,
+[
+[97.4, 0, 223.1],
+[0.924, 0, 0.383 ,0]
+],
+[5,
+[23, 0, 75],
+[1, 0, 0, 0], 0, 0, 0
+]
+];
+const robtarget p1:=[
+[600, 500, 225.3],
+[1, 0, 0, 0],
+[1, 1, 0, 0],
+[ 11, 12.3, 9E9, 9E9, 9E9, 9E9]
+];
+
+record myRec
+num nRecNum1
+bool bRecBool1
+endrecord
+
+proc proc1(num n1,
+num n2)
+var string st1;
+n1 := n1+1;
+MoveJSync p1, vmax, z30, tool1, "proc2";
+backward
+MoveJSync p1, v100, fine, tool1, "proc2";
+undo
+n1 := n1-1;
+error
+trynext;
+endproc
+
+func num nFunc1(
+switch s1
+|switch s2
+,num n1
+,bool b1)
+var num nVar;
+if not Present(s1) return;
+if Present(s1) then
+Incr n1;'
+elseif Present(s2) then
+b1:=false;
+else
+while n1>0 do
+Decr n1;
+test n1
+
+case 1:
+test1;
+case 2:
+test2;
+default:
+WaitUntil false;
+endtest
+endwhile
+endif
+for i from 1 to 10 step 2 do
+for j from 1 to 10 do
+st_Appl_Info{i,j} := "";
+endfor
+endfor
+! return 1;
+return 0;
+error
+return -1;
+endfunc
+
+trap Trap1
+Reset do1;
+endtrap
+
+endmodule
+
+MODULE UpperCaseModule(SYSMODULE,NOSTEPIN)
+TASK pers num n1 := 0;
+LOCAL pers num n2 := 1;
+VAR bool b1 := false;
+VAR intnum i1;
+
+LOCAL FUNC num nFunc1(
+switch s1
+|switch s2
+,num n1
+,bool b1)
+VAR num nVar;
+IF NOT PRESENT(s1) RETURN;
+IF PRESENT(s1) THEN
+INCR n1;'
+ELSEIF PRESENT(s2) THEN
+b1:=FALSE;
+ELSE
+WHILE n1>0 DO
+DECR n1;
+TEST n1
+
+CASE 1:
+test1;
+CASE 2:
+test2;
+DEFAULT:
+WAITUNTIL FALSE;
+ENDTEST
+ENDWHILE
+ENDIF
+FOR i FROM 1 TO 10 STEP 2 DO
+FOR j FROM 1 TO 10 DO
+st_Appl_Info{i,j} := "";
+ENDFOR
+ENDFOR
+! RETURN 1;
+RETURN 0;
+ERROR
+RETURN -1;
+ENDFUNC
+
+TRAP Trap1
+Reset do1;
+ENDTRAP
+
+ENDMODULE
+
+Module MixedCaseModule(SysModule)
+Task pers num n1 := 0;
+Local pers num n2 := 1;
+Var bool b1 := false;
+Var intnum i1;
+
+Task Func num nFunc1(
+switch s1
+|switch s2
+,num n1
+,bool b1)
+Var num nVar;
+If Not Present(s1) Return;
+If Present(s1) Then
+Incr n1;'
+ElseIf Present(s2) Then
+b1:=false;
+Else
+While n1>0 Do
+Decr n1;
+Test n1
+
+Case 1:
+test1;
+Case 2:
+test2;
+Default:
+WaitUntil false;
+EndTest
+EndWhile
+EndIf
+For i From 1 To 10 Step 2 Do
+For j From 1 To 10 Do
+st_Appl_Info{i,j} := "";
+EndFor
+EndFor
+! Return 1;
+Return 0;
+Error
+Return -1;
+EndFunc
+
+Trap Trap1
+Reset do1;
+EndTrap
+
+EndModule
+
+! END_INDENT
+
+! START_INDENT
+! INDENT_EXE let g:rapidSpaceIndent = 0
+! INDENT_EXE set shiftwidth=4
+
+proc bla()
+var num i;
+Incr i;
+endproc
+
+! END_INDENT
+
+! START_INDENT
+! INDENT_EXE let g:rapidCommentIndent = 1
+!
+proc bla()
+! indent this first column comment because of g:rapidCommentIndent=1
+endproc
+! END_INDENT
+
+! START_INDENT
+! INDENT_EXE let g:rapidNewStyleIndent = 1
+pers string st_Appl_Info{3,3}:=
+[
+[
+"["
+,
+"default"
+,
+"case"
+]
+,
+[
+"else"
+,
+"then"
+,
+"endif"
+]
+,
+[
+"do"
+,
+"}"
+,
+")"
+]
+,
+];
+! END_INDENT
diff --git a/runtime/indent/testdir/rapid.ok b/runtime/indent/testdir/rapid.ok
new file mode 100644
index 0000000000..ce336821c4
--- /dev/null
+++ b/runtime/indent/testdir/rapid.ok
@@ -0,0 +1,266 @@
+! vim: set ft=rapid :
+
+! START_INDENT
+
+%%%
+VERSION:1
+LANGUAGE:ENGLISH
+%%%
+
+module LowerCaseModule
+
+ task pers num n1 := 0;
+ local pers num n2 := 1;
+ var bool b1 := false;
+ var intnum i1;
+
+! put some stuff in those strings that may confuse indentation
+ const string st1 := "endmodule (";
+ pers string st_Appl_Info{3,3}:=[
+ [
+ "["
+ ,
+ "default"
+ ,
+ "case"
+ ],
+ [
+ "else"
+ ,
+ "then"
+ ,
+ "endif"
+ ],
+ [
+ "do"
+ ,
+ "}"
+ ,
+ ")"
+ ],
+ ];
+
+ pers tooldata tTool1:=[TRUE,
+ [
+ [97.4, 0, 223.1],
+ [0.924, 0, 0.383 ,0]
+ ],
+ [5,
+ [23, 0, 75],
+ [1, 0, 0, 0], 0, 0, 0
+ ]
+ ];
+ const robtarget p1:=[
+ [600, 500, 225.3],
+ [1, 0, 0, 0],
+ [1, 1, 0, 0],
+ [ 11, 12.3, 9E9, 9E9, 9E9, 9E9]
+ ];
+
+ record myRec
+ num nRecNum1
+ bool bRecBool1
+ endrecord
+
+ proc proc1(num n1,
+ num n2)
+ var string st1;
+ n1 := n1+1;
+ MoveJSync p1, vmax, z30, tool1, "proc2";
+ backward
+ MoveJSync p1, v100, fine, tool1, "proc2";
+ undo
+ n1 := n1-1;
+ error
+ trynext;
+ endproc
+
+ func num nFunc1(
+ switch s1
+ |switch s2
+ ,num n1
+ ,bool b1)
+ var num nVar;
+ if not Present(s1) return;
+ if Present(s1) then
+ Incr n1;'
+ elseif Present(s2) then
+ b1:=false;
+ else
+ while n1>0 do
+ Decr n1;
+ test n1
+
+ case 1:
+ test1;
+ case 2:
+ test2;
+ default:
+ WaitUntil false;
+ endtest
+ endwhile
+ endif
+ for i from 1 to 10 step 2 do
+ for j from 1 to 10 do
+ st_Appl_Info{i,j} := "";
+ endfor
+ endfor
+! return 1;
+ return 0;
+ error
+ return -1;
+ endfunc
+
+ trap Trap1
+ Reset do1;
+ endtrap
+
+endmodule
+
+MODULE UpperCaseModule(SYSMODULE,NOSTEPIN)
+ TASK pers num n1 := 0;
+ LOCAL pers num n2 := 1;
+ VAR bool b1 := false;
+ VAR intnum i1;
+
+ LOCAL FUNC num nFunc1(
+ switch s1
+ |switch s2
+ ,num n1
+ ,bool b1)
+ VAR num nVar;
+ IF NOT PRESENT(s1) RETURN;
+ IF PRESENT(s1) THEN
+ INCR n1;'
+ ELSEIF PRESENT(s2) THEN
+ b1:=FALSE;
+ ELSE
+ WHILE n1>0 DO
+ DECR n1;
+ TEST n1
+
+ CASE 1:
+ test1;
+ CASE 2:
+ test2;
+ DEFAULT:
+ WAITUNTIL FALSE;
+ ENDTEST
+ ENDWHILE
+ ENDIF
+ FOR i FROM 1 TO 10 STEP 2 DO
+ FOR j FROM 1 TO 10 DO
+ st_Appl_Info{i,j} := "";
+ ENDFOR
+ ENDFOR
+! RETURN 1;
+ RETURN 0;
+ ERROR
+ RETURN -1;
+ ENDFUNC
+
+ TRAP Trap1
+ Reset do1;
+ ENDTRAP
+
+ENDMODULE
+
+Module MixedCaseModule(SysModule)
+ Task pers num n1 := 0;
+ Local pers num n2 := 1;
+ Var bool b1 := false;
+ Var intnum i1;
+
+ Task Func num nFunc1(
+ switch s1
+ |switch s2
+ ,num n1
+ ,bool b1)
+ Var num nVar;
+ If Not Present(s1) Return;
+ If Present(s1) Then
+ Incr n1;'
+ ElseIf Present(s2) Then
+ b1:=false;
+ Else
+ While n1>0 Do
+ Decr n1;
+ Test n1
+
+ Case 1:
+ test1;
+ Case 2:
+ test2;
+ Default:
+ WaitUntil false;
+ EndTest
+ EndWhile
+ EndIf
+ For i From 1 To 10 Step 2 Do
+ For j From 1 To 10 Do
+ st_Appl_Info{i,j} := "";
+ EndFor
+ EndFor
+! Return 1;
+ Return 0;
+ Error
+ Return -1;
+ EndFunc
+
+ Trap Trap1
+ Reset do1;
+ EndTrap
+
+EndModule
+
+! END_INDENT
+
+! START_INDENT
+! INDENT_EXE let g:rapidSpaceIndent = 0
+! INDENT_EXE set shiftwidth=4
+
+proc bla()
+ var num i;
+ Incr i;
+endproc
+
+! END_INDENT
+
+! START_INDENT
+! INDENT_EXE let g:rapidCommentIndent = 1
+!
+proc bla()
+ ! indent this first column comment because of g:rapidCommentIndent=1
+endproc
+! END_INDENT
+
+! START_INDENT
+! INDENT_EXE let g:rapidNewStyleIndent = 1
+pers string st_Appl_Info{3,3}:=
+[
+ [
+ "["
+ ,
+ "default"
+ ,
+ "case"
+ ]
+ ,
+ [
+ "else"
+ ,
+ "then"
+ ,
+ "endif"
+ ]
+ ,
+ [
+ "do"
+ ,
+ "}"
+ ,
+ ")"
+ ]
+ ,
+];
+! END_INDENT
diff --git a/runtime/indent/testdir/runtest.vim b/runtime/indent/testdir/runtest.vim
index fa4e16e381..882a140a8d 100644
--- a/runtime/indent/testdir/runtest.vim
+++ b/runtime/indent/testdir/runtest.vim
@@ -12,6 +12,7 @@ set nowrapscan
set report=9999
set modeline
set debug=throw
+set nomore
au! SwapExists * call HandleSwapExists()
func HandleSwapExists()
diff --git a/runtime/indent/tex.vim b/runtime/indent/tex.vim
index d356ba905b..68d13fb116 100644
--- a/runtime/indent/tex.vim
+++ b/runtime/indent/tex.vim
@@ -67,7 +67,8 @@
" 2020/04/26 by Yichao Zhou <broken.zhou AT gmail.com>
" (*) Fix a bug related to \[ & \]. Thanks Manuel Boni for
" reporting.
-"
+" 2023/08/28 by Vim Project
+" (*) Set b:undo_indent.
" }}}
" Document: {{{
@@ -167,6 +168,7 @@ setlocal indentexpr=GetTeXIndent()
setlocal indentkeys&
exec 'setlocal indentkeys+=[,(,{,),},],\&' . substitute(g:tex_items, '^\|\(\\|\)', ',=', 'g')
let g:tex_items = '^\s*' . substitute(g:tex_items, '^\(\^\\s\*\)*', '', '')
+let b:undo_indent = "setlocal autoindent< indentexpr< indentkeys< smartindent<"
" }}}
function! GetTeXIndent() " {{{
diff --git a/runtime/indent/typescript.vim b/runtime/indent/typescript.vim
index e899f83d0f..e26750b8aa 100644
--- a/runtime/indent/typescript.vim
+++ b/runtime/indent/typescript.vim
@@ -2,6 +2,7 @@
" Language: TypeScript
" Maintainer: See https://github.com/HerringtonDarkholme/yats.vim
" Last Change: 2019 Oct 18
+" 2023 Aug 28 by Vim Project (undo_indent)
" Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org
" 0. Initialization {{{1
@@ -20,6 +21,8 @@ setlocal indentexpr=GetTypescriptIndent()
setlocal formatexpr=Fixedgq(v:lnum,v:count)
setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e
+let b:undo_indent = "setlocal formatexpr< indentexpr< indentkeys< smartindent<"
+
" Only define the function once.
if exists("*GetTypescriptIndent")
finish
diff --git a/runtime/indent/typescriptreact.vim b/runtime/indent/typescriptreact.vim
new file mode 100644
index 0000000000..052bddddbd
--- /dev/null
+++ b/runtime/indent/typescriptreact.vim
@@ -0,0 +1,2 @@
+" Placeholder for backwards compatilibity: .tsx used to stand for TypeScript.
+runtime! indent/typescript.vim
diff --git a/runtime/indent/verilog.vim b/runtime/indent/verilog.vim
index e81197c3b4..377615c348 100644
--- a/runtime/indent/verilog.vim
+++ b/runtime/indent/verilog.vim
@@ -1,6 +1,7 @@
" Language: Verilog HDL
" Maintainer: Chih-Tsun Huang <cthuang@cs.nthu.edu.tw>
" Last Change: 2017 Aug 25 by Chih-Tsun Huang
+" 2023 Aug 28 by Vim Project (undo_indent)
" URL: http://www.cs.nthu.edu.tw/~cthuang/vim/indent/verilog.vim
"
" Credits:
@@ -28,6 +29,8 @@ setlocal indentkeys+==endmodule,=endfunction,=endtask,=endspecify
setlocal indentkeys+==endconfig,=endgenerate,=endprimitive,=endtable
setlocal indentkeys+==`else,=`elsif,=`endif
+let b:undo_indent = "setlocal indentexpr< indentkeys<"
+
" Only define the function once.
if exists("*GetVerilogIndent")
finish
diff --git a/runtime/indent/vhdl.vim b/runtime/indent/vhdl.vim
index ad318066f4..b01d1156e9 100644
--- a/runtime/indent/vhdl.vim
+++ b/runtime/indent/vhdl.vim
@@ -3,6 +3,7 @@
" Maintainer: Gerald Lai <laigera+vim?gmail.com>
" Version: 1.62
" Last Change: 2017 Oct 17
+" 2023 Aug 28 by Vim Project (undo_indent)
" URL: http://www.vim.org/scripts/script.php?script_id=1450
" only load this indent file when no other was loaded
@@ -19,6 +20,8 @@ setlocal indentkeys+==~if,=~then,=~elsif,=~else
setlocal indentkeys+==~case,=~loop,=~for,=~generate,=~record,=~units,=~process,=~block,=~function,=~component,=~procedure
setlocal indentkeys+==~architecture,=~configuration,=~entity,=~package
+let b:undo_indent = "setlocal indentexpr< indentkeys<"
+
" constants
" not a comment
let s:NC = '\%(--.*\)\@<!'
diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim
index 3beb70d255..b2fb57f51f 100644
--- a/runtime/indent/vim.vim
+++ b/runtime/indent/vim.vim
@@ -1,7 +1,8 @@
" Vim indent file
" Language: Vim script
-" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2022 Jun 24
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 10
+" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
diff --git a/runtime/indent/wast.vim b/runtime/indent/wat.vim
index 1be234b6e9..08997f1a98 100644
--- a/runtime/indent/wast.vim
+++ b/runtime/indent/wat.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: WebAssembly
" Maintainer: rhysd <lin90162@yahoo.co.jp>
-" Last Change: Jul 29, 2018
+" Last Change: Nov 14, 2023
" For bugs, patches and license go to https://github.com/rhysd/vim-wasm
if exists("b:did_indent")
diff --git a/runtime/indent/xhtml.vim b/runtime/indent/xhtml.vim
index 2197b7901c..e5c9cc307f 100644
--- a/runtime/indent/xhtml.vim
+++ b/runtime/indent/xhtml.vim
@@ -1,7 +1,8 @@
" Vim indent file
" Language: XHTML
-" Maintainer: Bram Moolenaar <Bram@vim.org> (for now)
-" Last Change: 2005 Jun 24
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 10
+" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
diff --git a/runtime/indent/zimbu.vim b/runtime/indent/zimbu.vim
index 0e6e2ab1d1..08369e42e5 100644
--- a/runtime/indent/zimbu.vim
+++ b/runtime/indent/zimbu.vim
@@ -1,7 +1,8 @@
" Vim indent file
" Language: Zimbu
-" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2021 Sep 26
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2023 Aug 10
+" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Only load this indent file when no other was loaded.
if exists("b:did_indent")