The integration uses ensime that was initially created for Emacs but can be used with VIM. The instructions bellow are for Arch Linux but the information should be useful for other distros or even MacOS X.
Documentation and web page for ensime is located at:
- Install packages
yaourt -S ensime-server-bin vim-ensime-git vim-scala-git vim sbt
- Add plugin to SBT
mkdir -p ~/.sbt/0.13/plugins
echo 'addSbtPlugin("org.ensime" % "sbt-ensime" % "2.0.1")' >> ~/.sbt/0.13/plugins/plugins.sbt
To make sure SBT and ensime engine uses the same scala version we need a file called ensime.sbt
in the project root directory root with the following text:
ensimeScalaVersion in ThisBuild := "2.11.11"
Change the scala version if needed.
After that we need to prepare the project to be used with ensime plugin. Fire up sbt
at the project's root dir and execute the following command. Each of this commands will download half of internet so be patient.
ensimeConfig
ensimeConfigProject
Open a scala file. It should say that is starting the server in the status line.
- Go to declaration:
:EnDeclaration
:EnDeclarationSplit
- Open documentation
:EnDocBrowse
- Autocomplete
In insert mode press
- These can be binded to keys for faster access:
noremap <Leader>sb :EnDocBrowse<CR>
noremap <Leader>sd :EnDeclaration<CR>
noremap <Leader>ss :EnDeclarationSplit<CR>
If executing sbt
you get this error:
[ERROR] Failed to construct terminal; falling back to unsupported
it means that the terminal is not supported. You can use xterm-color
instead:
TERM=xterm-color sbt