YCM+eclim VIM和eclipse的强强联合

前言

经过上次安装YCM之后,发现不能支持java语言,于是自己摸索了一下,发现eclim能够和YCM配合起来使用,而需要的操作也是很少的。

工具

  • YCM
  • eclipse
  • eclim

注意:eclim和eclipse的版本以及VIM的版本要对应,VIM 我的是7.4

下载

官方下载教程
http://eclim.org/install.html

安装

此处我们直接命令行安装

dream@love_lyy:~$ ./eclim_2.7.2.bin
Welcome to the installer for eclim 2.7.2.
# 选择eclipse的位置
Please specify the root directory of your eclipse install.
  Ex: /opt/eclipse
      /usr/local/eclipse
> /home/dream/eclipse/jee-oxygen/eclipse/
# 选择vim
Please specify the directory where you would like the eclim vimfiles installed.
If you do not want to install the vimfiles (eg: emacs-eclim users), then type: skip
  Ex: ~/.vim
      ~/.vim/bundle/eclim
> /home/dream/.vim

Choose which eclim features you would like to install.
Type the number for each feature you want to install:
  Ex (Java and Python): 0 5
  Ex (Java and Python): 0,5
  Ex (Java, Web, and C/C++): 0-2
0) Java Development
1) Web Development
2) C/C++ Development
3) Ruby Development
4) Php Development
5) Python Development
6) Scala Development
7) Groovy Development
8) Android Development
> 0,1
Eclim plugins to install:
  Java Development
  Web Development
Is this correct? (y/n): y

running: ['java', '-Djava.net.useSystemProxies=true', '-jar', '/home/dream/eclipse/jee-oxygen/eclipse/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar', '-initialize', '-debug'] ... done
running: ['java', '-Djava.net.useSystemProxies=true', '-jar', '/home/dream/eclipse/jee-oxygen/eclipse/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar', '-clean', '-refresh', '-application', 'org.eclipse.equinox.p2.garbagecollector.application'] ... done

Checking for required eclipse dependencies...
running: ['java', '-Djava.net.useSystemProxies=true', '-jar', '/home/dream/eclipse/jee-oxygen/eclipse/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar', '-application', 'org.eclipse.equinox.p2.director', '-repository', u'http://download.eclipse.org/releases/oxygen/', '-list'] ... done

Installing eclim...
running: ['java', '-Djava.net.useSystemProxies=true', '-jar', '/home/dream/eclipse/jee-oxygen/eclipse/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar', '-application', 'org.eclipse.equinox.p2.director', '-repository', 'file:///tmp/eclim-installer.d0Ms/update-site', '-installIU', 'org.eclim.feature.group'] ... done
running: ['/home/dream/.p2/pool/plugins/org.eclim_2.7.2/nailgun/configure'] ... done
running: ['make'] ... done

-----------------------------------------
The eclim install completed successfully.
You can now start the eclimd server by executing the script:
  /home/dream/eclipse/jee-oxygen/eclipse/eclimd

For more information please see the eclimd server documentation:
  http://eclim.org/eclimd.html
For information on using eclim, please visit the getting started guide:
  http://eclim.org/gettingstarted.html

启动服务器

到这就搞定了,接下来是启动服务器
由于这个启动服务器的路径较长,我们在~/.bashrc里面最后一行添加别名

alias eclimd='/home/dream/eclipse/jee-oxygen/eclipse/eclimd'

自己的eclipse目录/eclimd
这里写图片描述

检测

进入vim 在下面输入:PingEclim,出现下面的标记则视为成功
这里写图片描述
这里写图片描述

添加YCM配置

在vim配置中添加下面一句话就行了

let g:EclimCompletionMethod = 'omnifunc'

问题解决方案

1、笔者在安装的过程中PingEclim失败了
解决:可能是Vim文件安装位置选择的时候,出现了问题
2、下载安装bin文件之后,执行不了
解决:修改chmod 777,因为没有执行权限
3、无法解析的主机
解决:修改host 127.0.1.1

dream@love_lyy:~/.vim/bundle$ cat /etc/hosts -n
     1  127.0.0.1   localhost
     2  127.0.1.1   dream-Lenovo-Y430P
     3  
     4  # The following lines are desirable for IPv6 capable hosts
     5  ::1     ip6-localhost ip6-loopback
     6  fe00::0 ip6-localnet
     7  ff00::0 ip6-mcastprefix
     8  ff02::1 ip6-allnodes
     9  ff02::2 ip6-allrouters
    10  
    11  0.0.0.0 account.jetbrains.com
dream@love_lyy:~/.vim/bundle$ sudo vim /etc/hosts
sudo: 无法解析主机:love_lyy

最后附上Eclim指令集,话说VIM的简约风我很喜欢

Eclim指令集
http://www.cnblogs.com/frankM/p/4614943.html

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_41376740/article/details/80184890