mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
updated for version 7.0212
This commit is contained in:
parent
b475fb917b
commit
c06ac34092
@ -1,12 +1,12 @@
|
||||
" Vim completion script
|
||||
" Language: All languages, uses existing syntax highlighting rules
|
||||
" Maintainer: David Fishburn <fishburn@ianywhere.com>
|
||||
" Version: 1.0
|
||||
" Last Change: Sun Jan 08 2006 10:17:51 PM
|
||||
" Version: 1.1
|
||||
" Last Change: Wed Mar 01 2006 9:58:14 PM
|
||||
|
||||
" Set completion with CTRL-X CTRL-O to autoloaded function.
|
||||
if exists('&ofu')
|
||||
setlocal ofu=syntaxcomplete#Complete
|
||||
if exists('+omnifunc')
|
||||
setlocal omnifunc=syntaxcomplete#Complete
|
||||
endif
|
||||
|
||||
if exists('g:loaded_syntax_completion')
|
||||
@ -62,7 +62,7 @@ function! syntaxcomplete#Complete(findstart, base)
|
||||
if list_idx > -1
|
||||
let compl_list = s:cache_list[list_idx]
|
||||
else
|
||||
let compl_list = s:SyntaxList()
|
||||
let compl_list = OmniSyntaxList()
|
||||
let s:cache_name = add( s:cache_name, &filetype )
|
||||
let s:cache_list = add( s:cache_list, compl_list )
|
||||
endif
|
||||
@ -78,7 +78,7 @@ function! syntaxcomplete#Complete(findstart, base)
|
||||
return compl_list
|
||||
endfunc
|
||||
|
||||
function! s:SyntaxList()
|
||||
function! OmniSyntaxList()
|
||||
let saveL = @l
|
||||
|
||||
" Loop through all the syntax groupnames, and build a
|
||||
@ -86,63 +86,146 @@ function! s:SyntaxList()
|
||||
" work generically for any filetype that does not already
|
||||
" have a plugin defined.
|
||||
" This ASSUMES the syntax groupname BEGINS with the name
|
||||
" of the filetype. From my casual viewing of the vim7\sytax
|
||||
" of the filetype. From my casual viewing of the vim7\syntax
|
||||
" directory.
|
||||
redir @l
|
||||
silent! exec 'syntax list '
|
||||
redir END
|
||||
|
||||
let syntax_groups = @l
|
||||
let syntax_full = "\n".@l
|
||||
let @l = saveL
|
||||
|
||||
if syntax_groups =~ 'E28'
|
||||
\ || syntax_groups =~ 'E411'
|
||||
\ || syntax_groups =~ 'E415'
|
||||
\ || syntax_groups =~ 'No sytax items'
|
||||
return -1
|
||||
if syntax_full =~ 'E28'
|
||||
\ || syntax_full =~ 'E411'
|
||||
\ || syntax_full =~ 'E415'
|
||||
\ || syntax_full =~ 'No Syntax items'
|
||||
return []
|
||||
endif
|
||||
|
||||
" Abort names - match, links to, matchgroup=, start=, contains=, contained,
|
||||
" cluster=, nextgroup=, end=
|
||||
" Default the include group to include the requested syntax group
|
||||
let syntax_group_include_{&filetype} = ''
|
||||
" Check if there are any overrides specified for this filetype
|
||||
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},
|
||||
\ '\s*,\s*', '\\|', 'g'
|
||||
\ )
|
||||
endif
|
||||
endif
|
||||
|
||||
" Default the exclude group to nothing
|
||||
let syntax_group_exclude_{&filetype} = ''
|
||||
" Check if there are any overrides specified for this filetype
|
||||
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},
|
||||
\ '\s*,\s*', '\\|', 'g'
|
||||
\ )
|
||||
endif
|
||||
endif
|
||||
|
||||
" 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'.&filetype.'\w\+\ze'.
|
||||
\ '\s\+xxx\s\+'.
|
||||
\ '\<\('.
|
||||
\ substitute(s:syn_remove_words, ',', '\\|', 'g').
|
||||
\ '\)\@!'
|
||||
\ '\s\+xxx\s\+'
|
||||
let syn_list = ''
|
||||
let index = 0
|
||||
let index = match(syntax_groups, next_group_regex, index)
|
||||
|
||||
let index = match(syntax_full, next_group_regex, index)
|
||||
|
||||
while index > 0
|
||||
let group_name = matchstr( syntax_groups, '\w\+', index )
|
||||
let group_name = matchstr( syntax_full, '\w\+', index )
|
||||
|
||||
let extra_syn_list = s:SyntaxGroupItems(group_name)
|
||||
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.'\>'
|
||||
let get_syn_list = 0
|
||||
endif
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
let syn_list = syn_list . extra_syn_list . "\n"
|
||||
if get_syn_list == 1
|
||||
" Pass in the full syntax listing, plus the group name we
|
||||
" are interested in.
|
||||
let extra_syn_list = s:SyntaxGroupItems(group_name, syntax_full)
|
||||
|
||||
let syn_list = syn_list . extra_syn_list . "\n"
|
||||
endif
|
||||
|
||||
let index = index + strlen(group_name)
|
||||
let index = match(syntax_groups, next_group_regex, index)
|
||||
let index = match(syntax_full, next_group_regex, index)
|
||||
endwhile
|
||||
|
||||
return sort(split(syn_list))
|
||||
" 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
|
||||
endfunction
|
||||
|
||||
function! s:SyntaxGroupItems( group_name )
|
||||
let saveL = @l
|
||||
|
||||
" Generate (based on the syntax highlight rules) a list of
|
||||
" the Statements, functions, keywords and so on available
|
||||
" If this needs updating, the syntax\sql.vim file should be
|
||||
" updated
|
||||
redir @l
|
||||
silent! exec 'syntax list ' . a:group_name
|
||||
redir END
|
||||
function! s:SyntaxGroupItems( group_name, syntax_full )
|
||||
|
||||
if @l !~ 'E28'
|
||||
let syn_list = ""
|
||||
|
||||
" 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'
|
||||
\)
|
||||
|
||||
if syntax_group != ""
|
||||
" let syn_list = substitute( @l, '^.*xxx\s*\%(contained\s*\)\?', "", '' )
|
||||
let syn_list = substitute( @l, '^.*xxx\s*', "", '' )
|
||||
" let syn_list = substitute( @l, '^.*xxx\s*', "", '' )
|
||||
|
||||
" We only want the words for the lines begining with
|
||||
" containedin, but there could be other items.
|
||||
@ -152,7 +235,7 @@ function! s:SyntaxGroupItems( group_name )
|
||||
" contained nextgroup=...
|
||||
" So this will strip off the ending of lines with known
|
||||
" keywords.
|
||||
let syn_list = substitute( syn_list, '\<\('.
|
||||
let syn_list = substitute( syntax_group, '\<\('.
|
||||
\ substitute(
|
||||
\ escape( s:syn_remove_words, '\\/.*$^~[]')
|
||||
\ , ',', '\\|', 'g').
|
||||
@ -172,8 +255,6 @@ function! s:SyntaxGroupItems( group_name )
|
||||
let syn_list = ''
|
||||
endif
|
||||
|
||||
let @l = saveL
|
||||
|
||||
return syn_list
|
||||
endfunction
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
*insert.txt* For Vim version 7.0aa. Last change: 2006 Feb 23
|
||||
*insert.txt* For Vim version 7.0aa. Last change: 2006 Mar 02
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -1244,18 +1244,56 @@ SYNTAX *ft-syntax-omni*
|
||||
This uses the current syntax highlighting for completion. It can be used for
|
||||
any filetype and provides a minimal language-sensitive completion.
|
||||
|
||||
To enable code completion do: >
|
||||
source $VIMRUNTIME/autoload/syntaxcomplete.vim
|
||||
To enable syntax code completion you can run: >
|
||||
setlocal omnifunc=syntaxcomplete#Complete
|
||||
|
||||
You can automate this by placing this in your vimrc (after any ":filetype"
|
||||
command): >
|
||||
autocmd Filetype *
|
||||
\ if exists('&ofu') && &ofu == "" |
|
||||
\ source $VIMRUNTIME/autoload/syntaxcomplete.vim |
|
||||
\ endif
|
||||
You can automate this by placing the following in your vimrc (after any
|
||||
":filetype" command): >
|
||||
if has("autocmd") && exists("+omnifunc")
|
||||
autocmd Filetype *
|
||||
\ if &omnifunc == "" |
|
||||
\ setlocal omnifunc=syntaxcomplete#Complete |
|
||||
\ endif
|
||||
endif
|
||||
|
||||
The above will set completion to this script only if a proper one does not
|
||||
already exist for that filetype.
|
||||
The above will set completion to this script only if a specific plugin does
|
||||
not already exist for that filetype.
|
||||
|
||||
Each filetype can have a wide range of syntax items. The plugin allows you to
|
||||
customize which syntax groups to include or exclude from the list. Let's have
|
||||
a look at the PHP filetype to see how this works.
|
||||
|
||||
If you edit a file called, index.php, run the following command: >
|
||||
:syntax list
|
||||
|
||||
First thing you will notice is there are many different syntax groups. The
|
||||
PHP language can include elements from different languages like HTML,
|
||||
JavaScript and many more. The syntax plugin will only include syntax groups
|
||||
that begin with the filetype, "php", in this case. For example these syntax
|
||||
groups are included by default with the PHP: phpEnvVar, phpIntVar,
|
||||
phpFunctions.
|
||||
|
||||
The PHP language has an enormous number of items which it knows how to syntax
|
||||
highlight. This means these items will be available within the omni
|
||||
completion list. Some people may find this list unwieldy or are only
|
||||
interested in certain items.
|
||||
|
||||
There are two ways to prune this list (if necessary). If you find certain
|
||||
syntax groups you do not wish displayed you can add the following to your
|
||||
vimrc: >
|
||||
let g:omni_syntax_group_exclude_php = 'phpCoreConstant,phpConstant'
|
||||
|
||||
Add as many syntax groups to this list by comma separating them. The basic
|
||||
form of this variable is: >
|
||||
let g:omni_syntax_group_exclude_{filetype} = 'comma,separated,list'
|
||||
|
||||
For completeness the opposite is also true. Creating this variable in your
|
||||
vimrc will only include the items in the phpFunctions and phpMethods syntax
|
||||
groups: >
|
||||
let g:omni_syntax_group_include_php = 'phpFunctions,phpMethods'
|
||||
|
||||
You can create as many of these variables as you need, varying only the
|
||||
filetype at the end of the variable name.
|
||||
|
||||
|
||||
XML *ft-xml-omni*
|
||||
|
@ -1,6 +1,6 @@
|
||||
" Vim plugin for showing matching parens
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2006 Mar 01
|
||||
" Last Change: 2006 Mar 02
|
||||
|
||||
" Exit quickly when:
|
||||
" - this plugin was already loaded (or disabled)
|
||||
@ -76,24 +76,14 @@ function! s:Highlight_Matching_Pair()
|
||||
execute 'if' s_skip '| let s_skip = 0 | endif'
|
||||
|
||||
" Find the match. When it was just before the cursor move it there for a
|
||||
" moment. To restore the cursor position use "N|" and when 'virtualedit'
|
||||
" is set, cursor() otherwise.
|
||||
" moment.
|
||||
if before > 0
|
||||
if &ve != ''
|
||||
let vcol = virtcol('.')
|
||||
let old_ve = &ve
|
||||
set ve=all
|
||||
endif
|
||||
let save_cursor = getpos('.')
|
||||
call cursor(c_lnum, c_col - before)
|
||||
endif
|
||||
let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline)
|
||||
if before > 0
|
||||
if &ve != ''
|
||||
exe 'normal ' . vcol . '|'
|
||||
let &ve = old_ve
|
||||
else
|
||||
call cursor(0, c_col)
|
||||
endif
|
||||
call cursor(save_cursor)
|
||||
endif
|
||||
|
||||
" If a match is found setup match highlighting.
|
||||
|
Loading…
x
Reference in New Issue
Block a user