diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-04-06 14:09:13 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-04-06 14:09:13 +0200 |
commit | 75b8156a445fb4788dc3d1946764af30b5c50ac4 (patch) | |
tree | 7430b073f6771ca2b5bb1d45b627eefe91e6773d /runtime/indent/j.vim | |
parent | 7e38ea2fb6a781213c85824dcf9ccb582fbc5c43 (diff) |
Updated runtime files.
Diffstat (limited to 'runtime/indent/j.vim')
-rw-r--r-- | runtime/indent/j.vim | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/runtime/indent/j.vim b/runtime/indent/j.vim index ae443bae2a..e268e1fcd3 100644 --- a/runtime/indent/j.vim +++ b/runtime/indent/j.vim @@ -2,7 +2,7 @@ " Language: J " Maintainer: David Bürgin <676c7473@gmail.com> " URL: https://github.com/glts/vim-j -" Last Change: 2014-03-17 +" Last Change: 2014-04-05 if exists('b:did_indent') finish @@ -10,8 +10,8 @@ endif let b:did_indent = 1 setlocal indentexpr=GetJIndent() -setlocal indentkeys-=0{,0},\:,0# -setlocal indentkeys+=0),=case.,=catch.,=catchd.,=catcht.,=do.,=else.,=elseif.,=end.,=fcase. +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<' @@ -19,19 +19,31 @@ if exists('*GetJIndent') finish endif -function GetJIndent() +" 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 prevlnum = prevnonblank(v:lnum-1) if prevlnum == 0 return 0 endif - let indent = indent(prevlnum) - if getline(prevlnum) =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|fcase\|for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.' - if getline(prevlnum) !~# '\<end\.' - let indent += shiftwidth() - endif + let prevline = getline(prevlnum) + if 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 indent += shiftwidth() + elseif g:j_indent_definitions && (prevline =~# '\<\%([1-4]\|13\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>' || prevline =~# '^\s*:\s*$') + " Increase indentation in explicit definitions of adverbs, conjunctions, + " and verbs + let indent += shiftwidth() endif - if getline(v:lnum) =~# '^\s*\%(\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|end\|fcase\)\.\)\|)' + " 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 indent -= shiftwidth() endif return indent |