sponsor Vim development Vim logo Vim Book Ad

SyntaxComplete : OMNI Completion based on the current syntax highlights

 script karma  Rating 28/14, Downloaded by 1746    Comments, bugs, improvements  Vim wiki

created by
David Fishburn
 
script type
utility
 
description
SyntaxComplete.vim is a plugin which uses the new Vim7 OMNI completion features (intellisense code completion).

SyntaxComplete.vim version 5.0 is included in the Vim 7.2 release.
SyntaxComplete.vim version 7.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 8.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 9.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 10.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 11.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 12.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 13.0 is included in the Vim 7.3 release.

What does it do:
-----------------------
Vim has the ability to color syntax highlight nearly 500 languages.  Part of this highlighting includes knowing what keywords are part of a language.  Many filetypes already have custom completion scripts written for them, the syntaxcomplete plugin provides basic completion for all other filetypes.  It does this by populating the omni completion list with the text Vim already knows how to color highlight.  It can be used for any filetype and provides a minimal language-sensitive completion.

There are not many languages with full blown OMNI completion scripts written in Vim.  Yet, having a list of functions and keywords to complete can be very handy especially when you are working with a predefined API.

Adding the following to your .vimrc, will setup SyntaxComplete for every filetype that does not already have a language specific OMNI script:

    if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
    \ if &omnifunc == "" |
    \ setlocal omnifunc=syntaxcomplete#Complete |
    \ endif
    endif


It also provides some public functions so other plugin writers can pull syntax keywords (based on group names) from Vim and utilize them in any manor.  Examples are included in the help files, but here is a simple example:
    let myKeywords = []
    let myKeywords = OmniSyntaxList( ['sqlKeyword'] )
    let allItems = OmniSyntaxList( [] )

Regex can also be used to identify which syntax groups to include:
    let myKeywords = OmniSyntaxList( ['html\w\+', 'jquery\w\+'] )



Existing instructions can be found within Vim7 using
:h ft-syntax-omni

This plugin is new to Vim7.  Improvements to the script will be uploaded here, and supplied to Bram for inclusion into future versions of Vim7.

There are many customizations which can be made per filetype via your .vimrc.  See the documentation for details.

 
install details
install details
Copy syntaxcomplete.vim to:
.vim/autoload/syntaxcomplete.vim (Unix)
vimfiles\autoload\syntaxcomplete.vim (Windows)

For documentation:
:h ft-syntax-omni
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
syntaxcomplete.vim 13.0 2013-06-02 7.0 David Fishburn NF: Extended the option omni_syntax_group_include_{filetype} to accept a comma separated list of regex's rather than string.  For example, for the javascript filetype you could use:
     let g:omni_syntax_group_include_javascript = 'javascript\w\+,jquery\w\+'

NF: Some syntax files (perl.vim) use the match // syntax as a mechanism to identify keywords.  This update attempts to parse the match syntax and pull out syntax items which are at least 3 words or more.
syntaxcomplete.vim 12.0 2013-02-04 7.0 David Fishburn Version 12.0

BF: It is possible to have '-' as part of iskeyword, when checking for character ranges, tighten up the regex.  E688: More targets than List items.
                                                          
Version 11.0

BF: Corrected which characters required escaping during substitution calls.
syntaxcomplete.vim 10.0 2012-10-21 7.0 David Fishburn Cycle through all the character ranges specified in the
iskeyword option and build a list of valid word separators.

Prior to this change, only actual characters were used,
where for example ASCII "45" == "-".  If "45" were used
in iskeyword the hyphen would not be picked up.  

This introduces a new option, since the character ranges
specified could be multibyte:
    let g:omni_syntax_use_single_byte = 1

This by default will only allow single byte ASCII
characters to be added and an additional check to ensure
the character is printable (see documentation for isprint).
syntaxcomplete.vim 9.0 2012-04-28 7.3 David Fishburn Included in Vim 7.3 but you must pull from Vim sources.  This will allow you to update to it.

Version 9.0
- Add the check for cpo.
                                                            
Version 8.0
- Updated SyntaxCSyntaxGroupItems()
        - Some additional syntax items were also allowed
          on nextgroup= lines which were ignored by default.
          Now these lines are processed independently.
syntaxcomplete.vim 7.0 2010-07-29 7.0 David Fishburn Initial upload
ip used for rating: 54.82.209.152

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo