lsp-elixir
Emacs lsp-mode for Elixir, using
elixir-ls server, both based on the Language Server Protocol.
Installation
-
Have packages
elixir-modeandlsp-modeinstalled. -
Clone this repository:
$ git clone https://github.com/rodrigues/lsp-elixir.git -
Add this to your emacs config:
(require 'elixir-mode)
(require 'lsp-mode)
(add-to-list 'load-path "<path to lsp-elixir>")
(require 'lsp-elixir)
(add-hook 'elixir-mode-hook #'lsp-elixir-enable)This assumes you have an executable elixirls that will run elixir-ls language server.
-
You can use the one provided in this repo, and use
elixirls-setup, also provided in this repo, to provide aelixir-lsrelease. -
You can also customize the command that is run, using
M-x customize-grouplsp-elixir. Alternatively, you can also add to emacs config:
(setq lsp-elixir-ls-command "sh")
(setq lsp-elixir-ls-args '("YOUR_PATH_TO_ELIXIRLS/language_server.sh"))Auto format on save
Add the following to your emacs config:
(add-hook 'elixir-mode-hook (lambda () (add-hook 'before-save-hook 'lsp-format-buffer)))Company integration
You'd need to install the packages company and company-lsp and add the following to your emacs config:
(require 'company-lsp)
(require 'company)
(push 'company-lsp company-backends)Flycheck integration
You need to have lsp-ui package to have flycheck integration.
(require 'lsp-ui)
(add-hook 'lsp-mode-hook 'lsp-ui-mode)
(setq lsp-ui-flycheck-enable 1)Disabling partially lsp-ui
(setq lsp-ui-COMPONENT-enable nil)COMPONENT needs to be one of: sideline, doc, peek, imenu, or flycheck.