From a4e9136f68a40b1cb0eb6df5a5f06603224a87f4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 19 Sep 2024 06:05:19 +0200 Subject: Merging upstream version 2:9.1.0698. Signed-off-by: Daniel Baumann --- runtime/indent/Make_mvc.mak | 4 +-- runtime/indent/Makefile | 4 +-- runtime/indent/glsl.vim | 14 ++++++++ runtime/indent/lua.vim | 9 ++--- runtime/indent/mojo.vim | 6 ++++ runtime/indent/ocaml.vim | 4 +-- runtime/indent/proto.vim | 19 +++++++++++ runtime/indent/rust.vim | 9 +++-- runtime/indent/scheme.vim | 9 ++--- runtime/indent/testdir/lua.in | 19 +++++++++++ runtime/indent/testdir/lua.ok | 19 +++++++++++ runtime/indent/testdir/thrift.in | 38 +++++++++++++++++++++ runtime/indent/testdir/thrift.ok | 38 +++++++++++++++++++++ runtime/indent/thrift.vim | 74 ++++++++++++++++++++++++++++++++++++++++ runtime/indent/typst.vim | 18 ++++++++++ runtime/indent/vim.vim | 6 ++-- runtime/indent/yaml.vim | 5 +-- 17 files changed, 274 insertions(+), 21 deletions(-) create mode 100644 runtime/indent/glsl.vim create mode 100644 runtime/indent/mojo.vim create mode 100644 runtime/indent/proto.vim create mode 100644 runtime/indent/testdir/lua.in create mode 100644 runtime/indent/testdir/lua.ok create mode 100644 runtime/indent/testdir/thrift.in create mode 100644 runtime/indent/testdir/thrift.ok create mode 100644 runtime/indent/thrift.vim create mode 100644 runtime/indent/typst.vim (limited to 'runtime/indent') diff --git a/runtime/indent/Make_mvc.mak b/runtime/indent/Make_mvc.mak index 0f73d7f..a50494d 100644 --- a/runtime/indent/Make_mvc.mak +++ b/runtime/indent/Make_mvc.mak @@ -4,7 +4,7 @@ .SUFFIXES: -VIM = vim.exe +VIMPROG = vim.exe VIMRUNTIME = .. # Run the tests that didn't run yet or failed previously. @@ -12,7 +12,7 @@ VIMRUNTIME = .. # If a test fails a testdir\*.fail file will be written. test : @ set "VIMRUNTIME=$(VIMRUNTIME)" - $(VIM) --clean --not-a-term -u testdir\runtest.vim + $(VIMPROG) --clean --not-a-term -u testdir\runtest.vim clean testclean : diff --git a/runtime/indent/Makefile b/runtime/indent/Makefile index 66ded80..36a3f15 100644 --- a/runtime/indent/Makefile +++ b/runtime/indent/Makefile @@ -3,14 +3,14 @@ .SUFFIXES: .PHONY: test clean testclean -VIM = vim +VIMPROG = vim VIMRUNTIME = .. # Run the tests that didn't run yet or failed previously. # If a test succeeds a testdir/*.out file will be written. # If a test fails a testdir/*.fail file will be written. test: - VIMRUNTIME=$(VIMRUNTIME) $(VIM) --clean --not-a-term -u testdir/runtest.vim + VIMRUNTIME=$(VIMRUNTIME) $(VIMPROG) --clean --not-a-term -u testdir/runtest.vim clean testclean: diff --git a/runtime/indent/glsl.vim b/runtime/indent/glsl.vim new file mode 100644 index 0000000..4ebee60 --- /dev/null +++ b/runtime/indent/glsl.vim @@ -0,0 +1,14 @@ +" Language: OpenGL Shading Language +" Maintainer: Gregory Anders +" 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/lua.vim b/runtime/indent/lua.vim index 35b08d4..ce6cfe1 100644 --- a/runtime/indent/lua.vim +++ b/runtime/indent/lua.vim @@ -4,6 +4,7 @@ " First Author: Max Ischenko " 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, '\\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 0000000..9b6a7d4 --- /dev/null +++ b/runtime/indent/mojo.vim @@ -0,0 +1,6 @@ +" Vim indent file +" Language: Mojo +" Maintainer: Riley Bruins +" Last Change: 2024 Jul 07 + +runtime! indent/python.vim diff --git a/runtime/indent/ocaml.vim b/runtime/indent/ocaml.vim index c9beb8b..d137796 100644 --- a/runtime/indent/ocaml.vim +++ b/runtime/indent/ocaml.vim @@ -4,8 +4,7 @@ " Mike Leary " Markus Mottl " 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 0000000..743f140 --- /dev/null +++ b/runtime/indent/proto.vim @@ -0,0 +1,19 @@ +" Vim indent file +" Language: Protobuf +" Maintainer: David Pedersen +" 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/rust.vim b/runtime/indent/rust.vim index 7c055ec..a96650d 100644 --- a/runtime/indent/rust.vim +++ b/runtime/indent/rust.vim @@ -2,7 +2,10 @@ " Language: Rust " Author: Chris Morgan " 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 496da32..888659b 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 +" Language: Scheme +" Last Change: 2024 Jun 21 +" Maintainer: Evan Hanson " Previous Maintainer: Sergey Khorev -" 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/testdir/lua.in b/runtime/indent/testdir/lua.in new file mode 100644 index 0000000..c8f5d2b --- /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 0000000..95f9873 --- /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 0000000..7490dc8 --- /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 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 0000000..9e2a482 --- /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 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 0000000..e0860e1 --- /dev/null +++ b/runtime/indent/thrift.vim @@ -0,0 +1,74 @@ +" Vim indent file +" Language: Apache Thrift +" Maintainer: Yinzuo Jiang +" 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 0000000..6aaa04a --- /dev/null +++ b/runtime/indent/typst.vim @@ -0,0 +1,18 @@ +" Vim indent file +" Language: Typst +" Maintainer: Gregory Anders +" 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/vim.vim b/runtime/indent/vim.vim index 97a4a36..c95a76d 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -3,7 +3,7 @@ vim9script # Vim indent file # Language: Vim script # Maintainer: The Vim Project -# Last Change: 2023 Aug 10 +# Last Change: 2024 Jul 12 # Former Maintainer: Bram Moolenaar # Only load this indent file when no other was loaded. @@ -16,7 +16,9 @@ b:undo_indent = 'setlocal indentkeys< indentexpr<' import autoload '../autoload/dist/vimindent.vim' -setlocal indentexpr=vimindent.Expr() +# export indentexpr as a global function, so it can be easily manipulated by plugins +g:VimIndent = vimindent.Expr +setlocal indentexpr=g:VimIndent() setlocal indentkeys+==endif,=enddef,=endfu,=endfor,=endwh,=endtry,=endclass,=endinterface,=endenum,=},=else,=cat,=finall,=END,0\\ execute('setlocal indentkeys+=0=\"\\\ ,0=#\\\ ') setlocal indentkeys-=0# diff --git a/runtime/indent/yaml.vim b/runtime/indent/yaml.vim index e5daf9f..c387127 100644 --- a/runtime/indent/yaml.vim +++ b/runtime/indent/yaml.vim @@ -3,7 +3,8 @@ " Maintainer: Nikolai Pavlov " 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<' -- cgit v1.2.3