1---
2title: Elixir
3description: "Configure Elixir language support in Zed, including language servers, formatting, and debugging."
4---
5
6# Elixir
7
8Elixir support is available through the [Elixir extension](https://github.com/zed-extensions/elixir).
9
10- Tree-sitter Grammars:
11 - [elixir-lang/tree-sitter-elixir](https://github.com/elixir-lang/tree-sitter-elixir)
12 - [phoenixframework/tree-sitter-heex](https://github.com/phoenixframework/tree-sitter-heex)
13- Language Servers:
14 - [elixir-lang/expert](https://github.com/elixir-lang/expert)
15 - [elixir-lsp/elixir-ls](https://github.com/elixir-lsp/elixir-ls)
16 - [elixir-tools/next-ls](https://github.com/elixir-tools/next-ls)
17 - [lexical-lsp/lexical](https://github.com/lexical-lsp/lexical)
18
19Furthermore, the extension provides support for [EEx](https://hexdocs.pm/eex/EEx.html) (Embedded Elixir) templates and [HEEx](https://hexdocs.pm/phoenix/components.html#heex) templates, a mix of HTML and EEx used by Phoenix LiveView applications.
20
21## Language Servers
22
23The Elixir extension offers language server support for ElixirLS, Expert, Next LS, and Lexical. By default, only ElixirLS is enabled. You can change or disable the enabled language servers in your settings ({#kb zed::OpenSettings}) under Languages > Elixir/EEx/HEEx or directly within your settings file.
24
25Some of the language servers can also accept initialization or workspace configuration options. See the sections below for an outline of what each server supports. The configuration can be passed in your settings file via `lsp.{language-server-id}.initialization_options` and `lsp.{language-server-id}.settings` respectively.
26
27Visit the [Configuring Zed](../configuring-zed.md#settings-files) guide for more information on how to edit your settings file.
28
29### Using ElixirLS
30
31ElixirLS can accept workspace configuration options.
32
33The following example disables [Dialyzer](https://github.com/elixir-lsp/elixir-ls#dialyzer-integration):
34
35```json [settings]
36 "lsp": {
37 "elixir-ls": {
38 "settings": {
39 "dialyzerEnabled": false
40 }
41 }
42 }
43```
44
45See the official list of [ElixirLS configuration settings](https://github.com/elixir-lsp/elixir-ls#elixirls-configuration-settings) for all available options.
46
47### Using Expert
48
49Enable Expert by adding the following to your settings file:
50
51```json [settings]
52 "languages": {
53 "Elixir": {
54 "language_servers": ["expert", "!elixir-ls", "!next-ls", "!lexical", "..."]
55 },
56 "EEx": {
57 "language_servers": ["expert", "!elixir-ls", "!next-ls", "!lexical", "..."]
58 },
59 "HEEx": {
60 "language_servers": ["expert", "!elixir-ls", "!next-ls", "!lexical", "..."]
61 }
62 }
63```
64
65Expert can accept workspace configuration options.
66
67The following example sets the minimum number of characters required for a project symbol search to return results:
68
69```json [settings]
70 "lsp": {
71 "expert": {
72 "settings": {
73 "workspaceSymbols": {
74 "minQueryLength": 0
75 }
76 }
77 }
78 }
79```
80
81See the [Expert configuration](https://expert-lsp.org/docs/configuration/) page for all available options.
82
83### Using Next LS
84
85Enable Next LS by adding the following to your settings file:
86
87```json [settings]
88 "languages": {
89 "Elixir": {
90 "language_servers": ["next-ls", "!expert", "!elixir-ls", "!lexical", "..."]
91 },
92 "EEx": {
93 "language_servers": ["next-ls", "!expert", "!elixir-ls", "!lexical", "..."]
94 },
95 "HEEx": {
96 "language_servers": ["next-ls", "!expert", "!elixir-ls", "!lexical", "..."]
97 }
98 }
99```
100
101Next LS can accept initialization options.
102
103Completions are an experimental feature within Next LS, they are enabled by default in Zed. Disable them by adding the following to your settings file:
104
105```json [settings]
106 "lsp": {
107 "next-ls": {
108 "initialization_options": {
109 "experimental": {
110 "completions": {
111 "enable": false
112 }
113 }
114 }
115 }
116 }
117```
118
119Next LS also has an extension for [Credo](https://hexdocs.pm/credo/overview.html) integration which is enabled by default. You can disable this by adding the following section to your settings file:
120
121```json [settings]
122 "lsp": {
123 "next-ls": {
124 "initialization_options": {
125 "extensions": {
126 "credo": {
127 "enable": false
128 }
129 }
130 }
131 }
132 }
133```
134
135Next LS can also pass CLI options directly to Credo. The following example passes `--min-priority high` to it:
136
137```json [settings]
138 "lsp": {
139 "next-ls": {
140 "initialization_options": {
141 "extensions": {
142 "credo": {
143 "cli_options": ["--min-priority high"]
144 }
145 }
146 }
147 }
148 }
149```
150
151See the [Credo Command Line Switches](https://hexdocs.pm/credo/suggest_command.html#command-line-switches) page for more CLI options.
152
153### Using Lexical
154
155Enable Lexical by adding the following to your settings file:
156
157```json [settings]
158 "languages": {
159 "Elixir": {
160 "language_servers": ["lexical", "!expert", "!elixir-ls", "!next-ls", "..."]
161 },
162 "EEx": {
163 "language_servers": ["lexical", "!expert", "!elixir-ls", "!next-ls", "..."]
164 },
165 "HEEx": {
166 "language_servers": ["lexical", "!expert", "!elixir-ls", "!next-ls", "..."]
167 }
168 }
169```
170
171## Formatting without a language server
172
173If you prefer to work without a language server but would still like code formatting from [Mix](https://hexdocs.pm/mix/Mix.html), you can configure it as an external formatter by adding the following to your settings file:
174
175```json [settings]
176 "languages": {
177 "Elixir": {
178 "enable_language_server": false,
179 "format_on_save": "on",
180 "formatter": {
181 "external": {
182 "command": "mix",
183 "arguments": ["format", "--stdin-filename", "{buffer_path}", "-"]
184 }
185 }
186 },
187 "EEx": {
188 "enable_language_server": false,
189 "format_on_save": "on",
190 "formatter": {
191 "external": {
192 "command": "mix",
193 "arguments": ["format", "--stdin-filename", "{buffer_path}", "-"]
194 }
195 }
196 },
197 "HEEx": {
198 "enable_language_server": false,
199 "format_on_save": "on",
200 "formatter": {
201 "external": {
202 "command": "mix",
203 "arguments": ["format", "--stdin-filename", "{buffer_path}", "-"]
204 }
205 }
206 }
207 }
208```
209
210## Using the Tailwind CSS Language Server with HEEx templates
211
212To get all features (autocomplete, linting, and hover docs) from the [Tailwind CSS language server](https://github.com/tailwindlabs/tailwindcss-intellisense/tree/HEAD/packages/tailwindcss-language-server#readme) in HEEx templates, add the following to your settings file:
213
214```json [settings]
215 "lsp": {
216 "tailwindcss-language-server": {
217 "settings": {
218 "includeLanguages": {
219 "elixir": "html",
220 "heex": "html"
221 },
222 "experimental": {
223 "classRegex": ["class=\"([^\"]*)\"", "class='([^']*)'"]
224 }
225 }
226 }
227 }
228```
229
230With these settings, you will get completions for Tailwind CSS classes in HEEx templates. Examples:
231
232```heex
233<%!-- Standard class attribute --%>
234<div class="flex items-center <completion here>">
235 <p class="text-lg font-bold <completion here>">Hello World</p>
236</div>
237
238<%!-- With Elixir expression --%>
239<div class={"flex #{@custom_class} <completion here>"}>
240 Content
241</div>
242
243<%!-- With Phoenix function --%>
244<div class={class_list(["flex", "items-center", "<completion here>"])}>
245 Content
246</div>
247```
248
249## See also
250
251- [Erlang](./erlang.md)
252- [Gleam](./gleam.md)