sponsor Vim development Vim logo Vim Book Ad

ttagcomplete : Context-sensitive tags-based completion and code skeletons

 script karma  Rating 0/0, Downloaded by 1463  Comments, bugs, improvements  Vim wiki

created by
Tom Link
script type
In theory, this plugin provides a framework for context-sensitive
tags-based completion and code skeletons (requires tSkeleton vimscript
#1160). I.e. the completion function checks the context and filters the
available tags accordingly. You should thus get only those tags included
in the list that are actually useful in a given context (eg because the
are valid methods of a certain class).

In practice, the context sensitivity is currently only implemented for
Java and requires a tags file for the JDK sources to be created (see the
notes on |tlib#tag#Retrieve()| for details). It also makes certain
assumption about how variable declarations look like, e.g. the
class/type name should be in the same line as the variable name; class
names start with an upper-case letter etc.

Limitation: you have to type g:ttagecho_min_chars = 1 chars before
completion is allowed.

It shouldn't be too difficult to adapt this for other statically typed
languages with formal variable declarations. As the source code isn't
actually parsed or anything, there is little chance to use this
efficiently with dynamically typed languages like ruby where the
type/class is only known at run-time.
install details
Edit the vba file and type: >

    :so %

See :help vimball for details. If you have difficulties or use vim 7.0,
please make sure, you have the current version of vimball (vimscript
#1502) installed.

This script requires tlib (vimscript #1863) to be installed.

For code skeletons, you also need tSkeletons (vimscript #1160).

Suggested setup for java (best set in ~/vimfiles/after/ftplugin/java.vim): >

    " See notes on |tlib#tag#Retrieve()|.
    let b:tlib_tags_extra = $JAVA_HOME .'/tags0'

    let b:ttagcomplete_collect='ttagcomplete#Java'

    " Call |ttagcomplete#On()| and set 'omnifunc'.

    " For code skeletons, use this:
    if exists('g:loaded_tskeleton') && g:loaded_tskeleton >= 402
        noremap <buffer> <c-x><c-g> :call ttagcomplete#CompleteSkeletons('m')<cr>
        inoremap <buffer> <c-x><c-g> <c-\><c-o>:call ttagcomplete#CompleteSkeletons('m')<cr>

Also available via git

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
ttagcomplete.vba.gz 0.1 2007-11-12 7.0 Tom Link Initial upload
ip used for rating:

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.
Vim at Github