Mercurial > vim
comparison runtime/indent/j.vim @ 5362:ab1508486b12
Update runtime files. Add support for J.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 22 Sep 2013 14:42:24 +0200 |
parents | |
children | 657ade71d395 |
comparison
equal
deleted
inserted
replaced
5361:f0a6eb929df1 | 5362:ab1508486b12 |
---|---|
1 " Vim indent file | |
2 " Language: J | |
3 " Maintainer: David Bürgin <676c7473@gmail.com> | |
4 " Last Change: 2013-09-21 | |
5 | |
6 if exists("b:did_indent") | |
7 finish | |
8 endif | |
9 let b:did_indent = 1 | |
10 | |
11 setlocal indentexpr=GetJIndent() | |
12 setlocal indentkeys-=0{,0},\:,0# | |
13 setlocal indentkeys+=0),=case.,=catch.,=catchd.,=catcht.,=do.,=else.,=elseif.,=end.,=fcase. | |
14 | |
15 let b:undo_indent = "setl indk< inde<" | |
16 | |
17 if exists("*GetJIndent") | |
18 finish | |
19 endif | |
20 | |
21 function GetJIndent() | |
22 let prevlnum = prevnonblank(v:lnum-1) | |
23 if prevlnum == 0 | |
24 return 0 | |
25 endif | |
26 | |
27 let indent = indent(prevlnum) | |
28 if getline(prevlnum) =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|fcase\|for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.' | |
29 if getline(prevlnum) !~# '\<end\.' | |
30 let indent += &shiftwidth | |
31 endif | |
32 endif | |
33 if getline(v:lnum) =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|end\|fcase\)\.' | |
34 let indent -= &shiftwidth | |
35 endif | |
36 return indent | |
37 endfunction |