XUtils

Elm Language Server

Language server implementation for Elm


Alternative: Compile and install from source

First, clone this repo and compile it. npm link will add elm-language-server to the PATH.

git clone git@github.com:elm-tooling/elm-language-server.git
cd elm-language-server
npm install
npm run compile
npm link

Alternative: Install with Nix

elm-languager-server and its dependencies are available in nixpkgs.

nix-env -i -A nixpkgs.elmPackages.elm-language-server

Requirements

You will need to install elm and elm-test to get all diagnostics and elm-format for formatting. Alternatively you can also just install these to your local npm package.json.

npm install -g elm elm-test elm-format

If you want to use elm-review:

npm install -g elm-review

Or use local versions from your node_modules directory, if you want to do that you need to set the paths, via the settings (e.g. set elmPath to ./node_modules/.bin/elm).

Configuration

We used to have a file called elm-tooling.json where you could specifiy "entrypoints". That’s not needed anymore – the language server finds the entrypoints automatically.

If all you had in elm-tooling.json was "entrypoints", you can safely remove that file.

Currently, no configuration at all is needed.

VSCode

Just install the elm-tooling/elm-language-client-vscode plugin from the VSCode MarketPlace

To enable linked editing in VSCode, use the setting "editor.linkedEditing": true.

Vim

There are general setup instructions and FAQ for Vim.

It’s recommended to install syntax highlighting, which also adds the required detection of elm as filetype. An example vim configuration can be found in elm-vim/vim-config-example.

LanguageClient

To use this language server with LanguageClient add the following configuration to your neovim/vim.

let g:LanguageClient_serverCommands = {
  \ 'elm': ['elm-language-server'],
  \ }

let g:LanguageClient_rootMarkers = {
  \ 'elm': ['elm.json'],
  \ }

Kakoune

Emacs

The language client is included in lsp-mode, specifically here. See specifically this section for a minimal use-package configuration for lsp-mode.

Emacs Doom

  • Uncomment lsp and elm in your configuration file .doom.d/init.el and add the +lsp feature flag to the elm layer:
lsp
(elm +lsp)
(after! lsp-ui
  (setq lsp-ui-doc-max-width 100)
  (setq lsp-ui-doc-max-height 30)
  (setq lsp-ui-sideline-show-code-actions nil)
  (setq lsp-ui-doc-enable nil)
  (setq lsp-ui-doc-show-with-cursor nil)
  (setq lsp-ui-doc-show-with-mouse nil)
  (setq lsp-lens-enable nil)
  (setq lsp-enable-symbol-highlighting nil)
  )

You can also enable or disable more features: https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off

  • Run ~/.emacs.d/bin/doom sync
Feature How to use it
Diagnostics On by default
Formatting On save
CodeLenses lsp-lens-mode, lsp-show-lens
Completions On by default
Definitions lsp-find-definition, lsp-ui-peek-find-definitions
DocumentSymbols lsp-ui-imenu
Folding +fold/open, +fold/close
Hover lsp-ui-sideline-mode, lsp-ui-doc-mode, lsp-ui-show-doc
References lsp-ui-peek-find-references, lsp-find-references
Rename lsp-rename
SelectionRange lsp-extend-selection

Sublime

  1. Install Elm Syntax Highlighting, LSP and LSP-elm from Package Control.
  2. Restart Sublime.

You should now be able to use the integrations from Sublime. You might want to read about the features offered

Awesome libraries this is based on


Articles

  • coming soon...