Skip to content

AlexandreCarlton/eclim-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eclim-docker

Build Status

A containerised eclim, affording us Java completion in Vim without having to install eclipse or eclim.

Motivation

While YouCompleteMe (a popular Vim plugin) provides completion for many languages, it does not provide any for Java (unless eclim is installed).

Rather than having to install eclipse and eclim manually, we can instead copy across a few scripts, tweak our .vimrc and be ready to go.

Implementation

Docker

The Dockerfile provided builds eclim using the Java variant of eclipse. Since eclim requires access to multiple folders (including our workspace, which can be customised), a helper script eclimd has been provided to launch the instance for us. Unlike YouCompleteMe, this server is only launched once, albeit manually:

$ ./eclimd [--debug]

This helper script will read the values provided in ~/.eclimrc, which must also be copied into our home directory:

$ cp .eclimrc ~/.eclimrc

Finally, we need a way for our vim instance to communicate with the server (which relies on an executable provided only by eclim). The docker image build process modifies the vim function used to get the eclim command by allowing the user to set the g:EclimCommand variable:

function! eclim#client#nailgun#GetEclimCommand(home)
  " let command = a:home . 'bin/eclim'
  let command = get(g:, 'EclimCommand', a:home . 'bin/eclim')
  " ...
endfunction

Vim

Of course, we need some way to interact with the server from within Vim.

eclim provides a set of *.vim files so that we can communicate with Vim. However, these are only bundled in one place after we have run the eclim installer, so we cannot clone the repository via our favourite plugin manager.

Instead, we copy the bundled files from our docker container into a directory that can be loaded by our vim instance:

$ docker cp eclim:/usr/share/vim/vimfiles/eclim ~/.vim/plugged/eclim

We must also have vim register this using a plugin manager (in this case, vim-plug):

call plug#begin('~/.vim/plugged')
" ...
Plug 'ervandew/eclim', { 'frozen': 1, 'for': 'java' }
let g:EclimCompletionMethod = 'omnifunc'
let g:EclimCommand = '/path/to/eclim'
" ...
call plug#end()

We set frozen so that we do not try to update this plugin (since we manage this manually).

Finally, we must set the g:EclimCommand to the full path of the eclim wrapper script. This affords us access to the client executable we use to interact with our eclimd server.

Upgrading

Whenever a new version is released, we must adjust the ECLIM_VERSION variables provided in the eclimd, eclim and Makefile files.

Once we have restarted the eclimd container, we must replace the files we copied across into our bundled folder:

$ rm -rf ~/.vim/plugged/eclim
$ docker cp eclim:/usr/share/vim/vimfiles/eclim ~/.vim/plugged/eclim

Releases

No releases published

Packages

No packages published