Vim, the editor of the Beast, has got an Ensime plugin to convert your preferred text editor
into a Java/Scala IDE. It's not time for half measures and ensime-vim
aims at
becoming your go-to option to easily edit your source code in an efficient and fast way.
Just follow the next steps and you'll be able to get ensime-vim
in your vim in the blink of an eye.
First, you need to install the websocket-client
python package:
$ sudo pip install websocket-client
Then, export your $BROWSER
variable, for example in your .bashrc
:
$ export BROWSER=firefox
If this variable is pointing to a script, make sure the shebang line (#!/bin/bash
or whatever)
is on top of the file. Otherwise, it won't be executed.
You also need the ensime-sbt plugin. You can
install it with a pretty one-liner (make sure 0.3.3
is the latest released version):
$ echo 'addSbtPlugin("org.ensime" % "ensime-sbt" % "0.3.3")' \
>> ~/.sbt/0.13/plugins/plugins.sbt
In order to install this plugin in your vim, you have two de facto options. Other plugin managers should properly installed this plugin but their installation is not documented here.
Plugins | Your .{n}vimrc |
---|---|
Vim-Plug | Plug 'ensime/ensime-vim' |
Vundle | Plugin 'ensime/ensime-vim' |
After this, update your configuration and install them. With vim-plug
this is done
by executing :PlugInstall
followed by :UpdateRemotePlugins
. With Vundle
run :PluginInstall
.
If you happen to use neovim, remember that you must install the neovim python module. Execute:
$ pip install neovim
The ensime-server
needs to know a little bit about your project. Hence you must generate an
.ensime
file for any project in which you would like to use ensime-vim
. The most easiest way to
do this is by executing in your root project folder:
$ sbt gen-ensime
Afterwards, you are done and ready to enjoy the most of this project. If you want to contribute, please check this.
Under neovim, for all commands except autocomplete, events are only handled when you move your cursor
(that is the CursorMoved
event). A well-known vim constraint is that it doesn't allow a plugin to
have a real timer executing functions. In order to mimic this behavior, we use the CursorHold
event
and the updatetime
vim global variable. The first one is triggered after a certain duration of time
specified in updatetime
in milliseconds. Ensime-vim
sets this value to 1 second by default.
If this is causing any problem with other plugins like easytags
, please consider proposing to that
plugin to allow low updatetime
s times or open an issue to explain your problem. More information
about timers in vim can be found here.
This plugin is implemented on neovim
as an rplugin, bringing a better and faster user experience.
For people using vim
, ensime-vim
will be slower. The benefit of using neovim
instead
is to make use of the new remote plugin architecture, which allows better speedups by using a
client-server approach for plugin developments.
Refactorings are on their way! Right now only the rename refactoring has been implemented and it's
not completed (only local renaming works). There are some issues with the ensime-server
that
hopefully will be fixed in the following weeks. When that's finished and the new API is polished,
ensime-vim
will get all the possible refactorings implemented.
Check the vim documentation of the plugin, which is just here. It's also available
from vim
by running:
:help ensime-vim
All the logic of the plugin is under ensime_shared. Take a peek into it and start contributing!
Before, we were using the great neo2vim plugin made by yazgoo. Now, this is
no longer necessary as all the logic has been centralized and any change applied to ensime_shared
will be propagated
to both vim
and neovim
, helping readability and maintainability.
If you need to touch specific text editors configuration, especially if you register/unregister functions, check which
files are used by vim
and neovim
.
Vim-specific files | Neovim specific files |
---|---|
Vim ensime folder | Neovim rplugin |
Vim plugin folder |
All merges should be done on the dev
branch before being merged onto master.
It is possible to register callbacks and send events to ensime. Check this plugin example.
Would you like to have a new feature? Are you missing something? Do you need a dog? Contact us, open an issue and tell us your request/problem. We may help you!
The reference launch script is here (only works on Linux but should be adaptable to OS X, but you don't probably need it).