Mercurial > vim
annotate runtime/indent/j.vim @ 5815:d735e62f5925
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 06 Apr 2014 14:09:13 +0200 |
parents | 657ade71d395 |
children | 198e1e498edf |
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> |
5734 | 4 " URL: https://github.com/glts/vim-j |
5815 | 5 " Last Change: 2014-04-05 |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
6 |
5734 | 7 if exists('b:did_indent') |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
8 finish |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
9 endif |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
10 let b:did_indent = 1 |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
11 |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
12 setlocal indentexpr=GetJIndent() |
5815 | 13 setlocal indentkeys-=0{,0},:,0# |
14 setlocal indentkeys+=0),0<:>,=case.,=catch.,=catchd.,=catcht.,=do.,=else.,=elseif.,=end.,=fcase. | |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
15 |
5734 | 16 let b:undo_indent = 'setlocal indentkeys< indentexpr<' |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
17 |
5734 | 18 if exists('*GetJIndent') |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
19 finish |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
20 endif |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
21 |
5815 | 22 " If g:j_indent_definitions is true, the bodies of explicit definitions of |
23 " adverbs, conjunctions, and verbs will be indented. Default is false (0). | |
24 if !exists('g:j_indent_definitions') | |
25 let g:j_indent_definitions = 0 | |
26 endif | |
27 | |
28 function GetJIndent() abort | |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
29 let prevlnum = prevnonblank(v:lnum-1) |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
30 if prevlnum == 0 |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
31 return 0 |
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 let indent = indent(prevlnum) |
5815 | 34 let prevline = getline(prevlnum) |
35 if prevline =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|fcase\|for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.\%(\%(\<end\.\)\@!.\)*$' | |
36 " Increase indentation after an initial control word that starts or | |
37 " continues a block and is not terminated by "end." | |
38 let indent += shiftwidth() | |
39 elseif g:j_indent_definitions && (prevline =~# '\<\%([1-4]\|13\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>' || prevline =~# '^\s*:\s*$') | |
40 " Increase indentation in explicit definitions of adverbs, conjunctions, | |
41 " and verbs | |
42 let indent += shiftwidth() | |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
43 endif |
5815 | 44 " Decrease indentation in lines that start with either control words that |
45 " continue or end a block, or the special items ")" and ":" | |
46 if getline(v:lnum) =~# '^\s*\%()\|:\|\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|end\|fcase\)\.\)' | |
5734 | 47 let indent -= shiftwidth() |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
48 endif |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
49 return indent |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
50 endfunction |