Mercurial > vim
annotate runtime/indent/occam.vim @ 34546:33cb93a8d573 v9.1.0174
patch 9.1.0174: 'cursorline' and 'wincolor' hl missing with conceal and wrap
Commit: https://github.com/vim/vim/commit/21b0a3df8c4abb884489dfcc0c92b1bbe058f291
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed Mar 13 20:06:34 2024 +0100
patch 9.1.0174: 'cursorline' and 'wincolor' hl missing with conceal and wrap
Problem: 'cursorline' and 'wincolor' highlight missing with concealed and
wrapped lines.
Solution: Apply 'cursorline' and 'wincolor' highlight to boguscols.
(zeertzjq)
Since 'cursorline' and 'wincolor' highlight apply after the end of the
line, it is more consistent to have them also apply to boguscols.
Assigning MAXCOL to values in ScreenCols[] make mouse click behave the
same with 'cursorline' and 'nocursorline', but such behavior may be
incorrect, as it puts the cursor on the next screen line. That may be
fixed in a future PR.
closes: #14192
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 13 Mar 2024 20:15:03 +0100 |
parents | 6dd88e45d47d |
children |
rev | line source |
---|---|
7 | 1 " Vim indent file |
2 " Language: occam | |
25880 | 3 " Maintainer: Mario Schweigler <ms44@kent.ac.uk> (Invalid email address) |
4 " Doug Kearns <dougkearns@gmail.com> | |
28379 | 5 " Last Change: 2022 Apr 06 |
7 | 6 |
7 " Only load this indent file when no other was loaded. | |
8 if exists("b:did_indent") | |
9 finish | |
10 endif | |
11 let b:did_indent = 1 | |
12 | |
13 "{{{ Settings | |
14 " Set the occam indent function | |
15 setlocal indentexpr=GetOccamIndent() | |
16 " Indent after new line and after initial colon | |
17 setlocal indentkeys=o,O,0=: | |
18 "}}} | |
19 | |
28379 | 20 let b:undo_indent = "setl inde< indk<" |
21 | |
7 | 22 " Only define the function once |
23 if exists("*GetOccamIndent") | |
24 finish | |
25 endif | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
7
diff
changeset
|
26 let s:keepcpo= &cpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
7
diff
changeset
|
27 set cpo&vim |
7 | 28 |
29 "{{{ Indent definitions | |
30 " Define carriage return indent | |
31 let s:FirstLevelIndent = '^\C\s*\(IF\|ALT\|PRI\s\+ALT\|PAR\|SEQ\|PRI\s\+PAR\|WHILE\|VALOF\|CLAIM\|FORKING\)\>\|\(--.*\)\@<!\(\<PROC\>\|??\|\<CASE\>\s*\(--.*\)\=\_$\)' | |
32 let s:FirstLevelNonColonEndIndent = '^\C\s*PROTOCOL\>\|\(--.*\)\@<!\<\(\(CHAN\|DATA\)\s\+TYPE\|FUNCTION\)\>' | |
33 let s:SecondLevelIndent = '^\C\s*\(IF\|ALT\|PRI\s\+ALT\)\>\|\(--.*\)\@<!?\s*\<CASE\>\s*\(--.*\)\=\_$' | |
34 let s:SecondLevelNonColonEndIndent = '\(--.*\)\@<!\<\(CHAN\|DATA\)\s\+TYPE\>' | |
35 | |
36 " Define colon indent | |
37 let s:ColonIndent = '\(--.*\)\@<!\<PROC\>' | |
38 let s:ColonNonColonEndIndent = '^\C\s*PROTOCOL\>\|\(--.*\)\@<!\<\(\(CHAN\|DATA\)\s\+TYPE\|FUNCTION\)\>' | |
39 | |
40 let s:ColonEnd = '\(--.*\)\@<!:\s*\(--.*\)\=$' | |
41 let s:ColonStart = '^\s*:\s*\(--.*\)\=$' | |
42 | |
43 " Define comment | |
44 let s:CommentLine = '^\s*--' | |
45 "}}} | |
46 | |
47 "{{{ function GetOccamIndent() | |
48 " Auxiliary function to get the correct indent for a line of occam code | |
49 function GetOccamIndent() | |
50 | |
51 " Ensure magic is on | |
52 let save_magic = &magic | |
53 setlocal magic | |
54 | |
55 " Get reference line number | |
56 let linenum = prevnonblank(v:lnum - 1) | |
57 while linenum > 0 && getline(linenum) =~ s:CommentLine | |
58 let linenum = prevnonblank(linenum - 1) | |
59 endwhile | |
60 | |
61 " Get current indent | |
62 let curindent = indent(linenum) | |
63 | |
64 " Get current line | |
65 let line = getline(linenum) | |
66 | |
67 " Get previous line number | |
68 let prevlinenum = prevnonblank(linenum - 1) | |
69 while prevlinenum > 0 && getline(prevlinenum) =~ s:CommentLine | |
70 let prevlinenum = prevnonblank(prevlinenum - 1) | |
71 endwhile | |
72 | |
73 " Get previous line | |
74 let prevline = getline(prevlinenum) | |
75 | |
76 " Colon indent | |
77 if getline(v:lnum) =~ s:ColonStart | |
78 | |
79 let found = 0 | |
80 | |
81 while found < 1 | |
82 | |
83 if line =~ s:ColonStart | |
84 let found = found - 1 | |
85 elseif line =~ s:ColonIndent || (line =~ s:ColonNonColonEndIndent && line !~ s:ColonEnd) | |
86 let found = found + 1 | |
87 endif | |
88 | |
89 if found < 1 | |
90 let linenum = prevnonblank(linenum - 1) | |
91 if linenum > 0 | |
92 let line = getline(linenum) | |
93 else | |
94 let found = 1 | |
95 endif | |
96 endif | |
97 | |
98 endwhile | |
99 | |
100 if linenum > 0 | |
101 let curindent = indent(linenum) | |
102 else | |
103 let colonline = getline(v:lnum) | |
104 let tabstr = '' | |
105 while strlen(tabstr) < &tabstop | |
106 let tabstr = ' ' . tabstr | |
107 endwhile | |
108 let colonline = substitute(colonline, '\t', tabstr, 'g') | |
109 let curindent = match(colonline, ':') | |
110 endif | |
111 | |
112 " Restore magic | |
113 if !save_magic|setlocal nomagic|endif | |
114 | |
115 return curindent | |
116 endif | |
117 | |
118 if getline(v:lnum) =~ '^\s*:' | |
119 let colonline = getline(v:lnum) | |
120 let tabstr = '' | |
121 while strlen(tabstr) < &tabstop | |
122 let tabstr = ' ' . tabstr | |
123 endwhile | |
124 let colonline = substitute(colonline, '\t', tabstr, 'g') | |
125 let curindent = match(colonline, ':') | |
126 | |
127 " Restore magic | |
128 if !save_magic|setlocal nomagic|endif | |
129 | |
130 return curindent | |
131 endif | |
132 | |
133 " Carriage return indenat | |
134 if line =~ s:FirstLevelIndent || (line =~ s:FirstLevelNonColonEndIndent && line !~ s:ColonEnd) | |
135 \ || (line !~ s:ColonStart && (prevline =~ s:SecondLevelIndent | |
136 \ || (prevline =~ s:SecondLevelNonColonEndIndent && prevline !~ s:ColonEnd))) | |
11518 | 137 let curindent = curindent + shiftwidth() |
7 | 138 |
139 " Restore magic | |
140 if !save_magic|setlocal nomagic|endif | |
141 | |
142 return curindent | |
143 endif | |
144 | |
145 " Commented line | |
146 if getline(prevnonblank(v:lnum - 1)) =~ s:CommentLine | |
147 | |
148 " Restore magic | |
149 if !save_magic|setlocal nomagic|endif | |
150 | |
151 return indent(prevnonblank(v:lnum - 1)) | |
152 endif | |
153 | |
154 " Look for previous second level IF / ALT / PRI ALT | |
155 let found = 0 | |
156 | |
157 while !found | |
158 | |
11518 | 159 if indent(prevlinenum) == curindent - shiftwidth() |
7 | 160 let found = 1 |
161 endif | |
162 | |
163 if !found | |
164 let prevlinenum = prevnonblank(prevlinenum - 1) | |
165 while prevlinenum > 0 && getline(prevlinenum) =~ s:CommentLine | |
166 let prevlinenum = prevnonblank(prevlinenum - 1) | |
167 endwhile | |
168 if prevlinenum == 0 | |
169 let found = 1 | |
170 endif | |
171 endif | |
172 | |
173 endwhile | |
174 | |
175 if prevlinenum > 0 | |
176 if getline(prevlinenum) =~ s:SecondLevelIndent | |
11518 | 177 let curindent = curindent + shiftwidth() |
7 | 178 endif |
179 endif | |
180 | |
181 " Restore magic | |
182 if !save_magic|setlocal nomagic|endif | |
183 | |
184 return curindent | |
185 | |
186 endfunction | |
187 "}}} | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
7
diff
changeset
|
188 |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
7
diff
changeset
|
189 let &cpo = s:keepcpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
7
diff
changeset
|
190 unlet s:keepcpo |