Quick-tip: coding with IDE-features and focus - Eclim and NeoVim

coding
eclipse
vim
Tags: #<Tag:0x00007f0ca7940dd0> #<Tag:0x00007f0ca7940c90> #<Tag:0x00007f0ca7940b50>

#1

The art of Focus - Eclim

Eclim is a Vim (NeoVim and Emacs) bridge to get Eclipse support for your software development.

A tool to focus. Here I apply a minimal NeoVim config, primarily suitable for Java, Python and Web development.

Eclipse is a popular Java IDE, but it also supports extensions for Python (PyDev). With Eclim, among other things, we get the following extras:

  • Eclipse-based project and build management
  • IntelliSense style Code-completion
  • Code-validation

NeoVim

NeoVim re-envisions Vim with modern goals. It’s compatible to Vim, so we are not losing anything when we switch. First and foremost to a more open community.

Note that I kept the exception trace in the screenshot to indicate that this setup might not be perfectly stable. There is work to be done here.

NeoBundle

SuperTab

NeoVim config walk-through - Mac OS X

On Mac OS X the nvim folder resides at ~/.config. My assumption is you used brew already.

➜  ~ ls -al | grep nvim
lrwxr-xr-x   1 marius.ciepluch  GAMES-INT\Domain Users      12 Oct 19 11:35 .nvim -> .config/nvim

And the init.vim for Vim compatibility looks like this:

➜  .nvim cat init.vim
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc

The ~/.vimrc is simple:

" Note: Skip initialization for vim-tiny or vim-small.
if 0 | endif

if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=~/.vim/bundle/neobundle.vim/
" My Bundles here:
" Refer to |:NeoBundle-examples|.
" Note: You don't set neobundle setting in .gvimrc!
NeoBundle 'starcraftman/vim-eclim'
NeoBundle 'ervandew/supertab'
NeoBundle 'ayu-theme/ayu-vim'

call neobundle#end()

" Required:
filetype plugin indent on

" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck

set termguicolors     " enable true colors support
let ayucolor="mirage" " for mirage version of theme
colorscheme ayu
filetype plugin indent on

let g:SuperTabDefaultCompletionType = 'context'

Nothing fancy. Just keep in mind to softlink the plugin after the vim-eclim installation:

➜  .nvim ls -al | grep eclim
lrwxr-xr-x   1 marius.ciepluch  GAMES-INT\Domain Users   33 Oct 19 11:35 eclim -> /Users/marius.ciepluch/.vim/eclim

You do not have to drop files anywhere manually.

Eclim installation walk-through - Java 10, Mac OS X

Eclim 2.8.0 works with Java 10, on Mac OS X 10.14 (Mojave). But you need Xcode and accept the ToS.

➜  eclim ./eclim_2.8.0.bin
abort: error testing gcc.

-------- gcc output
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
--------

OSX users: If you see a message above that you need to accept the Xcode/iOS
license, please run:
  $ sudo xcodebuild -license accept
Then you can re-try the eclim installer.

Do not run the eclim installer as root unless you actually want the eclim
eclipse plugins and vimfiles installed in a root owned shared location.

Here is what I did:

➜  xcode-select --install
➜  sudo xcode-select --switch /Applications/Xcode.app

I repeated the installation steps:

➜  eclim ./eclim_2.8.0.bin
Welcome to the installer for eclim 2.8.0.

Please specify the path to your Eclipse.app directory.
  Ex: /Applications/Eclipse.app
      ~/Applications/Eclipse.app
> /Users/marius.ciepluch/eclipse/java-2018-09/Eclipse.app

Aaaand:

-----------------------------------------
The eclim install completed successfully.
You can now start the eclimd server by executing the script:
  /Users/marius.ciepluch/eclipse/java-2018-09/Eclipse.app/Contents/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

Run it:

➜ /Users/marius.ciepluch/eclipse/java-2018-09/Eclipse.app/Contents/Eclipse/eclimd
/usr/bin/java -version
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
JAVA_VERSION=10

Eclim basics

Create your Eclipse project for Java:

:ProjectCreate /Users/marius.ciepluch/eclipse-workspace/hello_eclim -n java

Check open projects:

:ProjectList

You can manually edit the .classpath of the project folder and Eclipse will re-load it automatically.

Eclim has lots of features.

Sumary

  • (Neo)Vim with Eclipse IntelliSese Tab-completion for Java (and other languages)
  • IDE-like project management through Vim
  • Asserted compatibility of Eclim to Java 10 and NeoVim (and Mac OS X)