annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5362
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: J
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 " Maintainer: David Bürgin <676c7473@gmail.com>
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 " Last Change: 2013-09-21
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 if exists("b:did_indent")
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 finish
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 endif
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 let b:did_indent = 1
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 setlocal indentexpr=GetJIndent()
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 setlocal indentkeys-=0{,0},\:,0#
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 setlocal indentkeys+=0),=case.,=catch.,=catchd.,=catcht.,=do.,=else.,=elseif.,=end.,=fcase.
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 let b:undo_indent = "setl indk< inde<"
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 if exists("*GetJIndent")
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 finish
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 endif
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 function GetJIndent()
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 let prevlnum = prevnonblank(v:lnum-1)
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 if prevlnum == 0
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 return 0
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 endif
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 let indent = indent(prevlnum)
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28 if getline(prevlnum) =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|fcase\|for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.'
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 if getline(prevlnum) !~# '\<end\.'
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 let indent += &shiftwidth
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 endif
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32 endif
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
33 if getline(v:lnum) =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|end\|fcase\)\.'
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 let indent -= &shiftwidth
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 endif
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 return indent
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 endfunction