In context 2 above, anonymous classes are not supported.
- In context 3 above, Vim will attempt to determine the methods supported by
the object.
- Vim can detect and load the Rails environment for files within a rails
project. The feature is disabled by default, to enable it add >
let g:rubycomplete_rails = 1
< to your vimrc
SYNTAX *ft-syntax-omni*
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.
To enable syntax code completion you can run: >
setlocal omnifunc=syntaxcomplete#Complete
You can automate this by placing the following in your |init.vim| (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 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
The first thing you will notice is that 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.
If you wish non-filetype syntax items to also be included, you can use a
regular expression syntax (added in version 13.0 of
autoload/syntaxcomplete.vim) to add items. Looking at the output from
":syntax list" while editing a PHP file I can see some of these entries: >
htmlArg,htmlTag,htmlTagName,javaScriptStatement,javaScriptGlobalObjects
To pick up any JavaScript and HTML keyword syntax groups while editing a PHP
file, you can use 3 different regexs, one for each language. Or you can
simply restrict the include groups to a particular value, without using
a regex string: >
let g:omni_syntax_group_include_php = 'php\w\+,javaScript\w\+,html\w\+'
let g:omni_syntax_group_include_php = 'phpFunctions,phpMethods'
<
The basic form of this variable is: >
let g:omni_syntax_group_include_{filetype} = 'regex,comma,separated'
The PHP language has an enormous number of items which it knows how to syntax
highlight. 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 use two different
methods to identify these groups. The first specifically lists the syntax
groups by name. The second uses a regular expression to identify both
syntax groups. Simply add one the following to your vimrc: >
let g:omni_syntax_group_exclude_php = 'phpCoreConstant,phpConstant'
let g:omni_syntax_group_exclude_php = 'php\w*Constant'
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} = 'regex,comma,separated'
You can create as many of these variables as you need, varying only the
filetype at the end of the variable name.
The plugin uses the isKeyword option to determine where word boundaries are
for the syntax items. For example,