| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | " Vim completion script | 
					
						
							|  |  |  | " Language:    All languages, uses existing syntax highlighting rules | 
					
						
							|  |  |  | " Maintainer:  David Fishburn <fishburn@ianywhere.com> | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  | " Version:     3.0 | 
					
						
							|  |  |  | " Last Change: Wed Nov 08 2006 10:46:46 AM | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  | " Usage:       For detailed help, ":help ft-syntax-omni"  | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | " Set completion with CTRL-X CTRL-O to autoloaded function. | 
					
						
							| 
									
										
										
										
											2006-03-19 22:11:16 +00:00
										 |  |  | " This check is in place in case this script is | 
					
						
							|  |  |  | " sourced directly instead of using the autoload feature.  | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  | if exists('+omnifunc') | 
					
						
							| 
									
										
										
										
											2006-03-19 22:11:16 +00:00
										 |  |  |     " Do not set the option if already set since this | 
					
						
							|  |  |  |     " results in an E117 warning. | 
					
						
							|  |  |  |     if &omnifunc == "" | 
					
						
							|  |  |  |         setlocal omnifunc=syntaxcomplete#Complete | 
					
						
							|  |  |  |     endif | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if exists('g:loaded_syntax_completion') | 
					
						
							|  |  |  |     finish  | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  | let g:loaded_syntax_completion = 30 | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | " Set ignorecase to the ftplugin standard | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  | " This is the default setting, but if you define a buffer local | 
					
						
							|  |  |  | " variable you can override this on a per filetype. | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  | if !exists('g:omni_syntax_ignorecase') | 
					
						
							|  |  |  |     let g:omni_syntax_ignorecase = &ignorecase | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  | " Indicates whether we should use the iskeyword option to determine | 
					
						
							|  |  |  | " how to split words. | 
					
						
							|  |  |  | " This is the default setting, but if you define a buffer local | 
					
						
							|  |  |  | " variable you can override this on a per filetype. | 
					
						
							|  |  |  | if !exists('g:omni_syntax_use_iskeyword') | 
					
						
							|  |  |  |     let g:omni_syntax_use_iskeyword = 1 | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Only display items in the completion window that are at least | 
					
						
							|  |  |  | " this many characters in length. | 
					
						
							|  |  |  | " This is the default setting, but if you define a buffer local | 
					
						
							|  |  |  | " variable you can override this on a per filetype. | 
					
						
							|  |  |  | if !exists('g:omni_syntax_minimum_length') | 
					
						
							|  |  |  |     let g:omni_syntax_minimum_length = 0 | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | " This script will build a completion list based on the syntax | 
					
						
							|  |  |  | " elements defined by the files in $VIMRUNTIME/syntax. | 
					
						
							|  |  |  | let s:syn_remove_words = 'match,matchgroup=,contains,'. | 
					
						
							|  |  |  |             \ 'links to,start=,end=,nextgroup=' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let s:cache_name = [] | 
					
						
							|  |  |  | let s:cache_list = [] | 
					
						
							| 
									
										
										
										
											2006-03-19 22:11:16 +00:00
										 |  |  | let s:prepended  = '' | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | " This function is used for the 'omnifunc' option. | 
					
						
							|  |  |  | function! syntaxcomplete#Complete(findstart, base) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  |     " Only display items in the completion window that are at least | 
					
						
							|  |  |  |     " this many characters in length | 
					
						
							|  |  |  |     if !exists('b:omni_syntax_ignorecase') | 
					
						
							|  |  |  |         if exists('g:omni_syntax_ignorecase') | 
					
						
							|  |  |  |             let b:omni_syntax_ignorecase = g:omni_syntax_ignorecase | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             let b:omni_syntax_ignorecase = &ignorecase | 
					
						
							|  |  |  |         endif | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     if a:findstart | 
					
						
							|  |  |  |         " Locate the start of the item, including "." | 
					
						
							|  |  |  |         let line = getline('.') | 
					
						
							|  |  |  |         let start = col('.') - 1 | 
					
						
							|  |  |  |         let lastword = -1 | 
					
						
							|  |  |  |         while start > 0 | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  |             " if line[start - 1] =~ '\S' | 
					
						
							|  |  |  |             "     let start -= 1 | 
					
						
							|  |  |  |             " elseif line[start - 1] =~ '\.' | 
					
						
							|  |  |  |             if line[start - 1] =~ '\k' | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |                 let start -= 1 | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  |                 let lastword = a:findstart | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |             else | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             endif | 
					
						
							|  |  |  |         endwhile | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         " Return the column of the last word, which is going to be changed. | 
					
						
							|  |  |  |         " Remember the text that comes before it in s:prepended. | 
					
						
							|  |  |  |         if lastword == -1 | 
					
						
							|  |  |  |             let s:prepended = '' | 
					
						
							|  |  |  |             return start | 
					
						
							|  |  |  |         endif | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  |         let s:prepended = strpart(line, start, (col('.') - 1) - start) | 
					
						
							|  |  |  |         return start | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  |     " let base = s:prepended . a:base | 
					
						
							|  |  |  |     let base = s:prepended | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     let filetype = substitute(&filetype, '\.', '_', 'g') | 
					
						
							|  |  |  |     let list_idx = index(s:cache_name, filetype, 0, &ignorecase) | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     if list_idx > -1 | 
					
						
							|  |  |  |         let compl_list = s:cache_list[list_idx] | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |         let compl_list   = OmniSyntaxList() | 
					
						
							|  |  |  |         let s:cache_name = add( s:cache_name,  filetype ) | 
					
						
							|  |  |  |         let s:cache_list = add( s:cache_list,  compl_list ) | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     " Return list of matches. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  |     if base != '' | 
					
						
							|  |  |  |         " let compstr    = join(compl_list, ' ') | 
					
						
							|  |  |  |         " let expr       = (b:omni_syntax_ignorecase==0?'\C':'').'\<\%('.base.'\)\@!\w\+\s*' | 
					
						
							|  |  |  |         " let compstr    = substitute(compstr, expr, '', 'g') | 
					
						
							|  |  |  |         " let compl_list = split(compstr, '\s\+') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         " Filter the list based on the first few characters the user | 
					
						
							|  |  |  |         " entered | 
					
						
							|  |  |  |         let expr = 'v:val '.(g:omni_syntax_ignorecase==1?'=~?':'=~#')." '^".escape(base, '\\/.*$^~[]').".*'" | 
					
						
							|  |  |  |         let compl_list = filter(deepcopy(compl_list), expr) | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return compl_list | 
					
						
							|  |  |  | endfunc | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  | function! OmniSyntaxList() | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     " Default to returning a dictionary, if use_dictionary is set to 0 | 
					
						
							|  |  |  |     " a list will be returned. | 
					
						
							|  |  |  |     " let use_dictionary = 1 | 
					
						
							|  |  |  |     " if a:0 > 0 && a:1 != '' | 
					
						
							|  |  |  |     "     let use_dictionary = a:1 | 
					
						
							|  |  |  |     " endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  |     " Only display items in the completion window that are at least | 
					
						
							|  |  |  |     " this many characters in length | 
					
						
							|  |  |  |     if !exists('b:omni_syntax_use_iskeyword') | 
					
						
							|  |  |  |         if exists('g:omni_syntax_use_iskeyword') | 
					
						
							|  |  |  |             let b:omni_syntax_use_iskeyword = g:omni_syntax_use_iskeyword | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             let b:omni_syntax_use_iskeyword = 1 | 
					
						
							|  |  |  |         endif | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     " Only display items in the completion window that are at least | 
					
						
							|  |  |  |     " this many characters in length | 
					
						
							|  |  |  |     if !exists('b:omni_syntax_minimum_length') | 
					
						
							|  |  |  |         if exists('g:omni_syntax_minimum_length') | 
					
						
							|  |  |  |             let b:omni_syntax_minimum_length = g:omni_syntax_minimum_length | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             let b:omni_syntax_minimum_length = 0 | 
					
						
							|  |  |  |         endif | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     let saveL = @l | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     " Loop through all the syntax groupnames, and build a | 
					
						
							|  |  |  |     " syntax file which contains these names.  This can  | 
					
						
							|  |  |  |     " work generically for any filetype that does not already | 
					
						
							|  |  |  |     " have a plugin defined. | 
					
						
							|  |  |  |     " This ASSUMES the syntax groupname BEGINS with the name | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |     " of the filetype.  From my casual viewing of the vim7\syntax  | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     " directory. | 
					
						
							|  |  |  |     redir @l | 
					
						
							|  |  |  |     silent! exec 'syntax list ' | 
					
						
							|  |  |  |     redir END | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |     let syntax_full = "\n".@l | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     let @l = saveL | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |     if syntax_full =~ 'E28'  | 
					
						
							|  |  |  |                 \ || syntax_full =~ 'E411' | 
					
						
							|  |  |  |                 \ || syntax_full =~ 'E415' | 
					
						
							|  |  |  |                 \ || syntax_full =~ 'No Syntax items' | 
					
						
							|  |  |  |         return [] | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     let filetype = substitute(&filetype, '\.', '_', 'g') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |     " Default the include group to include the requested syntax group | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     let syntax_group_include_{filetype} = '' | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |     " Check if there are any overrides specified for this filetype | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     if exists('g:omni_syntax_group_include_'.filetype) | 
					
						
							|  |  |  |         let syntax_group_include_{filetype} = | 
					
						
							|  |  |  |                     \ substitute( g:omni_syntax_group_include_{filetype},'\s\+','','g')  | 
					
						
							|  |  |  |         if syntax_group_include_{filetype} =~ '\w' | 
					
						
							|  |  |  |             let syntax_group_include_{filetype} =  | 
					
						
							|  |  |  |                         \ substitute( syntax_group_include_{filetype},  | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |                         \ '\s*,\s*', '\\|', 'g' | 
					
						
							|  |  |  |                         \ ) | 
					
						
							|  |  |  |         endif | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     " Default the exclude group to nothing | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     let syntax_group_exclude_{filetype} = '' | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |     " Check if there are any overrides specified for this filetype | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     if exists('g:omni_syntax_group_exclude_'.filetype) | 
					
						
							|  |  |  |         let syntax_group_exclude_{filetype} = | 
					
						
							|  |  |  |                     \ substitute( g:omni_syntax_group_exclude_{filetype},'\s\+','','g')  | 
					
						
							|  |  |  |         if syntax_group_exclude_{filetype} =~ '\w'  | 
					
						
							|  |  |  |             let syntax_group_exclude_{filetype} =  | 
					
						
							|  |  |  |                         \ substitute( syntax_group_exclude_{filetype},  | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |                         \ '\s*,\s*', '\\|', 'g' | 
					
						
							|  |  |  |                         \ ) | 
					
						
							|  |  |  |         endif | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     " Sometimes filetypes can be composite names, like c.doxygen | 
					
						
							|  |  |  |     " Loop through each individual part looking for the syntax | 
					
						
							|  |  |  |     " items specific to each individual filetype. | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     let syn_list = '' | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |     let ftindex  = 0 | 
					
						
							|  |  |  |     let ftindex  = match(&filetype, '\w\+', ftindex) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while ftindex > -1 | 
					
						
							|  |  |  |         let ft_part_name = matchstr( &filetype, '\w\+', ftindex ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         " Syntax rules can contain items for more than just the current  | 
					
						
							|  |  |  |         " filetype.  They can contain additional items added by the user | 
					
						
							|  |  |  |         " via autocmds or their vimrc. | 
					
						
							|  |  |  |         " Some syntax files can be combined (html, php, jsp). | 
					
						
							|  |  |  |         " We want only items that begin with the filetype we are interested in. | 
					
						
							|  |  |  |         let next_group_regex = '\n' . | 
					
						
							|  |  |  |                     \ '\zs'.ft_part_name.'\w\+\ze'. | 
					
						
							|  |  |  |                     \ '\s\+xxx\s\+'  | 
					
						
							|  |  |  |         let index    = 0 | 
					
						
							|  |  |  |         let index    = match(syntax_full, next_group_regex, index) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         while index > -1 | 
					
						
							|  |  |  |             let group_name = matchstr( syntax_full, '\w\+', index ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let get_syn_list = 1 | 
					
						
							|  |  |  |             " if syntax_group_include_{&filetype} == '' | 
					
						
							|  |  |  |             "     if syntax_group_exclude_{&filetype} != '' | 
					
						
							|  |  |  |             "         if '\<'.syntax_group_exclude_{&filetype}.'\>' =~ '\<'.group_name.'\>' | 
					
						
							|  |  |  |             "             let get_syn_list = 0 | 
					
						
							|  |  |  |             "         endif | 
					
						
							|  |  |  |             "     endif | 
					
						
							|  |  |  |             " else | 
					
						
							|  |  |  |             "     if '\<'.syntax_group_include_{&filetype}.'\>' !~ '\<'.group_name.'\>' | 
					
						
							|  |  |  |             "         let get_syn_list = 0 | 
					
						
							|  |  |  |             "     endif | 
					
						
							|  |  |  |             " endif | 
					
						
							|  |  |  |             if syntax_group_exclude_{filetype} != '' | 
					
						
							|  |  |  |                 if '\<'.syntax_group_exclude_{filetype}.'\>' =~ '\<'.group_name.'\>' | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |                     let get_syn_list = 0 | 
					
						
							|  |  |  |                 endif | 
					
						
							|  |  |  |             endif | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |          | 
					
						
							|  |  |  |             if get_syn_list == 1 | 
					
						
							|  |  |  |                 if syntax_group_include_{filetype} != '' | 
					
						
							|  |  |  |                     if '\<'.syntax_group_include_{filetype}.'\>' !~ '\<'.group_name.'\>' | 
					
						
							|  |  |  |                         let get_syn_list = 0 | 
					
						
							|  |  |  |                     endif | 
					
						
							|  |  |  |                 endif | 
					
						
							|  |  |  |             endif | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |             if get_syn_list == 1 | 
					
						
							|  |  |  |                 " Pass in the full syntax listing, plus the group name we  | 
					
						
							|  |  |  |                 " are interested in. | 
					
						
							|  |  |  |                 let extra_syn_list = s:SyntaxCSyntaxGroupItems(group_name, syntax_full) | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |                 " if !empty(extra_syn_list) | 
					
						
							|  |  |  |                 "     for elem in extra_syn_list | 
					
						
							|  |  |  |                 "         let item = {'word':elem, 'kind':'t', 'info':group_name} | 
					
						
							|  |  |  |                 "         let compl_list += [item] | 
					
						
							|  |  |  |                 "     endfor | 
					
						
							|  |  |  |                 " endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 let syn_list = syn_list . extra_syn_list . "\n" | 
					
						
							|  |  |  |             endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let index = index + strlen(group_name) | 
					
						
							|  |  |  |             let index = match(syntax_full, next_group_regex, index) | 
					
						
							|  |  |  |         endwhile | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |         let ftindex  = ftindex + len(ft_part_name) | 
					
						
							|  |  |  |         let ftindex  = match( &filetype, '\w\+', ftindex ) | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     endwhile | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |     " Convert the string to a List and sort it. | 
					
						
							|  |  |  |     let compl_list = sort(split(syn_list)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if &filetype == 'vim' | 
					
						
							|  |  |  |         let short_compl_list = [] | 
					
						
							|  |  |  |         for i in range(len(compl_list)) | 
					
						
							|  |  |  |             if i == len(compl_list)-1 | 
					
						
							|  |  |  |                 let next = i | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |                 let next = i + 1 | 
					
						
							|  |  |  |             endif | 
					
						
							|  |  |  |             if  compl_list[next] !~ '^'.compl_list[i].'.$' | 
					
						
							|  |  |  |                 let short_compl_list += [compl_list[i]] | 
					
						
							|  |  |  |             endif | 
					
						
							|  |  |  |         endfor | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return short_compl_list | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         return compl_list | 
					
						
							|  |  |  |     endif | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | endfunction | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-29 21:18:24 +00:00
										 |  |  | function! s:SyntaxCSyntaxGroupItems( group_name, syntax_full ) | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     let syn_list = "" | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |     " From the full syntax listing, strip out the portion for the | 
					
						
							|  |  |  |     " request group. | 
					
						
							|  |  |  |     " Query: | 
					
						
							|  |  |  |     "     \n           - must begin with a newline | 
					
						
							|  |  |  |     "     a:group_name - the group name we are interested in | 
					
						
							|  |  |  |     "     \s\+xxx\s\+  - group names are always followed by xxx | 
					
						
							|  |  |  |     "     \zs          - start the match | 
					
						
							|  |  |  |     "     .\{-}        - everything ... | 
					
						
							|  |  |  |     "     \ze          - end the match | 
					
						
							|  |  |  |     "     \n\w         - at the first newline starting with a character | 
					
						
							|  |  |  |     let syntax_group = matchstr(a:syntax_full,  | 
					
						
							|  |  |  |                 \ "\n".a:group_name.'\s\+xxx\s\+\zs.\{-}\ze'."\n".'\w' | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |                 \ ) | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if syntax_group != "" | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |         " let syn_list = substitute( @l, '^.*xxx\s*\%(contained\s*\)\?', "", '' ) | 
					
						
							| 
									
										
										
										
											2006-03-02 22:43:39 +00:00
										 |  |  |         " let syn_list = substitute( @l, '^.*xxx\s*', "", '' ) | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         " We only want the words for the lines begining with | 
					
						
							|  |  |  |         " containedin, but there could be other items. | 
					
						
							|  |  |  |          | 
					
						
							|  |  |  |         " Tried to remove all lines that do not begin with contained | 
					
						
							|  |  |  |         " but this does not work in all cases since you can have | 
					
						
							|  |  |  |         "    contained nextgroup=... | 
					
						
							|  |  |  |         " So this will strip off the ending of lines with known | 
					
						
							|  |  |  |         " keywords. | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |         let syn_list = substitute(  | 
					
						
							|  |  |  |                     \    syntax_group, '\<\('. | 
					
						
							|  |  |  |                     \    substitute( | 
					
						
							|  |  |  |                     \      escape(s:syn_remove_words, '\\/.*$^~[]') | 
					
						
							|  |  |  |                     \      , ',', '\\|', 'g' | 
					
						
							|  |  |  |                     \    ). | 
					
						
							|  |  |  |                     \    '\).\{-}\%($\|'."\n".'\)' | 
					
						
							|  |  |  |                     \    , "\n", 'g'  | 
					
						
							|  |  |  |                     \  ) | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         " Now strip off the newline + blank space + contained | 
					
						
							| 
									
										
										
										
											2006-05-06 21:40:45 +00:00
										 |  |  |         let syn_list = substitute(  | 
					
						
							|  |  |  |                     \    syn_list, '\%(^\|\n\)\@<=\s*\<\(contained\)' | 
					
						
							|  |  |  |                     \    , "", 'g'  | 
					
						
							|  |  |  |                     \ ) | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 17:54:07 +00:00
										 |  |  |         if b:omni_syntax_use_iskeyword == 0 | 
					
						
							|  |  |  |             " There are a number of items which have non-word characters in | 
					
						
							|  |  |  |             " them, *'T_F1'*.  vim.vim is one such file. | 
					
						
							|  |  |  |             " This will replace non-word characters with spaces. | 
					
						
							|  |  |  |             let syn_list = substitute( syn_list, '[^0-9A-Za-z_ ]', ' ', 'g' ) | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             let accept_chars = ','.&iskeyword.',' | 
					
						
							|  |  |  |             " Remove all character ranges | 
					
						
							|  |  |  |             let accept_chars = substitute(accept_chars, ',[^,]\+-[^,]\+,', ',', 'g') | 
					
						
							|  |  |  |             " Remove all numeric specifications | 
					
						
							|  |  |  |             let accept_chars = substitute(accept_chars, ',\d\{-},', ',', 'g') | 
					
						
							|  |  |  |             " Remove all commas | 
					
						
							|  |  |  |             let accept_chars = substitute(accept_chars, ',', '', 'g') | 
					
						
							|  |  |  |             " Escape special regex characters | 
					
						
							|  |  |  |             let accept_chars = escape(accept_chars, '\\/.*$^~[]' ) | 
					
						
							|  |  |  |             " Remove all characters that are not acceptable | 
					
						
							|  |  |  |             let syn_list = substitute( syn_list, '[^0-9A-Za-z_ '.accept_chars.']', ' ', 'g' ) | 
					
						
							|  |  |  |         endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if b:omni_syntax_minimum_length > 0 | 
					
						
							|  |  |  |             " If the user specified a minimum length, enforce it | 
					
						
							|  |  |  |             let syn_list = substitute(' '.syn_list.' ', ' \S\{,'.b:omni_syntax_minimum_length.'}\ze ', ' ', 'g') | 
					
						
							|  |  |  |         endif | 
					
						
							| 
									
										
										
										
											2006-01-12 23:22:24 +00:00
										 |  |  |     else | 
					
						
							|  |  |  |         let syn_list = '' | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return syn_list | 
					
						
							|  |  |  | endfunction |