Mercurial > vim
annotate runtime/autoload/syntaxcomplete.vim @ 3848:a2fe24ec6a0d v7.3.681
updated for version 7.3.681
Problem: List of distributed files picks up backup files.
Solution: Make tutor patterns more specific.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 03 Oct 2012 21:48:43 +0200 |
parents | 8b8ef1fed009 |
children | c53344bacabf |
rev | line source |
---|---|
625 | 1 " Vim completion script |
2 " Language: All languages, uses existing syntax highlighting rules | |
2072 | 3 " Maintainer: David Fishburn <dfishburn dot vim at gmail dot com> |
3224 | 4 " Version: 8.0 |
5 " Last Change: 2011 Nov 02 | |
871 | 6 " Usage: For detailed help, ":help ft-syntax-omni" |
625 | 7 |
2072 | 8 " History |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
9 " |
3224 | 10 " Version 8.0 |
11 " Updated SyntaxCSyntaxGroupItems() | |
12 " - Some additional syntax items were also allowed | |
13 " on nextgroup= lines which were ignored by default. | |
14 " Now these lines are processed independently. | |
15 " | |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
16 " Version 7.0 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
17 " Updated syntaxcomplete#OmniSyntaxList() |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
18 " - Looking up the syntax groups defined from a syntax file |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
19 " looked for only 1 format of {filetype}GroupName, but some |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
20 " syntax writers use this format as well: |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
21 " {b:current_syntax}GroupName |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
22 " OmniSyntaxList() will now check for both if the first |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
23 " method does not find a match. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
24 " |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
25 " Version 6.0 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
26 " Added syntaxcomplete#OmniSyntaxList() |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
27 " - Allows other plugins to use this for their own |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
28 " purposes. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
29 " - It will return a List of all syntax items for the |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
30 " syntax group name passed in. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
31 " - XPTemplate for SQL will use this function via the |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
32 " sqlcomplete plugin to populate a Choose box. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
33 " |
2072 | 34 " Version 5.0 |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
35 " Updated SyntaxCSyntaxGroupItems() |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
36 " - When processing a list of syntax groups, the final group |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
37 " was missed in function SyntaxCSyntaxGroupItems. |
2072 | 38 " |
625 | 39 " Set completion with CTRL-X CTRL-O to autoloaded function. |
785 | 40 " This check is in place in case this script is |
41 " sourced directly instead of using the autoload feature. | |
702 | 42 if exists('+omnifunc') |
785 | 43 " Do not set the option if already set since this |
44 " results in an E117 warning. | |
45 if &omnifunc == "" | |
46 setlocal omnifunc=syntaxcomplete#Complete | |
47 endif | |
625 | 48 endif |
49 | |
50 if exists('g:loaded_syntax_completion') | |
51 finish | |
52 endif | |
3224 | 53 let g:loaded_syntax_completion = 80 |
871 | 54 |
55 " Set ignorecase to the ftplugin standard | |
1121 | 56 " This is the default setting, but if you define a buffer local |
57 " variable you can override this on a per filetype. | |
871 | 58 if !exists('g:omni_syntax_ignorecase') |
59 let g:omni_syntax_ignorecase = &ignorecase | |
60 endif | |
625 | 61 |
1121 | 62 " Indicates whether we should use the iskeyword option to determine |
63 " how to split words. | |
64 " This is the default setting, but if you define a buffer local | |
65 " variable you can override this on a per filetype. | |
66 if !exists('g:omni_syntax_use_iskeyword') | |
67 let g:omni_syntax_use_iskeyword = 1 | |
68 endif | |
69 | |
70 " Only display items in the completion window that are at least | |
71 " this many characters in length. | |
72 " This is the default setting, but if you define a buffer local | |
73 " variable you can override this on a per filetype. | |
74 if !exists('g:omni_syntax_minimum_length') | |
75 let g:omni_syntax_minimum_length = 0 | |
76 endif | |
77 | |
625 | 78 " This script will build a completion list based on the syntax |
79 " elements defined by the files in $VIMRUNTIME/syntax. | |
80 let s:syn_remove_words = 'match,matchgroup=,contains,'. | |
3224 | 81 \ 'links to,start=,end=' |
82 " \ 'links to,start=,end=,nextgroup=' | |
625 | 83 |
84 let s:cache_name = [] | |
85 let s:cache_list = [] | |
785 | 86 let s:prepended = '' |
625 | 87 |
88 " This function is used for the 'omnifunc' option. | |
89 function! syntaxcomplete#Complete(findstart, base) | |
90 | |
1121 | 91 " Only display items in the completion window that are at least |
92 " this many characters in length | |
93 if !exists('b:omni_syntax_ignorecase') | |
94 if exists('g:omni_syntax_ignorecase') | |
95 let b:omni_syntax_ignorecase = g:omni_syntax_ignorecase | |
96 else | |
97 let b:omni_syntax_ignorecase = &ignorecase | |
98 endif | |
99 endif | |
100 | |
625 | 101 if a:findstart |
102 " Locate the start of the item, including "." | |
103 let line = getline('.') | |
104 let start = col('.') - 1 | |
105 let lastword = -1 | |
106 while start > 0 | |
1121 | 107 " if line[start - 1] =~ '\S' |
108 " let start -= 1 | |
109 " elseif line[start - 1] =~ '\.' | |
110 if line[start - 1] =~ '\k' | |
625 | 111 let start -= 1 |
1121 | 112 let lastword = a:findstart |
625 | 113 else |
114 break | |
115 endif | |
116 endwhile | |
117 | |
118 " Return the column of the last word, which is going to be changed. | |
119 " Remember the text that comes before it in s:prepended. | |
120 if lastword == -1 | |
121 let s:prepended = '' | |
122 return start | |
123 endif | |
1121 | 124 let s:prepended = strpart(line, start, (col('.') - 1) - start) |
125 return start | |
625 | 126 endif |
127 | |
1121 | 128 " let base = s:prepended . a:base |
129 let base = s:prepended | |
625 | 130 |
871 | 131 let filetype = substitute(&filetype, '\.', '_', 'g') |
132 let list_idx = index(s:cache_name, filetype, 0, &ignorecase) | |
625 | 133 if list_idx > -1 |
134 let compl_list = s:cache_list[list_idx] | |
135 else | |
871 | 136 let compl_list = OmniSyntaxList() |
137 let s:cache_name = add( s:cache_name, filetype ) | |
138 let s:cache_list = add( s:cache_list, compl_list ) | |
625 | 139 endif |
140 | |
141 " Return list of matches. | |
142 | |
1121 | 143 if base != '' |
144 " let compstr = join(compl_list, ' ') | |
145 " let expr = (b:omni_syntax_ignorecase==0?'\C':'').'\<\%('.base.'\)\@!\w\+\s*' | |
146 " let compstr = substitute(compstr, expr, '', 'g') | |
147 " let compl_list = split(compstr, '\s\+') | |
148 | |
149 " Filter the list based on the first few characters the user | |
150 " entered | |
151 let expr = 'v:val '.(g:omni_syntax_ignorecase==1?'=~?':'=~#')." '^".escape(base, '\\/.*$^~[]').".*'" | |
152 let compl_list = filter(deepcopy(compl_list), expr) | |
625 | 153 endif |
154 | |
155 return compl_list | |
156 endfunc | |
157 | |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
158 function! syntaxcomplete#OmniSyntaxList(...) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
159 if a:0 > 0 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
160 let parms = [] |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
161 if 3 == type(a:1) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
162 let parms = a:1 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
163 elseif 1 == type(a:1) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
164 let parms = split(a:1, ',') |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
165 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
166 return OmniSyntaxList( parms ) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
167 else |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
168 return OmniSyntaxList() |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
169 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
170 endfunc |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
171 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
172 function! OmniSyntaxList(...) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
173 let list_parms = [] |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
174 if a:0 > 0 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
175 if 3 == type(a:1) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
176 let list_parms = a:1 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
177 elseif 1 == type(a:1) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
178 let list_parms = split(a:1, ',') |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
179 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
180 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
181 |
871 | 182 " Default to returning a dictionary, if use_dictionary is set to 0 |
183 " a list will be returned. | |
184 " let use_dictionary = 1 | |
185 " if a:0 > 0 && a:1 != '' | |
186 " let use_dictionary = a:1 | |
187 " endif | |
188 | |
1121 | 189 " Only display items in the completion window that are at least |
190 " this many characters in length | |
191 if !exists('b:omni_syntax_use_iskeyword') | |
192 if exists('g:omni_syntax_use_iskeyword') | |
193 let b:omni_syntax_use_iskeyword = g:omni_syntax_use_iskeyword | |
194 else | |
195 let b:omni_syntax_use_iskeyword = 1 | |
196 endif | |
197 endif | |
198 | |
199 " Only display items in the completion window that are at least | |
200 " this many characters in length | |
201 if !exists('b:omni_syntax_minimum_length') | |
202 if exists('g:omni_syntax_minimum_length') | |
203 let b:omni_syntax_minimum_length = g:omni_syntax_minimum_length | |
204 else | |
205 let b:omni_syntax_minimum_length = 0 | |
206 endif | |
207 endif | |
208 | |
625 | 209 let saveL = @l |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
210 let filetype = substitute(&filetype, '\.', '_', 'g') |
625 | 211 |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
212 if empty(list_parms) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
213 " Default the include group to include the requested syntax group |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
214 let syntax_group_include_{filetype} = '' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
215 " Check if there are any overrides specified for this filetype |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
216 if exists('g:omni_syntax_group_include_'.filetype) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
217 let syntax_group_include_{filetype} = |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
218 \ substitute( g:omni_syntax_group_include_{filetype},'\s\+','','g') |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
219 let list_parms = split(g:omni_syntax_group_include_{filetype}, ',') |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
220 if syntax_group_include_{filetype} =~ '\w' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
221 let syntax_group_include_{filetype} = |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
222 \ substitute( syntax_group_include_{filetype}, |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
223 \ '\s*,\s*', '\\|', 'g' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
224 \ ) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
225 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
226 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
227 else |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
228 " A specific list was provided, use it |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
229 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
230 |
625 | 231 " Loop through all the syntax groupnames, and build a |
232 " syntax file which contains these names. This can | |
233 " work generically for any filetype that does not already | |
234 " have a plugin defined. | |
235 " This ASSUMES the syntax groupname BEGINS with the name | |
702 | 236 " of the filetype. From my casual viewing of the vim7\syntax |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
237 " directory this is true for almost all syntax definitions. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
238 " As an example, the SQL syntax groups have this pattern: |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
239 " sqlType |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
240 " sqlOperators |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
241 " sqlKeyword ... |
625 | 242 redir @l |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
243 silent! exec 'syntax list '.join(list_parms) |
625 | 244 redir END |
245 | |
702 | 246 let syntax_full = "\n".@l |
625 | 247 let @l = saveL |
248 | |
702 | 249 if syntax_full =~ 'E28' |
250 \ || syntax_full =~ 'E411' | |
251 \ || syntax_full =~ 'E415' | |
252 \ || syntax_full =~ 'No Syntax items' | |
253 return [] | |
254 endif | |
255 | |
871 | 256 let filetype = substitute(&filetype, '\.', '_', 'g') |
257 | |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
258 let list_exclude_groups = [] |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
259 if a:0 > 0 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
260 " Do nothing since we have specific a specific list of groups |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
261 else |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
262 " Default the exclude group to nothing |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
263 let syntax_group_exclude_{filetype} = '' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
264 " Check if there are any overrides specified for this filetype |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
265 if exists('g:omni_syntax_group_exclude_'.filetype) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
266 let syntax_group_exclude_{filetype} = |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
267 \ substitute( g:omni_syntax_group_exclude_{filetype},'\s\+','','g') |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
268 let list_exclude_groups = split(g:omni_syntax_group_exclude_{filetype}, ',') |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
269 if syntax_group_exclude_{filetype} =~ '\w' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
270 let syntax_group_exclude_{filetype} = |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
271 \ substitute( syntax_group_exclude_{filetype}, |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
272 \ '\s*,\s*', '\\|', 'g' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
273 \ ) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
274 endif |
702 | 275 endif |
276 endif | |
277 | |
871 | 278 " Sometimes filetypes can be composite names, like c.doxygen |
279 " Loop through each individual part looking for the syntax | |
280 " items specific to each individual filetype. | |
625 | 281 let syn_list = '' |
871 | 282 let ftindex = 0 |
283 let ftindex = match(&filetype, '\w\+', ftindex) | |
625 | 284 |
871 | 285 while ftindex > -1 |
286 let ft_part_name = matchstr( &filetype, '\w\+', ftindex ) | |
625 | 287 |
871 | 288 " Syntax rules can contain items for more than just the current |
289 " filetype. They can contain additional items added by the user | |
290 " via autocmds or their vimrc. | |
291 " Some syntax files can be combined (html, php, jsp). | |
292 " We want only items that begin with the filetype we are interested in. | |
293 let next_group_regex = '\n' . | |
294 \ '\zs'.ft_part_name.'\w\+\ze'. | |
295 \ '\s\+xxx\s\+' | |
296 let index = 0 | |
297 let index = match(syntax_full, next_group_regex, index) | |
298 | |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
299 if index == -1 && exists('b:current_syntax') && ft_part_name != b:current_syntax |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
300 " There appears to be two standards when writing syntax files. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
301 " Either items begin as: |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
302 " syn keyword {filetype}Keyword values ... |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
303 " let b:current_syntax = "sql" |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
304 " let b:current_syntax = "sqlanywhere" |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
305 " Or |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
306 " syn keyword {syntax_filename}Keyword values ... |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
307 " let b:current_syntax = "mysql" |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
308 " So, we will make the format of finding the syntax group names |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
309 " a bit more flexible and look for both if the first fails to |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
310 " find a match. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
311 let next_group_regex = '\n' . |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
312 \ '\zs'.b:current_syntax.'\w\+\ze'. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
313 \ '\s\+xxx\s\+' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
314 let index = 0 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
315 let index = match(syntax_full, next_group_regex, index) |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
316 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
317 |
871 | 318 while index > -1 |
319 let group_name = matchstr( syntax_full, '\w\+', index ) | |
320 | |
321 let get_syn_list = 1 | |
2434
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
322 for exclude_group_name in list_exclude_groups |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
323 if '\<'.exclude_group_name.'\>' =~ '\<'.group_name.'\>' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
324 let get_syn_list = 0 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
325 endif |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
326 endfor |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
327 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
328 " This code is no longer needed in version 6.0 since we have |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
329 " augmented the syntax list command to only retrieve the syntax |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
330 " groups we are interested in. |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
331 " |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
332 " if get_syn_list == 1 |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
333 " if syntax_group_include_{filetype} != '' |
86532ee3ea41
Updated runtime files. Add logcheck filetype plugin. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2072
diff
changeset
|
334 " if '\<'.syntax_group_include_{filetype}.'\>' !~ '\<'.group_name.'\>' |
871 | 335 " let get_syn_list = 0 |
336 " endif | |
337 " endif | |
338 " endif | |
339 | |
340 if get_syn_list == 1 | |
341 " Pass in the full syntax listing, plus the group name we | |
342 " are interested in. | |
343 let extra_syn_list = s:SyntaxCSyntaxGroupItems(group_name, syntax_full) | |
344 let syn_list = syn_list . extra_syn_list . "\n" | |
345 endif | |
625 | 346 |
871 | 347 let index = index + strlen(group_name) |
348 let index = match(syntax_full, next_group_regex, index) | |
349 endwhile | |
350 | |
351 let ftindex = ftindex + len(ft_part_name) | |
352 let ftindex = match( &filetype, '\w\+', ftindex ) | |
625 | 353 endwhile |
354 | |
702 | 355 " Convert the string to a List and sort it. |
356 let compl_list = sort(split(syn_list)) | |
357 | |
358 if &filetype == 'vim' | |
359 let short_compl_list = [] | |
360 for i in range(len(compl_list)) | |
361 if i == len(compl_list)-1 | |
362 let next = i | |
363 else | |
364 let next = i + 1 | |
365 endif | |
366 if compl_list[next] !~ '^'.compl_list[i].'.$' | |
367 let short_compl_list += [compl_list[i]] | |
368 endif | |
369 endfor | |
370 | |
371 return short_compl_list | |
372 else | |
373 return compl_list | |
374 endif | |
625 | 375 endfunction |
376 | |
818 | 377 function! s:SyntaxCSyntaxGroupItems( group_name, syntax_full ) |
702 | 378 |
379 let syn_list = "" | |
625 | 380 |
702 | 381 " From the full syntax listing, strip out the portion for the |
382 " request group. | |
383 " Query: | |
384 " \n - must begin with a newline | |
385 " a:group_name - the group name we are interested in | |
386 " \s\+xxx\s\+ - group names are always followed by xxx | |
387 " \zs - start the match | |
388 " .\{-} - everything ... | |
389 " \ze - end the match | |
2072 | 390 " \( - start a group or 2 potential matches |
702 | 391 " \n\w - at the first newline starting with a character |
2072 | 392 " \| - 2nd potential match |
393 " \%$ - matches end of the file or string | |
394 " \) - end a group | |
702 | 395 let syntax_group = matchstr(a:syntax_full, |
2072 | 396 \ "\n".a:group_name.'\s\+xxx\s\+\zs.\{-}\ze\(\n\w\|\%$\)' |
871 | 397 \ ) |
702 | 398 |
399 if syntax_group != "" | |
625 | 400 " let syn_list = substitute( @l, '^.*xxx\s*\%(contained\s*\)\?', "", '' ) |
702 | 401 " let syn_list = substitute( @l, '^.*xxx\s*', "", '' ) |
625 | 402 |
403 " We only want the words for the lines begining with | |
404 " containedin, but there could be other items. | |
405 | |
406 " Tried to remove all lines that do not begin with contained | |
407 " but this does not work in all cases since you can have | |
408 " contained nextgroup=... | |
409 " So this will strip off the ending of lines with known | |
410 " keywords. | |
871 | 411 let syn_list = substitute( |
412 \ syntax_group, '\<\('. | |
413 \ substitute( | |
414 \ escape(s:syn_remove_words, '\\/.*$^~[]') | |
415 \ , ',', '\\|', 'g' | |
416 \ ). | |
417 \ '\).\{-}\%($\|'."\n".'\)' | |
418 \ , "\n", 'g' | |
419 \ ) | |
625 | 420 |
3224 | 421 " Now strip off the newline + blank space + contained. |
422 " Also include lines with nextgroup=@someName skip_key_words syntax_element | |
871 | 423 let syn_list = substitute( |
3224 | 424 \ syn_list, '\%(^\|\n\)\@<=\s*\<\(contained\|nextgroup=\)' |
425 \ , "", 'g' | |
426 \ ) | |
427 | |
428 " This can leave lines like this | |
429 " =@vimMenuList skipwhite onoremenu | |
430 " Strip the special option keywords first | |
431 " :h :syn-skipwhite* | |
432 let syn_list = substitute( | |
433 \ syn_list, '\<\(skipwhite\|skipnl\|skipempty\)\>' | |
434 \ , "", 'g' | |
435 \ ) | |
436 | |
437 " Now remove the remainder of the nextgroup=@someName lines | |
438 let syn_list = substitute( | |
439 \ syn_list, '\%(^\|\n\)\@<=\s*\(@\w\+\)' | |
871 | 440 \ , "", 'g' |
441 \ ) | |
625 | 442 |
1121 | 443 if b:omni_syntax_use_iskeyword == 0 |
444 " There are a number of items which have non-word characters in | |
445 " them, *'T_F1'*. vim.vim is one such file. | |
446 " This will replace non-word characters with spaces. | |
447 let syn_list = substitute( syn_list, '[^0-9A-Za-z_ ]', ' ', 'g' ) | |
448 else | |
449 let accept_chars = ','.&iskeyword.',' | |
450 " Remove all character ranges | |
1620 | 451 " let accept_chars = substitute(accept_chars, ',[^,]\+-[^,]\+,', ',', 'g') |
452 let accept_chars = substitute(accept_chars, ',\@<=[^,]\+-[^,]\+,', '', 'g') | |
1121 | 453 " Remove all numeric specifications |
1620 | 454 " let accept_chars = substitute(accept_chars, ',\d\{-},', ',', 'g') |
455 let accept_chars = substitute(accept_chars, ',\@<=\d\{-},', '', 'g') | |
1121 | 456 " Remove all commas |
457 let accept_chars = substitute(accept_chars, ',', '', 'g') | |
458 " Escape special regex characters | |
459 let accept_chars = escape(accept_chars, '\\/.*$^~[]' ) | |
460 " Remove all characters that are not acceptable | |
461 let syn_list = substitute( syn_list, '[^0-9A-Za-z_ '.accept_chars.']', ' ', 'g' ) | |
462 endif | |
463 | |
464 if b:omni_syntax_minimum_length > 0 | |
465 " If the user specified a minimum length, enforce it | |
466 let syn_list = substitute(' '.syn_list.' ', ' \S\{,'.b:omni_syntax_minimum_length.'}\ze ', ' ', 'g') | |
467 endif | |
625 | 468 else |
469 let syn_list = '' | |
470 endif | |
471 | |
472 return syn_list | |
473 endfunction |