annotate runtime/indent/teraterm.vim @ 6951:b2673982c625

Updated and new runtime files.
author Bram Moolenaar <bram@vim.org>
date Tue, 21 Jul 2015 19:19:13 +0200
parents
children 2b6654519a7c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: Tera Term Language (TTL)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 " Based on Tera Term Version 4.86
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 " Maintainer: Ken Takata
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5 " URL: https://github.com/k-takata/vim-teraterm
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 " Last Change: 2015 Jun 4
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 " Filenames: *.ttl
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 " License: VIM License
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 if exists("b:did_indent")
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 finish
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 let b:did_indent = 1
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 setlocal nosmartindent
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 setlocal noautoindent
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 setlocal indentexpr=GetTeraTermIndent(v:lnum)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 setlocal indentkeys=!^F,o,O,e
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 setlocal indentkeys+==elseif,=endif,=loop,=next,=enduntil,=endwhile
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 if exists("*GetTeraTermIndent")
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 finish
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 " The shiftwidth() function is relatively new.
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 " Don't require it to exist.
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 if exists('*shiftwidth')
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28 function s:sw() abort
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 return shiftwidth()
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 endfunction
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 else
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32 function s:sw() abort
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
33 return &shiftwidth
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 endfunction
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 function! GetTeraTermIndent(lnum)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38 let l:prevlnum = prevnonblank(a:lnum-1)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39 if l:prevlnum == 0
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
40 " top of file
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
41 return 0
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44 " grab the previous and current line, stripping comments.
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 let l:prevl = substitute(getline(l:prevlnum), ';.*$', '', '')
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 let l:thisl = substitute(getline(a:lnum), ';.*$', '', '')
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 let l:previ = indent(l:prevlnum)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 let l:ind = l:previ
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
51 if l:prevl =~ '^\s*if\>.*\<then\s*$'
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 " previous line opened a block
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53 let l:ind += s:sw()
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
54 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
55 if l:prevl =~ '^\s*\%(elseif\|else\|do\|until\|while\|for\)\>'
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
56 " previous line opened a block
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 let l:ind += s:sw()
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
58 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
59 if l:thisl =~ '^\s*\%(elseif\|else\|endif\|enduntil\|endwhile\|loop\|next\)\>'
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
60 " this line closed a block
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
61 let l:ind -= s:sw()
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
62 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
63
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
64 return l:ind
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65 endfunction
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
66
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
67 " vim: ts=8 sw=2 sts=2