annotate runtime/indent/hog.vim @ 17296:49ef396af986 v8.1.1647

patch 8.1.1647: build error with GTK and hangulinput feature commit https://github.com/vim/vim/commit/d84b2c3d88b08722dd4f686256a22c26788ea122 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 7 19:16:58 2019 +0200 patch 8.1.1647: build error with GTK and hangulinput feature Problem: Build error with GTK and hangulinput feature, im_get_status() defined twice. (Dominique Pelle) Solution: Adjust im_get_status(). (closes #4628)
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Jul 2019 19:30:05 +0200
parents 63b0b7b79b25
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7188
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Vim indent file
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Language: hog (Snort.conf)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Maintainer: Victor Roemer, <vroemer@badsec.org>
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " Last Change: Mar 7, 2013
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " Only load this indent file when no other was loaded.
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 if exists("b:did_indent")
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 finish
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let b:did_indent = 1
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 let b:undo_indent = 'setlocal smartindent< indentexpr< indentkeys<'
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 setlocal nosmartindent
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 setlocal indentexpr=GetHogIndent()
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 setlocal indentkeys+=!^F,o,O,0#
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 " Only define the function once.
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 if exists("*GetHogIndent")
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 finish
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 let s:cpo_save = &cpo
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 set cpo&vim
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 let s:syn_blocks = '\<SnortRuleTypeBody\>'
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 function s:IsInBlock(lnum)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 return synIDattr(synID(a:lnum, 1, 1), 'name') =~ s:syn_blocks
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endfunction
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 function GetHogIndent()
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 let prevlnum = prevnonblank(v:lnum-1)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 " Comment blocks have identical indent
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 if getline(v:lnum) =~ '^\s*#' && getline(prevlnum) =~ '^\s*#'
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 return indent(prevlnum)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 " Ignore comment lines when calculating indent
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 while getline(prevlnum) =~ '^\s*#'
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 let prevlnum = prevnonblank(prevlnum-1)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 if !prevlnum
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 return previndent
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 endwhile
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 " Continuation of a line that wasn't indented
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 let prevline = getline(prevlnum)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 if prevline =~ '^\k\+.*\\\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7188
diff changeset
50 return shiftwidth()
7188
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " Continuation of a line that was indented
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 if prevline =~ '\k\+.*\\\s*$'
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 return indent(prevlnum)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 " Indent the next line if previous line contained a start of a block
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 " definition ('{' or '(').
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 if prevline =~ '^\k\+[^#]*{}\@!\s*$' " TODO || prevline =~ '^\k\+[^#]*()\@!\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7188
diff changeset
61 return shiftwidth()
7188
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 " Match inside of a block
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 if s:IsInBlock(v:lnum)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 if prevline =~ "^\k\+.*$"
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7188
diff changeset
67 return shiftwidth()
7188
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 else
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 return indent(prevlnum)
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 endif
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 return 0
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 endfunction
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 let &cpo = s:cpo_save
3ba0f29ba1d1 commit https://github.com/vim/vim/commit/d7464be9747fcaa8e6210e1f00a3882932df76e2
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 unlet s:cpo_save