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