annotate runtime/indent/j.vim @ 10928:5b3e671ef6a2 v8.0.0353

patch 8.0.0353: if [RO] is translated it may be truncated commit https://github.com/vim/vim/commit/3457d295f4035293a78f9a9851ea416f923dd59e Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 23 14:55:59 2017 +0100 patch 8.0.0353: if [RO] is translated it may be truncated Problem: If [RO] in the status line is translated to a longer string, it is trunctted to 4 bytes. Solution: Skip over the resulting string. (Jente Hidskes, closes #1499)
author Christian Brabandt <cb@256bit.org>
date Thu, 23 Feb 2017 15:00:05 +0100
parents 198e1e498edf
children cb3163d590a1
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>
5734
657ade71d395 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5362
diff changeset
4 " URL: https://github.com/glts/vim-j
6505
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
5 " Last Change: 2015-01-11
5362
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6
5734
657ade71d395 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5362
diff changeset
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
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
13 setlocal indentkeys-=0{,0},:,0#
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
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
657ade71d395 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5362
diff changeset
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
657ade71d395 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5362
diff changeset
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
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
22 " If g:j_indent_definitions is true, the bodies of explicit definitions of
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
23 " adverbs, conjunctions, and verbs will be indented. Default is false (0).
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
24 if !exists('g:j_indent_definitions')
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
25 let g:j_indent_definitions = 0
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
26 endif
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
27
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
28 function GetJIndent() abort
6505
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
29 let l:prevlnum = prevnonblank(v:lnum - 1)
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
30 if l:prevlnum == 0
5362
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
6505
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
33 let l:indent = indent(l:prevlnum)
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
34 let l:prevline = getline(l:prevlnum)
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
35 if l:prevline =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|fcase\|for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.\%(\%(\<end\.\)\@!.\)*$'
5815
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
36 " Increase indentation after an initial control word that starts or
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
37 " continues a block and is not terminated by "end."
6505
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
38 let l:indent += shiftwidth()
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
39 elseif g:j_indent_definitions && (l:prevline =~# '\<\%([1-4]\|13\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>' || l:prevline =~# '^\s*:\s*$')
5815
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
40 " Increase indentation in explicit definitions of adverbs, conjunctions,
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
41 " and verbs
6505
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
42 let l:indent += shiftwidth()
5362
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43 endif
5815
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
44 " Decrease indentation in lines that start with either control words that
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
45 " continue or end a block, or the special items ")" and ":"
d735e62f5925 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5734
diff changeset
46 if getline(v:lnum) =~# '^\s*\%()\|:\|\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|end\|fcase\)\.\)'
6505
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
47 let l:indent -= shiftwidth()
5362
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 endif
6505
198e1e498edf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5815
diff changeset
49 return l:indent
5362
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 endfunction