annotate runtime/indent/sas.vim @ 32443:fbcf40a2bf58 v9.0.1553

patch 9.0.1553: CI: using slightly outdated gcc version Commit: https://github.com/vim/vim/commit/b6a19594b29a7d4f33a1f4324a0579df61f48d06 Author: Philip H <47042125+pheiduck@users.noreply.github.com> Date: Sat May 13 18:05:20 2023 +0100 patch 9.0.1553: CI: using slightly outdated gcc version Problem: CI: using slightly outdated gcc version. Solution: Use "brew" to get a more recent gcc version. (closes https://github.com/vim/vim/issues/12391)
author Bram Moolenaar <Bram@vim.org>
date Sat, 13 May 2023 19:15:03 +0200
parents 6dd88e45d47d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Vim indent file
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Language: SAS
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Maintainer: Zhen-Huan Hu <wildkeny@gmail.com>
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
4 " Version: 3.0.3
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14249
diff changeset
5 " Last Change: 2022 Apr 06
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 if exists("b:did_indent")
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 finish
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let b:did_indent = 1
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 setlocal indentexpr=GetSASIndent()
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 setlocal indentkeys+=;,=~data,=~proc,=~macro
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14249
diff changeset
15 let b:undo_indent = "setl inde< indk<"
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14249
diff changeset
16
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 if exists("*GetSASIndent")
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 finish
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 let s:cpo_save = &cpo
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 set cpo&vim
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 " Regex that captures the start of a data/proc section
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 let s:section_str = '\v%(^|;)\s*%(data|proc)>'
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 " Regex that captures the end of a run-processing section
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 let s:section_run = '\v%(^|;)\s*run\s*;'
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 " Regex that captures the end of a data/proc section
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 let s:section_end = '\v%(^|;)\s*%(quit|enddata)\s*;'
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 " Regex that captures the start of a control block (anything inside a section)
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
32 let s:block_str = '\v<%(do>%([^;]+<%(to|over|while)>[^;]+)=|%(compute|define\s+%(column|footer|header|style|table|tagset|crosstabs|statgraph)|edit|layout|method|select)>[^;]+|begingraph)\s*;'
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 " Regex that captures the end of a control block (anything inside a section)
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
34 let s:block_end = '\v<%(end|endcomp|endlayout|endgraph)\s*;'
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " Regex that captures the start of a macro
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 let s:macro_str = '\v%(^|;)\s*\%macro>'
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 " Regex that captures the end of a macro
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 let s:macro_end = '\v%(^|;)\s*\%mend\s*;'
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 " Regex that defines the end of the program
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 let s:program_end = '\v%(^|;)\s*endsas\s*;'
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 " List of procs supporting run-processing
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 let s:run_processing_procs = [
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 \ 'catalog', 'chart', 'datasets', 'document', 'ds2', 'plot', 'sql',
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 \ 'gareabar', 'gbarline', 'gchart', 'gkpi', 'gmap', 'gplot', 'gradar', 'greplay', 'gslide', 'gtile',
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 \ 'anova', 'arima', 'catmod', 'factex', 'glm', 'model', 'optex', 'plan', 'reg',
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 \ 'iml',
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 \ ]
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 " Find the line number of previous keyword defined by the regex
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 function! s:PrevMatch(lnum, regex)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 let prev_lnum = prevnonblank(a:lnum - 1)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 while prev_lnum > 0
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 let prev_line = getline(prev_lnum)
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
57 if prev_line =~? a:regex
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 break
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 else
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 let prev_lnum = prevnonblank(prev_lnum - 1)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 endwhile
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 return prev_lnum
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 endfunction
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 " Main function
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 function! GetSASIndent()
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 let prev_lnum = prevnonblank(v:lnum - 1)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 if prev_lnum ==# 0
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 " Leave the indentation of the first line unchanged
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 return indent(1)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 else
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 let prev_line = getline(prev_lnum)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 " Previous non-blank line contains the start of a macro/section/block
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 " while not the end of a macro/section/block (at the same line)
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
76 if (prev_line =~? s:section_str && prev_line !~? s:section_run && prev_line !~? s:section_end) ||
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
77 \ (prev_line =~? s:block_str && prev_line !~? s:block_end) ||
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
78 \ (prev_line =~? s:macro_str && prev_line !~? s:macro_end)
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
79 let ind = indent(prev_lnum) + shiftwidth()
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
80 elseif prev_line =~? s:section_run && prev_line !~? s:section_end
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 let prev_section_str_lnum = s:PrevMatch(v:lnum, s:section_str)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 let prev_section_end_lnum = max([
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 \ s:PrevMatch(v:lnum, s:section_end),
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 \ s:PrevMatch(v:lnum, s:macro_end ),
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 \ s:PrevMatch(v:lnum, s:program_end)])
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 " Check if the section supports run-processing
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 if prev_section_end_lnum < prev_section_str_lnum &&
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
88 \ getline(prev_section_str_lnum) =~? '\v%(^|;)\s*proc\s+%(' .
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 \ join(s:run_processing_procs, '|') . ')>'
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
90 let ind = indent(prev_lnum) + shiftwidth()
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 else
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 let ind = indent(prev_lnum)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 else
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 let ind = indent(prev_lnum)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 " Re-adjustments based on the inputs of the current line
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 let curr_line = getline(v:lnum)
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
100 if curr_line =~? s:program_end
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 " End of the program
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 " Same indentation as the first non-blank line
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 return indent(nextnonblank(1))
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
104 elseif curr_line =~? s:macro_end
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 " Current line is the end of a macro
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 " Match the indentation of the start of the macro
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 return indent(s:PrevMatch(v:lnum, s:macro_str))
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
108 elseif curr_line =~? s:block_end && curr_line !~? s:block_str
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 " Re-adjust if current line is the end of a block
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 " while not the beginning of a block (at the same line)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 " Returning the indent of previous block start directly
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 " would not work due to nesting
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
113 let ind = ind - shiftwidth()
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
114 elseif curr_line =~? s:section_str || curr_line =~? s:section_run || curr_line =~? s:section_end
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 " Re-adjust if current line is the start/end of a section
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 " since the end of a section could be inexplicit
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 let prev_section_str_lnum = s:PrevMatch(v:lnum, s:section_str)
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 " Check if the previous section supports run-processing
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
119 if getline(prev_section_str_lnum) =~? '\v%(^|;)\s*proc\s+%(' .
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 \ join(s:run_processing_procs, '|') . ')>'
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 let prev_section_end_lnum = max([
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 \ s:PrevMatch(v:lnum, s:section_end),
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 \ s:PrevMatch(v:lnum, s:macro_end ),
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 \ s:PrevMatch(v:lnum, s:program_end)])
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 else
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 let prev_section_end_lnum = max([
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 \ s:PrevMatch(v:lnum, s:section_end),
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 \ s:PrevMatch(v:lnum, s:section_run),
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 \ s:PrevMatch(v:lnum, s:macro_end ),
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 \ s:PrevMatch(v:lnum, s:program_end)])
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 if prev_section_end_lnum < prev_section_str_lnum
14249
4543777545a3 Updated runtime and language files.
Christian Brabandt <cb@256bit.org>
parents: 11160
diff changeset
133 let ind = ind - shiftwidth()
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 endif
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 return ind
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 endfunction
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 let &cpo = s:cpo_save
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 unlet s:cpo_save