annotate runtime/autoload/syntaxcomplete.vim @ 754:3a779b47f235 v7.0223

updated for version 7.0223
author vimboss
date Mon, 13 Mar 2006 22:18:45 +0000
parents 8a99b25de218
children fd60bacf955b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
1 " Vim completion script
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
2 " Language: All languages, uses existing syntax highlighting rules
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
3 " Maintainer: David Fishburn <fishburn@ianywhere.com>
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
4 " Version: 1.1
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
5 " Last Change: Wed Mar 01 2006 9:58:14 PM
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
6
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
7 " Set completion with CTRL-X CTRL-O to autoloaded function.
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
8 if exists('+omnifunc')
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
9 setlocal omnifunc=syntaxcomplete#Complete
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
10 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
11
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
12 if exists('g:loaded_syntax_completion')
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
13 finish
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
14 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
15 let g:loaded_syntax_completion = 1
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
16
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
17 " This script will build a completion list based on the syntax
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
18 " elements defined by the files in $VIMRUNTIME/syntax.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
19
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
20 let s:syn_remove_words = 'match,matchgroup=,contains,'.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
21 \ 'links to,start=,end=,nextgroup='
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
22
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
23 let s:cache_name = []
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
24 let s:cache_list = []
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
25
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
26 " This function is used for the 'omnifunc' option.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
27 function! syntaxcomplete#Complete(findstart, base)
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
28
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
29 if a:findstart
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
30 " Locate the start of the item, including "."
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
31 let line = getline('.')
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
32 let start = col('.') - 1
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
33 let lastword = -1
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
34 while start > 0
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
35 if line[start - 1] =~ '\w'
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
36 let start -= 1
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
37 elseif line[start - 1] =~ '\.'
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
38 " The user must be specifying a column name
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
39 if lastword == -1
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
40 let lastword = start
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
41 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
42 let start -= 1
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
43 let b:sql_compl_type = 'column'
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
44 else
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
45 break
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
46 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
47 endwhile
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
48
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
49 " Return the column of the last word, which is going to be changed.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
50 " Remember the text that comes before it in s:prepended.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
51 if lastword == -1
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
52 let s:prepended = ''
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
53 return start
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
54 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
55 let s:prepended = strpart(line, start, lastword - start)
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
56 return lastword
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
57 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
58
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
59 let base = s:prepended . a:base
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
60
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
61 let list_idx = index(s:cache_name, &filetype, 0, &ignorecase)
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
62 if list_idx > -1
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
63 let compl_list = s:cache_list[list_idx]
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
64 else
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
65 let compl_list = OmniSyntaxList()
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
66 let s:cache_name = add( s:cache_name, &filetype )
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
67 let s:cache_list = add( s:cache_list, compl_list )
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
68 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
69
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
70 " Return list of matches.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
71
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
72 if base =~ '\w'
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
73 let compstr = join(compl_list, ' ')
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
74 let compstr = substitute(compstr, '\<\%('.base.'\)\@!\w\+\s*', '', 'g')
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
75 let compl_list = split(compstr, '\s\+')
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
76 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
77
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
78 return compl_list
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
79 endfunc
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
80
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
81 function! OmniSyntaxList()
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
82 let saveL = @l
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
83
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
84 " Loop through all the syntax groupnames, and build a
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
85 " syntax file which contains these names. This can
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
86 " work generically for any filetype that does not already
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
87 " have a plugin defined.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
88 " This ASSUMES the syntax groupname BEGINS with the name
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
89 " of the filetype. From my casual viewing of the vim7\syntax
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
90 " directory.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
91 redir @l
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
92 silent! exec 'syntax list '
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
93 redir END
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
94
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
95 let syntax_full = "\n".@l
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
96 let @l = saveL
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
97
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
98 if syntax_full =~ 'E28'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
99 \ || syntax_full =~ 'E411'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
100 \ || syntax_full =~ 'E415'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
101 \ || syntax_full =~ 'No Syntax items'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
102 return []
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
103 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
104
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
105 " Default the include group to include the requested syntax group
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
106 let syntax_group_include_{&filetype} = ''
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
107 " Check if there are any overrides specified for this filetype
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
108 if exists('g:omni_syntax_group_include_'.&filetype)
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
109 let syntax_group_include_{&filetype} =
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
110 \ substitute( g:omni_syntax_group_include_{&filetype},'\s\+','','g')
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
111 if syntax_group_include_{&filetype} =~ '\w'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
112 let syntax_group_include_{&filetype} =
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
113 \ substitute( syntax_group_include_{&filetype},
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
114 \ '\s*,\s*', '\\|', 'g'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
115 \ )
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
116 endif
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
117 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
118
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
119 " Default the exclude group to nothing
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
120 let syntax_group_exclude_{&filetype} = ''
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
121 " Check if there are any overrides specified for this filetype
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
122 if exists('g:omni_syntax_group_exclude_'.&filetype)
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
123 let syntax_group_exclude_{&filetype} =
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
124 \ substitute( g:omni_syntax_group_exclude_{&filetype},'\s\+','','g')
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
125 if syntax_group_exclude_{&filetype} =~ '\w'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
126 let syntax_group_exclude_{&filetype} =
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
127 \ substitute( syntax_group_exclude_{&filetype},
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
128 \ '\s*,\s*', '\\|', 'g'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
129 \ )
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
130 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
131 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
132
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
133 " Syntax rules can contain items for more than just the current
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
134 " filetype. They can contain additional items added by the user
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
135 " via autocmds or their vimrc.
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
136 " Some syntax files can be combined (html, php, jsp).
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
137 " We want only items that begin with the filetype we are interested in.
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
138 let next_group_regex = '\n' .
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
139 \ '\zs'.&filetype.'\w\+\ze'.
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
140 \ '\s\+xxx\s\+'
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
141 let syn_list = ''
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
142 let index = 0
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
143 let index = match(syntax_full, next_group_regex, index)
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
144
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
145 while index > 0
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
146 let group_name = matchstr( syntax_full, '\w\+', index )
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
147
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
148 let get_syn_list = 1
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
149 " if syntax_group_include_{&filetype} == ''
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
150 " if syntax_group_exclude_{&filetype} != ''
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
151 " if '\<'.syntax_group_exclude_{&filetype}.'\>' =~ '\<'.group_name.'\>'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
152 " let get_syn_list = 0
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
153 " endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
154 " endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
155 " else
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
156 " if '\<'.syntax_group_include_{&filetype}.'\>' !~ '\<'.group_name.'\>'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
157 " let get_syn_list = 0
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
158 " endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
159 " endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
160 if syntax_group_exclude_{&filetype} != ''
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
161 if '\<'.syntax_group_exclude_{&filetype}.'\>' =~ '\<'.group_name.'\>'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
162 let get_syn_list = 0
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
163 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
164 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
165
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
166 if get_syn_list == 1
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
167 if syntax_group_include_{&filetype} != ''
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
168 if '\<'.syntax_group_include_{&filetype}.'\>' !~ '\<'.group_name.'\>'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
169 let get_syn_list = 0
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
170 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
171 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
172 endif
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
173
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
174 if get_syn_list == 1
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
175 " Pass in the full syntax listing, plus the group name we
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
176 " are interested in.
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
177 let extra_syn_list = s:SyntaxGroupItems(group_name, syntax_full)
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
178
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
179 let syn_list = syn_list . extra_syn_list . "\n"
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
180 endif
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
181
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
182 let index = index + strlen(group_name)
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
183 let index = match(syntax_full, next_group_regex, index)
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
184 endwhile
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
185
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
186 " Convert the string to a List and sort it.
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
187 let compl_list = sort(split(syn_list))
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
188
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
189 if &filetype == 'vim'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
190 let short_compl_list = []
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
191 for i in range(len(compl_list))
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
192 if i == len(compl_list)-1
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
193 let next = i
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
194 else
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
195 let next = i + 1
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
196 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
197 if compl_list[next] !~ '^'.compl_list[i].'.$'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
198 let short_compl_list += [compl_list[i]]
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
199 endif
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
200 endfor
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
201
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
202 return short_compl_list
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
203 else
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
204 return compl_list
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
205 endif
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
206 endfunction
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
207
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
208 function! s:SyntaxGroupItems( group_name, syntax_full )
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
209
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
210 let syn_list = ""
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
211
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
212 " From the full syntax listing, strip out the portion for the
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
213 " request group.
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
214 " Query:
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
215 " \n - must begin with a newline
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
216 " a:group_name - the group name we are interested in
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
217 " \s\+xxx\s\+ - group names are always followed by xxx
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
218 " \zs - start the match
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
219 " .\{-} - everything ...
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
220 " \ze - end the match
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
221 " \n\w - at the first newline starting with a character
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
222 let syntax_group = matchstr(a:syntax_full,
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
223 \ "\n".a:group_name.'\s\+xxx\s\+\zs.\{-}\ze'."\n".'\w'
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
224 \)
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
225
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
226 if syntax_group != ""
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
227 " let syn_list = substitute( @l, '^.*xxx\s*\%(contained\s*\)\?', "", '' )
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
228 " let syn_list = substitute( @l, '^.*xxx\s*', "", '' )
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
229
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
230 " We only want the words for the lines begining with
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
231 " containedin, but there could be other items.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
232
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
233 " Tried to remove all lines that do not begin with contained
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
234 " but this does not work in all cases since you can have
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
235 " contained nextgroup=...
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
236 " So this will strip off the ending of lines with known
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
237 " keywords.
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 625
diff changeset
238 let syn_list = substitute( syntax_group, '\<\('.
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
239 \ substitute(
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
240 \ escape( s:syn_remove_words, '\\/.*$^~[]')
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
241 \ , ',', '\\|', 'g').
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
242 \ '\).\{-}\%($\|'."\n".'\)'
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
243 \ , "\n", 'g' )
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
244
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
245 " Now strip off the newline + blank space + contained
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
246 let syn_list = substitute( syn_list, '\%(^\|\n\)\@<=\s*\<\('.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
247 \ 'contained\)'
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
248 \ , "", 'g' )
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
249
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
250 " There are a number of items which have non-word characters in
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
251 " them, *'T_F1'*. vim.vim is one such file.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
252 " This will replace non-word characters with spaces.
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
253 let syn_list = substitute( syn_list, '[^0-9A-Za-z_ ]', ' ', 'g' )
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
254 else
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
255 let syn_list = ''
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
256 endif
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
257
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
258 return syn_list
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
259 endfunction
81fe2ccc1207 updated for version 7.0179
vimboss
parents:
diff changeset
260