annotate runtime/indent/dosbatch.vim @ 31275:0851a1a22a38 v9.0.0971

patch 9.0.0971: escape sequences not recognized without termresponse feature Commit: https://github.com/vim/vim/commit/6f2a22756536849f9e45caa4ddd62cab4334f065 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 29 13:59:13 2022 +0000 patch 9.0.0971: escape sequences not recognized without termresponse feature Problem: Escape sequences not recognized without the termresponse feature. Solution: Recognize escape sequences to avoid display mess up.
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Nov 2022 15:00:06 +0100
parents ebedba7a4898
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Vim indent file
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Language: MSDOS batch file (with NT command extensions)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Maintainer: Ken Takata
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " URL: https://github.com/k-takata/vim-dosbatch-indent
26050
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
5 " Last Change: 2021-10-18
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " Filenames: *.bat
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " License: VIM License
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 if exists("b:did_indent")
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 finish
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 endif
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 let b:did_indent = 1
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 setlocal nosmartindent
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 setlocal noautoindent
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 setlocal indentexpr=GetDosBatchIndent(v:lnum)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 setlocal indentkeys=!^F,o,O
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 setlocal indentkeys+=0=)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
26050
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
20 let b:undo_indent = "setl ai< inde< indk< si<"
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
21
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 if exists("*GetDosBatchIndent")
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 finish
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endif
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 let s:cpo_save = &cpo
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 set cpo&vim
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 function! GetDosBatchIndent(lnum)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 let l:prevlnum = prevnonblank(a:lnum-1)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 if l:prevlnum == 0
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 " top of file
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 return 0
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 endif
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " grab the previous and current line, stripping comments.
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 let l:prevl = substitute(getline(l:prevlnum), '\c^\s*\%(@\s*\)\?rem\>.*$', '', '')
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 let l:thisl = getline(a:lnum)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 let l:previ = indent(l:prevlnum)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 let l:ind = l:previ
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 if l:prevl =~? '^\s*@\=if\>.*(\s*$' ||
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 \ l:prevl =~? '\<do\>\s*(\s*$' ||
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 \ l:prevl =~? '\<else\>\s*\%(if\>.*\)\?(\s*$' ||
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 \ l:prevl =~? '^.*\(&&\|||\)\s*(\s*$'
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 " previous line opened a block
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 let l:ind += shiftwidth()
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 endif
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 if l:thisl =~ '^\s*)'
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 " this line closed a block
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 let l:ind -= shiftwidth()
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 endif
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 return l:ind
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endfunction
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 let &cpo = s:cpo_save
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 unlet s:cpo_save
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 " vim: ts=8 sw=2 sts=2