The language server for Elixir that just works. 😎
Still in heavy development, currently supporting the following features:
- Compiler Diagnostics
- Code Formatting
- Workspace Symbols
- Document Symbols
- Go To Definition
- Workspace Folders
- Find References
- Extensions
- Credo
- Hover
- Completions †‡
†- denotes an experimental feature, which can be toggled on/off.
‡ - denotes a partially implemented feature.
Currently it supports 1.13 and newer, but this could be lowered potentially.
- Neovim: elixir-tools.nvim
- VSCode: elixir-tools.vscode
-
Emacs - eglot
(require 'eglot) (add-to-list 'exec-path "path/to/next-ls/bin/") (with-eval-after-load 'eglot (add-to-list 'eglot-server-programs `((elixir-ts-mode heex-ts-mode elixir-mode) . ("nextls" "--stdio=true")))) (add-hook 'elixir-mode-hook 'eglot-ensure) (add-hook 'elixir-ts-mode-hook 'eglot-ensure) (add-hook 'heex-ts-mode-hook 'eglot-ensure)
-
Doom Emacs - eglot
-
Install
nextls
somewhere on yourPATH
-
Enable
lsp
with eglot in$DOOMDIR/init.el
- ;; lsp + (lsp +eglot)
-
Enable the Elixir layer with lsp in
$DOOMDIR/init.el
- ;; elixir + (elixir +lsp)
-
Configure the eglot client in
$DOOMDIR/config.el
(set-eglot-client! 'elixir-mode '("nextls" "--stdio"))
-
-
Helix
Add the following config to your
~/.config/helix/languages.toml
.[[language]] name = "elixir" scope = "source.elixir" language-server = { command = "path/to/next-ls", args = ["--stdio=true"] }
If you are using the latest git version of helix use this:
[[language]] name = "elixir" scope = "source.elixir" language-servers = ["nextls"] [language-server.nextls] command = "path/to/next-ls" args = ["--stdio=true"]
-
Zed
Add the following settings (tested with Zed Preview v0.106.2):
{ "elixir": { "lsp": "next_ls" } }
If you would like to set initialization options, for example to enable an experimental feature, you can add the following to your settings.json file.
Note the different between snake case and kebab case between the third and sixth lines.
{ "elixir": { "lsp": "next_ls" }, "lsp": { "next-ls": { "initialization_options": { "experimental": { "completions": { "enable": true } } } } } }
-
Vim - prabirshrestha/vim-lsp
Install Next LS somewhere on your PATH, or instead use an absolute path to the Next LS executable.
if executable('nextls') au User lsp_setup call lsp#register_server({ \ 'name': 'next_ls', \ 'cmd': ["nextls", "--stdio"], \ 'root_uri':{server_info->lsp#utils#path_to_uri( \ lsp#utils#find_nearest_parent_file_directory( \ lsp#utils#get_buffer_path(), \ ['mix.exs'] \ ))}, \ 'allowlist': ['elixir'], \ }) endif
-
Vim - yegappan/lsp
yegappan/lsp - requires Vim 9
Install Next LS somewhere on your PATH, or instead use an absolute path to the Next LS executable.
let lspServers = [#{ \ name: 'next_ls', \ filetype: ['elixir'], \ path: 'nextls', \ args: ['--stdio'], \ rootSearchFiles: ['mix.exs'] \ }] autocmd VimEnter * call LspAddServer(lspServers)
-
Vim - ALE
Valid once dense-analysis/ale#4626 is merged.
Install Next LS somewhere on your PATH, or instead use an absolute path to the Next LS executable.
let g:ale_elixir_next_ls_executable = 'path/to/nextls' " optional, if you want to change the executable that is used let g:ale_linters = {'elixir': ['next_ls']}
The preferred way to use Next LS is through one of the supported editor extensions.
The extension will automatically install the latest version of Next LS and will be kept up to date automatically.
brew install elixir-tools/tap/next-ls
nix profile install github:elixir-tools/next-ls
If you need to install Next LS on it's own, you can download the appropriate executable from our GitHub Releases.
These executables are created with Burrito and are completely standalone, except you'll still need Elixir and OTP installed in order for it to start a runtime for your application code.
If you are making changes to Next LS and want to test them locally you can run bin/start --port 9000
to start the language server (port 9000 is just an example, you can use any port that you want as long as it is not being used already).
Then you can configure your editor to connect to Next LS using that port.
{
nextls = {enable = true, port = 9000}
}
Visual Studio Code
{
"elixir-tools.nextLS.adapter": "tcp",
"elixir-tools.nextLS.port": 9000
}
Next LS creates an .elixir-tools
hidden directory in your project, but it will be automatically ignored by git
.
pgrep -fl epmd
If epmd
is not running, you might need to start it or ensure it starts automatically with your system. You can do this by running epmd -daemon
.
ldd --version
This will show the glibc
version at the top. Ensure it's 2.34 or higher.
macOS doesn't use glibc
; it uses the Darwin C Library. Hence, this step is not applicable.
Windows does not use glibc
. If you're using a subsystem or tool that needs it, ensure it's updated.
To ensure that elixir
is in your PATH
, open Visual Studio Code from the terminal using the command-line tools.
Start the language server in TCP mode and connect to it with your editor, as described above.
Both extensions install the Next LS executable to ~/.cache/elixir-tools/nextls/bin/nextls
, so you can start the server with ~/.cache/elixir-tools/nextls/bin/nextls --port 9000
.
Sometimes, the firewall can interfere with epmd
and each Erlang node's ability to cluster. If you face connection issues, you might try turning off the firewall temporarily to see if it resolves the issue.
This is usually a problem on macOS, as you should see a popup asking if beam
and epmd
can accept incoming connections (which you should click "yes").
In future version, we plan to sign and notarize the darwin binaries, which should avoid this popups and make this a non-issue.