2013-09-22 14:42:24 +02:00
|
|
|
" Vim indent file
|
|
|
|
" Language: J
|
|
|
|
" Maintainer: David Bürgin <676c7473@gmail.com>
|
2014-03-22 21:02:50 +01:00
|
|
|
" URL: https://github.com/glts/vim-j
|
|
|
|
" Last Change: 2014-03-17
|
2013-09-22 14:42:24 +02:00
|
|
|
|
2014-03-22 21:02:50 +01:00
|
|
|
if exists('b:did_indent')
|
2013-09-22 14:42:24 +02:00
|
|
|
finish
|
|
|
|
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.
|
|
|
|
|
2014-03-22 21:02:50 +01:00
|
|
|
let b:undo_indent = 'setlocal indentkeys< indentexpr<'
|
2013-09-22 14:42:24 +02:00
|
|
|
|
2014-03-22 21:02:50 +01:00
|
|
|
if exists('*GetJIndent')
|
2013-09-22 14:42:24 +02:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
|
|
|
function GetJIndent()
|
|
|
|
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\.'
|
2014-03-22 21:02:50 +01:00
|
|
|
let indent += shiftwidth()
|
2013-09-22 14:42:24 +02:00
|
|
|
endif
|
|
|
|
endif
|
2014-03-22 21:02:50 +01:00
|
|
|
if getline(v:lnum) =~# '^\s*\%(\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|end\|fcase\)\.\)\|)'
|
|
|
|
let indent -= shiftwidth()
|
2013-09-22 14:42:24 +02:00
|
|
|
endif
|
|
|
|
return indent
|
|
|
|
endfunction
|