diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
| commit | 1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch) | |
| tree | cd08258054db80bb9a11b1061bb091c70b76926a /runtime/indent | |
| parent | eaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff) | |
| parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
| download | rneovim-aucmd_textputpost.tar.gz rneovim-aucmd_textputpost.tar.bz2 rneovim-aucmd_textputpost.zip | |
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'runtime/indent')
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 |