Skip to content

Instantly share code, notes, and snippets.

@jfontan
Created November 8, 2017 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfontan/f743b6d26bda3c5aed67f920e1a7123e to your computer and use it in GitHub Desktop.
Save jfontan/f743b6d26bda3c5aed67f920e1a7123e to your computer and use it in GitHub Desktop.

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:

http://ensime.org/

Installation

  • 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

Prepare scala project

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

Usage

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>

Errors

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment