From afce081b90c1e2c50c3507758c7558a0dfa1f33e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 15:18:03 +0200 Subject: Adding upstream version 2:8.2.2434. Signed-off-by: Daniel Baumann --- runtime/indent/j.vim | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 runtime/indent/j.vim (limited to 'runtime/indent/j.vim') diff --git a/runtime/indent/j.vim b/runtime/indent/j.vim new file mode 100644 index 0000000..c308512 --- /dev/null +++ b/runtime/indent/j.vim @@ -0,0 +1,50 @@ +" Vim indent file +" Language: J +" Maintainer: David Bürgin +" URL: https://gitlab.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\)\)\.\%(\%(\' || 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 -- cgit v1.2.3