diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2024-11-19 22:57:13 +0000 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2024-11-19 22:57:13 +0000 |
| commit | 9be89f131f87608f224f0ee06d199fcd09d32176 (patch) | |
| tree | 11022dcfa9e08cb4ac5581b16734196128688d48 /runtime/indent | |
| parent | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff) | |
| parent | 88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff) | |
| download | rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2 rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip | |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/indent')
| -rw-r--r-- | runtime/indent/asm.vim | 29 | ||||
| -rw-r--r-- | runtime/indent/glsl.vim | 14 | ||||
| -rw-r--r-- | runtime/indent/hare.vim | 31 | ||||
| -rw-r--r-- | runtime/indent/hcl.vim | 16 | ||||
| -rw-r--r-- | runtime/indent/kdl.vim | 30 | ||||
| -rw-r--r-- | runtime/indent/lua.vim | 9 | ||||
| -rw-r--r-- | runtime/indent/mojo.vim | 6 | ||||
| -rw-r--r-- | runtime/indent/ocaml.vim | 4 | ||||
| -rw-r--r-- | runtime/indent/proto.vim | 19 | ||||
| -rw-r--r-- | runtime/indent/query.lua | 4 | ||||
| -rw-r--r-- | runtime/indent/rust.vim | 9 | ||||
| -rw-r--r-- | runtime/indent/scheme.vim | 9 | ||||
| -rw-r--r-- | runtime/indent/terraform.vim | 11 | ||||
| -rw-r--r-- | runtime/indent/testdir/lua.in | 19 | ||||
| -rw-r--r-- | runtime/indent/testdir/lua.ok | 19 | ||||
| -rw-r--r-- | runtime/indent/testdir/thrift.in | 38 | ||||
| -rw-r--r-- | runtime/indent/testdir/thrift.ok | 38 | ||||
| -rw-r--r-- | runtime/indent/thrift.vim | 74 | ||||
| -rw-r--r-- | runtime/indent/typst.vim | 18 | ||||
| -rw-r--r-- | runtime/indent/yaml.vim | 5 |
20 files changed, 343 insertions, 59 deletions
diff --git a/runtime/indent/asm.vim b/runtime/indent/asm.vim deleted file mode 100644 index 054612b9d6..0000000000 --- a/runtime/indent/asm.vim +++ /dev/null @@ -1,29 +0,0 @@ -" Vim indent file -" Language: asm -" Maintainer: Philip Jones <philj56@gmail.com> -" Upstream: https://github.com/philj56/vim-asm-indent -" Last Change: 2017-Jul-01 -" 2024 Apr 25 by Vim Project (undo_indent) - -if exists("b:did_indent") - finish -endif -let b:did_indent = 1 - -setlocal indentexpr=s:getAsmIndent() -setlocal indentkeys=<:>,!^F,o,O - -let b:undo_indent = "setlocal indentexpr< indentkeys<" - -function! s:getAsmIndent() - let line = getline(v:lnum) - let ind = shiftwidth() - - " If the line is a label (starts with ':' terminated keyword), - " then don't indent - if line =~ '^\s*\k\+:' - let ind = 0 - endif - - return ind -endfunction diff --git a/runtime/indent/glsl.vim b/runtime/indent/glsl.vim new file mode 100644 index 0000000000..4ebee60656 --- /dev/null +++ b/runtime/indent/glsl.vim @@ -0,0 +1,14 @@ +" Language: OpenGL Shading Language +" Maintainer: Gregory Anders <greg@gpanders.com> +" Last Modified: 2024 Jul 21 +" Upstream: https://github.com/tikhomirov/vim-glsl + +if exists('b:did_indent') + finish +endif +let b:did_indent = 1 + +setlocal autoindent cindent +setlocal cinoptions& + +let b:undo_indent = 'setl ai< ci< cino<' diff --git a/runtime/indent/hare.vim b/runtime/indent/hare.vim index 0a9d8dafd8..1b51d1e80a 100644 --- a/runtime/indent/hare.vim +++ b/runtime/indent/hare.vim @@ -1,19 +1,16 @@ " Vim indent file -" Language: Hare -" Maintainer: Amelia Clarke <me@rsaihe.dev> -" Last Change: 2022 Sep 22 -" 2023 Aug 28 by Vim Project (undo_indent) +" Language: Hare +" Maintainer: Amelia Clarke <selene@perilune.dev> +" Last Change: 2024-04-14 +" Upstream: https://git.sr.ht/~sircmpwn/hare.vim -if exists("b:did_indent") +if exists('b:did_indent') finish endif let b:did_indent = 1 -if !has("cindent") || !has("eval") - finish -endif - -setlocal cindent +let s:cpo_save = &cpo +set cpo&vim " L0 -> don't deindent labels " (s -> use one indent after a trailing ( @@ -41,7 +38,11 @@ setlocal cinwords=if,else,for,switch,match setlocal indentexpr=GetHareIndent() -let b:undo_indent = "setl cin< cino< cinw< inde< indk<" +let b:undo_indent = 'setl cino< cinw< inde< indk<' + +if exists('*GetHareIndent()') + finish +endif function! FloorCindent(lnum) return cindent(a:lnum) / shiftwidth() * shiftwidth() @@ -122,7 +123,8 @@ function! GetHareIndent() " Indent the body of a case. " If the previous line ended in a semicolon and the line before that was a " case, don't do any special indenting. - if prevline =~# '\v;\s*(//.*)?$' && prevprevline =~# '\v\=\>\s*(//.*)?$' && line !~# '\v^\s*}' + if prevline =~# '\v;\s*(//.*)?$' && prevprevline =~# '\v\=\>\s*(//.*)?$' + \ && line !~# '\v^\s*}' return indent(prevlnum) endif @@ -138,4 +140,7 @@ function! GetHareIndent() return l:indent endfunction -" vim: tabstop=2 shiftwidth=2 expandtab +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: et sw=2 sts=2 ts=8 diff --git a/runtime/indent/hcl.vim b/runtime/indent/hcl.vim new file mode 100644 index 0000000000..b13d2c5649 --- /dev/null +++ b/runtime/indent/hcl.vim @@ -0,0 +1,16 @@ +" Vim indent file +" Language: HCL +" Maintainer: Gregory Anders +" Upstream: https://github.com/hashivim/vim-terraform +" Last Change: 2024-09-03 + +if exists('b:did_indent') + finish +endif +let b:did_indent = 1 + +setlocal autoindent shiftwidth=2 tabstop=2 softtabstop=2 expandtab +setlocal indentexpr=hcl#indentexpr(v:lnum) +setlocal indentkeys+=<:>,0=},0=) + +let b:undo_indent = 'setlocal ai< sw< ts< sts< et< inde< indk<' diff --git a/runtime/indent/kdl.vim b/runtime/indent/kdl.vim new file mode 100644 index 0000000000..b0a6bd90d9 --- /dev/null +++ b/runtime/indent/kdl.vim @@ -0,0 +1,30 @@ +" Vim indent file +" Language: KDL +" Author: Aram Drevekenin <aram@poor.dev> +" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com> +" Last Change: 2024-06-16 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr=KdlIndent() +let b:undo_indent = "setlocal indentexpr<" + +function! KdlIndent(...) + let line = substitute(getline(v:lnum), '//.*$', '', '') + let previousNum = prevnonblank(v:lnum - 1) + let previous = substitute(getline(previousNum), '//.*$', '', '') + + let l:indent = indent(previousNum) + if previous =~ "{" && previous !~ "}" + let l:indent += shiftwidth() + endif + if line =~ "}" && line !~ "{" + let l:indent -= shiftwidth() + endif + return l:indent +endfunction +" vim: sw=2 sts=2 et diff --git a/runtime/indent/lua.vim b/runtime/indent/lua.vim index 35b08d4037..ce6cfe18cd 100644 --- a/runtime/indent/lua.vim +++ b/runtime/indent/lua.vim @@ -4,6 +4,7 @@ " First Author: Max Ischenko <mfi 'at' ukr.net> " Last Change: 2017 Jun 13 " 2022 Sep 07: b:undo_indent added by Doug Kearns +" 2024 Jul 27: by Vim project: match '(', ')' in function GetLuaIndentIntern() " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -46,12 +47,12 @@ function! GetLuaIndentIntern() endif " Add a 'shiftwidth' after lines that start a block: - " 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{' + " 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{', '(' let ind = indent(prevlnum) 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 @@ -65,9 +66,9 @@ function! GetLuaIndentIntern() endif endif - " Subtract a 'shiftwidth' on end, else, elseif, until and '}' + " Subtract a 'shiftwidth' on end, else, elseif, until, '}' and ')' " This is the part that requires 'indentkeys'. - let midx = match(getline(v:lnum), '^\s*\%(end\>\|else\>\|elseif\>\|until\>\|}\)') + let midx = match(getline(v:lnum), '^\s*\%(end\>\|else\>\|elseif\>\|until\>\|}\|)\)') if midx != -1 && synIDattr(synID(v:lnum, midx + 1, 1), "name") != "luaComment" let ind = ind - shiftwidth() endif diff --git a/runtime/indent/mojo.vim b/runtime/indent/mojo.vim new file mode 100644 index 0000000000..9b6a7d4c58 --- /dev/null +++ b/runtime/indent/mojo.vim @@ -0,0 +1,6 @@ +" Vim indent file +" Language: Mojo +" Maintainer: Riley Bruins <ribru17@gmail.com> +" Last Change: 2024 Jul 07 + +runtime! indent/python.vim diff --git a/runtime/indent/ocaml.vim b/runtime/indent/ocaml.vim index c9beb8be0b..d137796e3d 100644 --- a/runtime/indent/ocaml.vim +++ b/runtime/indent/ocaml.vim @@ -4,8 +4,7 @@ " Mike Leary <leary@nwlink.com> " Markus Mottl <markus.mottl@gmail.com> " URL: https://github.com/ocaml/vim-ocaml -" Last Change: 2023 Aug 28 - Add undo_indent (Vim Project) -" 2017 Jun 13 +" Last Change: 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) @@ -36,6 +35,7 @@ if !exists("no_ocaml_comments") setlocal comments=sr:(*\ ,mb:\ ,ex:*) setlocal comments^=sr:(**,mb:\ \ ,ex:*) setlocal fo=cqort + let b:undo_indent .= " | setl com< fo<" endif endif diff --git a/runtime/indent/proto.vim b/runtime/indent/proto.vim new file mode 100644 index 0000000000..743f14094b --- /dev/null +++ b/runtime/indent/proto.vim @@ -0,0 +1,19 @@ +" Vim indent file +" Language: Protobuf +" Maintainer: David Pedersen <limero@me.com> +" Last Change: 2024 Aug 07 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +" Protobuf is like indenting C +setlocal cindent +setlocal expandtab +setlocal shiftwidth=2 + +let b:undo_indent = "setlocal cindent< expandtab< shiftwidth<" + +" vim: sw=2 sts=2 et diff --git a/runtime/indent/query.lua b/runtime/indent/query.lua index 3261376d87..c5b4f1f03d 100644 --- a/runtime/indent/query.lua +++ b/runtime/indent/query.lua @@ -1,6 +1,6 @@ -- Neovim indent file -- Language: Treesitter query --- Last Change: 2022 Mar 29 +-- Last Change: 2024 Jul 03 -- it's a lisp! -vim.cmd([[ runtime! indent/lisp.vim ]]) +vim.cmd([[runtime! indent/lisp.vim]]) diff --git a/runtime/indent/rust.vim b/runtime/indent/rust.vim index 7c055ec739..a96650d419 100644 --- a/runtime/indent/rust.vim +++ b/runtime/indent/rust.vim @@ -2,7 +2,10 @@ " Language: Rust " Author: Chris Morgan <me@chrismorgan.info> " Last Change: 2023-09-11 +" 2024 Jul 04 by Vim Project: use shiftwidth() instead of hard-coding shifted values (#15138) + " For bugs, patches and license go to https://github.com/rust-lang/rust.vim +" Note: upstream seems umaintained: https://github.com/rust-lang/rust.vim/issues/502 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -179,7 +182,7 @@ function GetRustIndent(lnum) " 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 + return indent(prevlinenum) + shiftwidth() endif " Handle where clauses nicely: subsequent values should line up nicely. @@ -197,7 +200,7 @@ function GetRustIndent(lnum) 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 + return indent(l:scope_start) + shiftwidth() endif endif @@ -268,7 +271,7 @@ function GetRustIndent(lnum) " It's the closing line, dedent it return 0 else - return &shiftwidth + return shiftwidth() endif endif endif diff --git a/runtime/indent/scheme.vim b/runtime/indent/scheme.vim index 496da3267d..888659b1de 100644 --- a/runtime/indent/scheme.vim +++ b/runtime/indent/scheme.vim @@ -1,9 +1,10 @@ " Vim indent file -" Language: Scheme -" Last Change: 2018 Jan 31 -" Maintainer: Evan Hanson <evhan@foldling.org> +" Language: Scheme +" Last Change: 2024 Jun 21 +" Maintainer: Evan Hanson <evhan@foldling.org> " Previous Maintainer: Sergey Khorev <sergey.khorev@gmail.com> -" URL: https://foldling.org/vim/indent/scheme.vim +" Repository: https://git.foldling.org/vim-scheme.git +" URL: https://foldling.org/vim/indent/scheme.vim " Only load this indent file when no other was loaded. if exists("b:did_indent") diff --git a/runtime/indent/terraform.vim b/runtime/indent/terraform.vim new file mode 100644 index 0000000000..d62813d6a2 --- /dev/null +++ b/runtime/indent/terraform.vim @@ -0,0 +1,11 @@ +" Vim indent file +" Language: Terraform +" Maintainer: Gregory Anders +" Upstream: https://github.com/hashivim/vim-terraform +" Last Change: 2024-09-03 + +if exists('b:did_indent') + finish +endif + +runtime! indent/hcl.vim diff --git a/runtime/indent/testdir/lua.in b/runtime/indent/testdir/lua.in new file mode 100644 index 0000000000..c8f5d2bb8d --- /dev/null +++ b/runtime/indent/testdir/lua.in @@ -0,0 +1,19 @@ +-- vim: set ft=lua sw=2 noet: + +-- START_INDENT +function foo(a, b, c, d) + return { a, b, c, d } +end + +local a = foo( +1, +2, +"longxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", +4 +) + +local b = { +1, + 2, +} +-- END_INDENT diff --git a/runtime/indent/testdir/lua.ok b/runtime/indent/testdir/lua.ok new file mode 100644 index 0000000000..95f9873beb --- /dev/null +++ b/runtime/indent/testdir/lua.ok @@ -0,0 +1,19 @@ +-- vim: set ft=lua sw=2 noet: + +-- START_INDENT +function foo(a, b, c, d) + return { a, b, c, d } +end + +local a = foo( + 1, + 2, + "longxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + 4 +) + +local b = { + 1, + 2, +} +-- END_INDENT diff --git a/runtime/indent/testdir/thrift.in b/runtime/indent/testdir/thrift.in new file mode 100644 index 0000000000..7490dc8d30 --- /dev/null +++ b/runtime/indent/testdir/thrift.in @@ -0,0 +1,38 @@ +// vim: set ft=thrift sw=4 et: + +# START_INDENT +namespace cpp foo +namespace java com.foo.thrift + +include "Status.thrift" + +// These are supporting structs for JniFrontend.java, which serves as the glue +// between our C++ execution environment and the Java frontend. + +struct TSetSessionParams { + 1: required string user +} + +struct TAuthenticateParams { + 1: required string user + 2: required string passwd + 3: optional string host +4: optional string db_name + 5: optional list<string> table_names; +} + +/* { + * xxxx + * } + */ +// TColumnDesc +struct TColumnDesc { + // { +4: optional string tableName +5: optional string columnDefault + // Let FE control the type, which makes it easier to modify and display complex types +6: optional string columnTypeStr // deprecated +7: optional string dataType + // } +} +# END_INDENT diff --git a/runtime/indent/testdir/thrift.ok b/runtime/indent/testdir/thrift.ok new file mode 100644 index 0000000000..9e2a48242b --- /dev/null +++ b/runtime/indent/testdir/thrift.ok @@ -0,0 +1,38 @@ +// vim: set ft=thrift sw=4 et: + +# START_INDENT +namespace cpp foo +namespace java com.foo.thrift + +include "Status.thrift" + +// These are supporting structs for JniFrontend.java, which serves as the glue +// between our C++ execution environment and the Java frontend. + +struct TSetSessionParams { + 1: required string user +} + +struct TAuthenticateParams { + 1: required string user + 2: required string passwd + 3: optional string host + 4: optional string db_name + 5: optional list<string> table_names; +} + +/* { + * xxxx + * } + */ +// TColumnDesc +struct TColumnDesc { + // { + 4: optional string tableName + 5: optional string columnDefault + // Let FE control the type, which makes it easier to modify and display complex types + 6: optional string columnTypeStr // deprecated + 7: optional string dataType + // } +} +# END_INDENT diff --git a/runtime/indent/thrift.vim b/runtime/indent/thrift.vim new file mode 100644 index 0000000000..e0860e12a2 --- /dev/null +++ b/runtime/indent/thrift.vim @@ -0,0 +1,74 @@ +" Vim indent file +" Language: Apache Thrift +" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com> +" Last Change: 2024/07/29 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal cindent +setlocal indentexpr=GetThriftIndent() + +let b:undo_indent = "set cindent< indentexpr<" + +" Only define the function once. +if exists("*GetThriftIndent") + finish +endif + +let s:keepcpo= &cpo +set cpo&vim + +function! SkipThriftBlanksAndComments(startline) + let lnum = a:startline + while lnum > 1 + let lnum = prevnonblank(lnum) + if getline(lnum) =~ '\*/\s*$' + while getline(lnum) !~ '/\*' && lnum > 1 + let lnum = lnum - 1 + endwhile + if getline(lnum) =~ '^\s*/\*' + let lnum = lnum - 1 + else + break + endif + elseif getline(lnum) =~ '^\s*\(//\|#\)' + let lnum = lnum - 1 + else + break + endif + endwhile + return lnum +endfunction + +function GetThriftIndent() + " Thrift is just like C; use the built-in C indenting and then correct a few + " specific cases. + let theIndent = cindent(v:lnum) + + " If we're in the middle of a comment then just trust cindent + if getline(v:lnum) =~ '^\s*\*' + return theIndent + endif + + let line = substitute(getline(v:lnum), '\(//\|#\).*$', '', '') + let previousNum = SkipThriftBlanksAndComments(v:lnum - 1) + let previous = substitute(getline(previousNum), '\(//\|#\).*$', '', '') + + let l:indent = indent(previousNum) + if previous =~ "{" && previous !~ "}" + let l:indent += shiftwidth() + endif + if line =~ "}" && line !~ "{" + let l:indent -= shiftwidth() + endif + return l:indent +endfunction + +let &cpo = s:keepcpo +unlet s:keepcpo + +" vim: sw=2 sts=2 et diff --git a/runtime/indent/typst.vim b/runtime/indent/typst.vim new file mode 100644 index 0000000000..6aaa04a53a --- /dev/null +++ b/runtime/indent/typst.vim @@ -0,0 +1,18 @@ +" Vim indent file +" Language: Typst +" Maintainer: Gregory Anders <greg@gpanders.com> +" Last Change: 2024-07-14 +" Based on: https://github.com/kaarmu/typst.vim + +if exists('b:did_indent') + finish +endif +let b:did_indent = 1 + +setlocal expandtab +setlocal softtabstop=2 +setlocal shiftwidth=2 +setlocal autoindent +setlocal indentexpr=typst#indentexpr() + +let b:undo_indent = 'setl et< sts< sw< ai< inde<' diff --git a/runtime/indent/yaml.vim b/runtime/indent/yaml.vim index e5daf9f219..c38712745d 100644 --- a/runtime/indent/yaml.vim +++ b/runtime/indent/yaml.vim @@ -3,7 +3,8 @@ " Maintainer: Nikolai Pavlov <zyx.vim@gmail.com> " Last Updates: Lukas Reineke, "lacygoill" " Last Change: 2022 Jun 17 -" 2024 Feb 29 disable mulitline indent by default (The Vim project) +" 2024 Feb 29 by Vim project: disable mulitline indent by default +" 2024 Aug 14 by Vim project: fix re-indenting when commenting out lines " Only load this indent file when no other was loaded. if exists('b:did_indent') @@ -13,7 +14,7 @@ endif let b:did_indent = 1 setlocal indentexpr=GetYAMLIndent(v:lnum) -setlocal indentkeys=!^F,o,O,0#,0},0],<:>,0- +setlocal indentkeys=!^F,o,O,0},0],<:>,0- setlocal nosmartindent let b:undo_indent = 'setlocal indentexpr< indentkeys< smartindent<' |