Mercurial > vim
annotate runtime/indent/teraterm.vim @ 10930:126405b39964 v8.0.0354
patch 8.0.0354: test to check that setting termcap key fails sometimes
commit https://github.com/vim/vim/commit/1c410400fad79068b16dc4c6c7a023463a0858cf
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 23 15:20:03 2017 +0100
patch 8.0.0354: test to check that setting termcap key fails sometimes
Problem: Test to check that setting termcap key fails sometimes.
Solution: Check for "t_k1" to exist. (Christian Brabandt, closes https://github.com/vim/vim/issues/1459)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 23 Feb 2017 15:30:05 +0100 |
parents | 2b6654519a7c |
children | 63b0b7b79b25 |
rev | line source |
---|---|
6951 | 1 " Vim indent file |
2 " Language: Tera Term Language (TTL) | |
9908
2b6654519a7c
commit https://github.com/vim/vim/commit/7571d55f7dcc009a375b2124cce2c8b21f361234
Christian Brabandt <cb@256bit.org>
parents:
6951
diff
changeset
|
3 " Based on Tera Term Version 4.92 |
6951 | 4 " Maintainer: Ken Takata |
5 " URL: https://github.com/k-takata/vim-teraterm | |
9908
2b6654519a7c
commit https://github.com/vim/vim/commit/7571d55f7dcc009a375b2124cce2c8b21f361234
Christian Brabandt <cb@256bit.org>
parents:
6951
diff
changeset
|
6 " Last Change: 2016 Aug 17 |
6951 | 7 " Filenames: *.ttl |
8 " License: VIM License | |
9 | |
10 if exists("b:did_indent") | |
11 finish | |
12 endif | |
13 let b:did_indent = 1 | |
14 | |
15 setlocal nosmartindent | |
16 setlocal noautoindent | |
17 setlocal indentexpr=GetTeraTermIndent(v:lnum) | |
18 setlocal indentkeys=!^F,o,O,e | |
19 setlocal indentkeys+==elseif,=endif,=loop,=next,=enduntil,=endwhile | |
20 | |
21 if exists("*GetTeraTermIndent") | |
22 finish | |
23 endif | |
24 | |
25 " The shiftwidth() function is relatively new. | |
26 " Don't require it to exist. | |
27 if exists('*shiftwidth') | |
9908
2b6654519a7c
commit https://github.com/vim/vim/commit/7571d55f7dcc009a375b2124cce2c8b21f361234
Christian Brabandt <cb@256bit.org>
parents:
6951
diff
changeset
|
28 let s:sw = function('shiftwidth') |
6951 | 29 else |
30 function s:sw() abort | |
31 return &shiftwidth | |
32 endfunction | |
33 endif | |
34 | |
35 function! GetTeraTermIndent(lnum) | |
36 let l:prevlnum = prevnonblank(a:lnum-1) | |
37 if l:prevlnum == 0 | |
38 " top of file | |
39 return 0 | |
40 endif | |
41 | |
42 " grab the previous and current line, stripping comments. | |
43 let l:prevl = substitute(getline(l:prevlnum), ';.*$', '', '') | |
44 let l:thisl = substitute(getline(a:lnum), ';.*$', '', '') | |
45 let l:previ = indent(l:prevlnum) | |
46 | |
47 let l:ind = l:previ | |
48 | |
9908
2b6654519a7c
commit https://github.com/vim/vim/commit/7571d55f7dcc009a375b2124cce2c8b21f361234
Christian Brabandt <cb@256bit.org>
parents:
6951
diff
changeset
|
49 if l:prevl =~ '^\s*if\>.*\<then\>' |
6951 | 50 " previous line opened a block |
51 let l:ind += s:sw() | |
52 endif | |
53 if l:prevl =~ '^\s*\%(elseif\|else\|do\|until\|while\|for\)\>' | |
54 " previous line opened a block | |
55 let l:ind += s:sw() | |
56 endif | |
57 if l:thisl =~ '^\s*\%(elseif\|else\|endif\|enduntil\|endwhile\|loop\|next\)\>' | |
58 " this line closed a block | |
59 let l:ind -= s:sw() | |
60 endif | |
61 | |
62 return l:ind | |
63 endfunction | |
64 | |
65 " vim: ts=8 sw=2 sts=2 |