summaryrefslogtreecommitdiffstats
path: root/runtime/indent
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/glsl.vim14
-rw-r--r--runtime/indent/lua.vim9
-rw-r--r--runtime/indent/mojo.vim6
-rw-r--r--runtime/indent/ocaml.vim4
-rw-r--r--runtime/indent/proto.vim19
-rw-r--r--runtime/indent/testdir/lua.in19
-rw-r--r--runtime/indent/testdir/lua.ok19
-rw-r--r--runtime/indent/testdir/thrift.in38
-rw-r--r--runtime/indent/testdir/thrift.ok38
-rw-r--r--runtime/indent/thrift.vim74
-rw-r--r--runtime/indent/typst.vim18
-rw-r--r--runtime/indent/vim.vim6
-rw-r--r--runtime/indent/yaml.vim5
13 files changed, 259 insertions, 10 deletions
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/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/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/vim.vim b/runtime/indent/vim.vim
index 97a4a3662d..c95a76dd4e 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 <https://github.com/vim/vim>
-# Last Change: 2023 Aug 10
+# Last Change: 2024 Jul 12
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
# 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 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<'