Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to complete user defined class methods using javacomplete

Tags:

java

vim

editor

I am working under Mac OS X 10.7. I got javacomplete working with the help of pathogen, but it only completes JDK classes, not the classes I've created. When trying to omni-complete one of my objects I'm getting 'Pattern not found'. Is this really limited to JDK classes? If not, can anybody describe their config.

BTW, I've tried created ctags but it didn't work with javacomplete either. However, ctrl-x ctrl-] works fine with ctags created.

like image 832
arapat Avatar asked Nov 13 '22 05:11

arapat


1 Answers

You need to set up the class path for your sources.

From the javacomplete documentation:

3. Set classpath using the following function: >
    javacomplete#AddClassPath('jarfile_or_classes_path')
    javacomplete#DelClassPath('jarfile_or_classes_path')
    javacomplete#SetClassPath('semicolon_separated_string')

    Another two variables will be used if they are existing:
        |g:java_classpath|  global classpath
        |b:classpath|       associated with current buffer

I have added the following to my .vimrc to auto-complete android projects:

if filereadable('AndroidManifest.xml')
    call javacomplete#SetClassPath('/home/tidbeck/android/sdk/android-sdk-linux_x86/platforms/android-17/android.jar:libs/android-support-v4.jar:bin/classes')
    call javacomplete#SetSourcePath('src')
endif

Two things that I noticed:

  • javacomplete#AddClassPath does not support jar files even though the docs say so
  • I had to remove my tags file to get completion to working
like image 194
tidbeck Avatar answered Nov 16 '22 03:11

tidbeck