From 3d39ea3ea9b6e66640e59731d155d731218e7e62 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 May 2024 07:11:50 +0800 Subject: vim-patch:9.1.0442: hare runtime files outdated (#29011) Problem: hare runtime files outdated Solution: runtime(hare): update hare.vim to match upstream (Amelia Clarke) closes: vim/vim#14836 https://github.com/vim/vim/commit/35dfe58a540e2fb0eff953630f8e4fcbf4bc26ca Co-authored-by: Amelia Clarke --- runtime/indent/hare.vim | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'runtime/indent') 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 -" Last Change: 2022 Sep 22 -" 2023 Aug 28 by Vim Project (undo_indent) +" Language: Hare +" Maintainer: Amelia Clarke +" 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 -- cgit From 14a7644181fb3244d548e5d3a0fa23d67580def2 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 26 May 2024 20:07:46 +0200 Subject: vim-patch:76174e7: runtime(asm): remove the indent plugin since it has too many issues fixes: vim/vim#14791 https://github.com/vim/vim/commit/76174e71101503900d54d38e00b3a869af1fdd85 Co-authored-by: Christian Brabandt --- runtime/indent/asm.vim | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 runtime/indent/asm.vim (limited to 'runtime/indent') 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 -" 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 -- cgit From c06f3dbe3ee82bd8c9e5d8625b225a937a9e5e9e Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 11 Jun 2024 08:44:44 +0200 Subject: vim-patch:2d88210: runtime(kdl): include syntax, indent and ftplugin files closes: vim/vim#14956 https://github.com/vim/vim/commit/2d88210b3c8516c30ed104054e5cdaef67880755 Co-authored-by: inzuo Jiang Co-authored-by: Aram Drevekenin --- runtime/indent/kdl.vim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 runtime/indent/kdl.vim (limited to 'runtime/indent') diff --git a/runtime/indent/kdl.vim b/runtime/indent/kdl.vim new file mode 100644 index 0000000000..2d24f18dff --- /dev/null +++ b/runtime/indent/kdl.vim @@ -0,0 +1,26 @@ +" Vim indent file +" Language: KDL +" Author: Aram Drevekenin +" Maintainer: Yinzuo Jiang +" Last Change: 2024-06-10 + +" 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 = getline(v:lnum) + let previousNum = prevnonblank(v:lnum - 1) + let previous = getline(previousNum) + + if previous =~ "{" && previous !~ "}" && line !~ "}" && line !~ ":$" + return indent(previousNum) + &tabstop + else + return indent(previousNum) + endif +endfunction -- cgit From 66a1e028e6edfc26e9546f1c68f3e4bdf159511e Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 11 Jun 2024 19:33:06 +0200 Subject: vim-patch:2e3b2a8: runtime(kdl): use shiftwidth() instead of &tabstop in indent script closes: vim/vim#14962 https://github.com/vim/vim/commit/2e3b2a8d8971850f15fb367ddb358a8565e15324 Co-authored-by: Yinzuo Jiang --- runtime/indent/kdl.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/indent') diff --git a/runtime/indent/kdl.vim b/runtime/indent/kdl.vim index 2d24f18dff..b1b004d0a2 100644 --- a/runtime/indent/kdl.vim +++ b/runtime/indent/kdl.vim @@ -2,7 +2,7 @@ " Language: KDL " Author: Aram Drevekenin " Maintainer: Yinzuo Jiang -" Last Change: 2024-06-10 +" Last Change: 2024-06-11 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -19,7 +19,7 @@ function! KdlIndent(...) let previous = getline(previousNum) if previous =~ "{" && previous !~ "}" && line !~ "}" && line !~ ":$" - return indent(previousNum) + &tabstop + return indent(previousNum) + shiftwidth() else return indent(previousNum) endif -- cgit From 615e859a0e0a6410dccc095693350e0ec2a280de Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 16 Jun 2024 11:30:17 +0200 Subject: vim-patch:79da22d: runtime(kdl): fix KdlIndent and kdlComment in indent script (vim/vim#15019) https://github.com/vim/vim/commit/79da22de755e28bd8d4f58fc4bf34cf94f45de63 Co-authored-by: Yinzuo Jiang --- runtime/indent/kdl.vim | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'runtime/indent') diff --git a/runtime/indent/kdl.vim b/runtime/indent/kdl.vim index b1b004d0a2..b0a6bd90d9 100644 --- a/runtime/indent/kdl.vim +++ b/runtime/indent/kdl.vim @@ -2,7 +2,7 @@ " Language: KDL " Author: Aram Drevekenin " Maintainer: Yinzuo Jiang -" Last Change: 2024-06-11 +" Last Change: 2024-06-16 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -14,13 +14,17 @@ setlocal indentexpr=KdlIndent() let b:undo_indent = "setlocal indentexpr<" function! KdlIndent(...) - let line = getline(v:lnum) + let line = substitute(getline(v:lnum), '//.*$', '', '') let previousNum = prevnonblank(v:lnum - 1) - let previous = getline(previousNum) + let previous = substitute(getline(previousNum), '//.*$', '', '') - if previous =~ "{" && previous !~ "}" && line !~ "}" && line !~ ":$" - return indent(previousNum) + shiftwidth() - else - return indent(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 -- cgit From 5eb604c64214957dc777e77cf1cc8d19dd8d8369 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 21 Jun 2024 10:35:48 +0200 Subject: vim-patch:17e0a19: runtime(scheme): update runtime files Add TODO highlighting, disable text-wrapping, add "define-library" to lispwords on CHICKEN. Update MAINTAINERS. closes: vim/vim#15063 https://github.com/vim/vim/commit/17e0a1969da4e70771435fc7fa9d8c96d25c8b00 Co-authored-by: Evan Hanson --- runtime/indent/scheme.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'runtime/indent') 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 +" 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") -- cgit From 12c9791e0fef7ee0d6cf6d3b828caa488d6347ea Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 3 Jul 2024 15:24:12 +0800 Subject: fix(runtime): stop treesitter highlight in b:undo_ftplugin (#29533) It seems that nvim-treesitter stops treesitter highlight when changing filetype, so it makes sense for builtin ftplugins to do this as well. Use :call and v:lua here to allow separation with '|'. --- runtime/indent/query.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/indent') 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]]) -- cgit From c49bcde9271a5bc22decbdf1a173207e9932fbf3 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 4 Jul 2024 19:27:46 +0200 Subject: vim-patch:11d5992: runtime(rust): use shiftwidth() in indent script closes: vim/vim#15138 https://github.com/vim/vim/commit/11d599257310bb95a7d1a3537345ae26f36c6210 Co-authored-by: novenary --- runtime/indent/rust.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'runtime/indent') 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 " 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 -- cgit From 26d52538051f72ba9e6e34a0a43db2cc3d12dcff Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 11 Jul 2024 22:55:26 +0200 Subject: vim-patch:fc533c9: runtime(mojo): include mojo ftplugin and indent script Taken from excerpts of the Python ftplugin and adapted, indent script simply sources the python indent script. closes: vim/vim#15171 https://github.com/vim/vim/commit/fc533c9f06aff579437f9f2348a21241a72c7967 Co-authored-by: Riley Bruins --- runtime/indent/mojo.vim | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 runtime/indent/mojo.vim (limited to 'runtime/indent') 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 +" Last Change: 2024 Jul 07 + +runtime! indent/python.vim -- cgit From 79130c0fd393e3eef8e4c939c54ea3d3faec2149 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 14 Jul 2024 17:26:40 +0200 Subject: vim-patch:9.1.0586: ocaml runtime files are outdated Problem: ocaml runtime files are outdated Solution: sync those files with the upstream repo, detect a few more ocaml files (Yinzuo Jiang) closes: vim/vim#15260 https://github.com/vim/vim/commit/700cf8cfa1e926e2ba676203b3ad90c2c2083f1d Co-authored-by: Yinzuo Jiang --- runtime/indent/ocaml.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/indent') 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 " 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 -- cgit From a0fd51c1e2db17ab21e2a2c907b232d05dfffc88 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 15 Jul 2024 20:02:22 +0200 Subject: vim-patch:1cc4cae: runtime(typst): Add typst runtime files closes: vim/vim#15234 https://github.com/vim/vim/commit/1cc4cae961a7b49608ef7bd56837cc723d49db4d Co-authored-by: Gregory Anders --- runtime/indent/typst.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 runtime/indent/typst.vim (limited to 'runtime/indent') 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 +" 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<' -- cgit From 79d492a4218ee6b4da5becbebb712a0f1f65d0f5 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:28:05 -0500 Subject: vim-patch:9.1.0610: filetype: OpenGL Shading Language files are not detected (#29831) Problem: filetype: OpenGL Shading Language files are not detected Solution: detect various file extensions as GLSL filetype, include indent and syntax script, do no longer recognize '*.comp' as Mason filetype (Gregory Anders) closes: vim/vim#15317 https://github.com/vim/vim/commit/e4b991ed36f96dd01c6d75e46a04fd1a99180e58 --- runtime/indent/glsl.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 runtime/indent/glsl.vim (limited to 'runtime/indent') 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 +" 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<' -- cgit From 1b5a394ffd4bb638ec9cbbb5e4d12d11225389cf Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 29 Jul 2024 21:19:24 +0200 Subject: vim-patch:011f222: runtime(thrift): add ftplugin, indent and syntax scripts Problem: Apache Thrift files misses ftplugin, indent and syntax scripts Solution: - add ftplugin and indent scripts - add thrift indent test - port the syntax script from apache/thrift (Apache License 2) Reference: https://diwakergupta.github.io/thrift-missing-guide/#_language_reference closes: vim/vim#15387 https://github.com/vim/vim/commit/011f2223e5df68f45a382f6a9dff6eaf5ecac346 Co-authored-by: Yinzuo Jiang --- runtime/indent/testdir/thrift.in | 38 +++++++++++++++++++++ runtime/indent/testdir/thrift.ok | 38 +++++++++++++++++++++ runtime/indent/thrift.vim | 74 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 runtime/indent/testdir/thrift.in create mode 100644 runtime/indent/testdir/thrift.ok create mode 100644 runtime/indent/thrift.vim (limited to 'runtime/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 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 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 +" 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 -- cgit From 28e2e8aa04308fbba1cdd9ec65305af95d9d1a0f Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 4 Aug 2024 18:59:47 +0200 Subject: vim-patch:c0f7505: runtime(lua): add/subtract a 'shiftwidth' after '('/')' in indentexpr Problem: - Current lua indentexpr does not indent for '(' ')'. - Missing indent test for lua. Solution: - Match '(', ')' in `function GetLuaIndentIntern`. - Add an indent test for lua. closes: vim/vim#15364 https://github.com/vim/vim/commit/c0f7505edeb36bf3e19386f276cafad7cba717a2 Co-authored-by: Yinzuo Jiang --- runtime/indent/lua.vim | 9 +++++---- runtime/indent/testdir/lua.in | 19 +++++++++++++++++++ runtime/indent/testdir/lua.ok | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 runtime/indent/testdir/lua.in create mode 100644 runtime/indent/testdir/lua.ok (limited to 'runtime/indent') 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 " 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/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 -- cgit From f35d5afbf1bae81896d4b959c7d99cf50e0c306f Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 7 Aug 2024 22:06:05 +0200 Subject: vim-patch:39eff4c: runtime(proto): Add indent script for protobuf filetype closes: vim/vim#15446 https://github.com/vim/vim/commit/39eff4cdc055a0f0db0d32fcf7a74fe30ea54f25 Co-authored-by: David Pedersen --- runtime/indent/proto.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 runtime/indent/proto.vim (limited to 'runtime/indent') 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 +" 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 -- cgit From 77380e1601ad72b7cc9466ef3408946ab2c79344 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 17 Aug 2024 11:38:50 +0200 Subject: vim-patch:c6ed816: runtime(yaml): do not re-indent when commenting out lines It's a personal annoyance for me. I have to edit yaml files on a lot of customer environments and whenever you type '#' at the start of the line, the commented line will be indented by whatever indent the previous line had. I hate this seriously, because it makes un-commenting painful. So let's fix this. But instead of messing with the indent function, let's just remove the '0#' from cinkeys, so that Vim won't perform re-indenting when commenting out such a yaml file. closes: vim/vim#15494 https://github.com/vim/vim/commit/c6ed816761f44da92d8c61f5ea6cb7fdbb45fac5 Co-authored-by: Christian Brabandt --- runtime/indent/yaml.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/indent') 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 " 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 From 51088b67cb1e9363df98cfc8f3bbd6caad03cc5d Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:32:52 -0500 Subject: vim-patch:150b507: runtime(hcl,terraform): Add runtime files for HCL and Terraform (#30266) closes: vim/vim#15618 https://github.com/vim/vim/commit/150b5078ac886519083576124090489c3a21bd3b --- runtime/indent/hcl.vim | 16 ++++++++++++++++ runtime/indent/terraform.vim | 11 +++++++++++ 2 files changed, 27 insertions(+) create mode 100644 runtime/indent/hcl.vim create mode 100644 runtime/indent/terraform.vim (limited to 'runtime/indent') 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/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 -- cgit