summaryrefslogtreecommitdiffstats
path: root/runtime/indent/j.vim
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:44:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:44:24 +0000
commit8baab3c8d7a6f22888bd581cd5c6098fd2e4b5a8 (patch)
tree3537e168b860f2742f6029d70501b5ed7d15d345 /runtime/indent/j.vim
parentInitial commit. (diff)
downloadvim-8baab3c8d7a6f22888bd581cd5c6098fd2e4b5a8.tar.xz
vim-8baab3c8d7a6f22888bd581cd5c6098fd2e4b5a8.zip
Adding upstream version 2:8.1.0875.upstream/2%8.1.0875upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'runtime/indent/j.vim')
-rw-r--r--runtime/indent/j.vim50
1 files changed, 50 insertions, 0 deletions
diff --git a/runtime/indent/j.vim b/runtime/indent/j.vim
new file mode 100644
index 0000000..ea3d509
--- /dev/null
+++ b/runtime/indent/j.vim
@@ -0,0 +1,50 @@
+" Vim indent file
+" Language: J
+" Maintainer: David Bürgin <676c7473@gmail.com>
+" URL: https://github.com/glts/vim-j
+" Last Change: 2015-01-11
+
+if exists('b:did_indent')
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetJIndent()
+setlocal indentkeys-=0{,0},:,0#
+setlocal indentkeys+=0),0<:>,=case.,=catch.,=catchd.,=catcht.,=do.,=else.,=elseif.,=end.,=fcase.
+
+let b:undo_indent = 'setlocal indentkeys< indentexpr<'
+
+if exists('*GetJIndent')
+ finish
+endif
+
+" If g:j_indent_definitions is true, the bodies of explicit definitions of
+" adverbs, conjunctions, and verbs will be indented. Default is false (0).
+if !exists('g:j_indent_definitions')
+ let g:j_indent_definitions = 0
+endif
+
+function GetJIndent() abort
+ let l:prevlnum = prevnonblank(v:lnum - 1)
+ if l:prevlnum == 0
+ return 0
+ endif
+ let l:indent = indent(l:prevlnum)
+ let l:prevline = getline(l:prevlnum)
+ if l:prevline =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|fcase\|for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.\%(\%(\<end\.\)\@!.\)*$'
+ " Increase indentation after an initial control word that starts or
+ " continues a block and is not terminated by "end."
+ let l:indent += shiftwidth()
+ elseif g:j_indent_definitions && (l:prevline =~# '\<\%([1-4]\|13\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>' || l:prevline =~# '^\s*:\s*$')
+ " Increase indentation in explicit definitions of adverbs, conjunctions,
+ " and verbs
+ let l:indent += shiftwidth()
+ endif
+ " Decrease indentation in lines that start with either control words that
+ " continue or end a block, or the special items ")" and ":"
+ if getline(v:lnum) =~# '^\s*\%()\|:\|\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|end\|fcase\)\.\)'
+ let l:indent -= shiftwidth()
+ endif
+ return l:indent
+endfunction