2012-05-07 25 views
5

我在Mac OS X 10.7下工作。我得到javacomplete病菌的帮助下工作,但它只有完成了JDK类,而不是我创建的类。当试图全方位完成我的一个对象时,我得到'未找到模式'。这是否仅限于JDK类?如果没有,任何人都可以描述他们的配置。如何使用javacomplete完成用户定义的类方法

顺便说一句,我已经尝试创建ctags但它没有与javacomplete一起工作。但是,ctrl-x ctrl-]适用于创建ctags。

回答

0

我已经使用了javacomplete插件以及supertab,并且我发现启用方法完成的easiet方法是使用另一个名为easytags.vim的插件,它可以在您编译类时自动创建标签。它从内存中提供了用户定义的类和方法完成。

1

您需要为您的源设置类路径。

从javacomplete文档:

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 

我加入以下到我的.vimrc 自动完成机器人项目:

我注意到
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 

两件事情:

  • javacomplete#AddClassPath不支持jar个文件,即使文档说这样
  • ,我不得不删除我的标签文件,以获得完成工作
0

安装Vim插件,你以后都将这些行添加到.vimrc

" Only do this part when compiled with support for autocommands. 
if has("autocmd") 
    autocmd Filetype java setlocal omnifunc=javacomplete#Complete 
endif 

我也无法使用现有标记文件(由ctags创建)来处理它。如上所述,一种解决方法是取消设置.vimrc中的vim选项tags。但这不是我的选择。 我只是操纵javacomplete.vim来“忽略”标签文件。

补丁程序如下:

 
--- autoload/javacomplete.vim 2011-01-30 21:33:46.000000000 +0100 
+++ /home/kndl/.vim/autoload/javacomplete.vim 2015-02-12 20:46:48.227465321 +0100 
@@ -2510,7 +2510,8 @@ 
fu! s:GetClassInfoFromSource(class, filename) 
    let ci = {} 
    if len(tagfiles()) > 0 
- let ci = s:DoGetClassInfoFromTags(a:class) 
+ " kndl: Deactivate ctags feature as this does not work. It seems that I am unable to build an accepted tags file. 
+ "let ci = s:DoGetClassInfoFromTags(a:class) 
    endif 

    if empty(ci) 
相关问题