Agent documentation index: llms.txt. Markdown versions are available for docs pages.
Download

Elixir

Elixir support is available through the Elixir extension.

Furthermore, the extension provides support for EEx (Embedded Elixir) templates and HEEx templates, a mix of HTML and EEx used by Phoenix LiveView applications.

Language Servers

The Elixir extension offers language server support for ElixirLS, Expert, Dexter, Next LS, and Lexical. By default, only ElixirLS is enabled. You can change or disable the enabled language servers in your settings (cmd-,|ctrl-,) under Languages > Elixir/EEx/HEEx or directly within your settings file.

The extension will try to find and use local binaries in your $PATH for the enabled language servers. If it cannot find them there, it will fallback to installing them for you instead.

Alternatively, you can provide your own custom binaries by passing the path and arguments in your settings file via lsp.{language-server-id}.binary.path and lsp.{language-server-id}.binary.arguments respectively; note that a few of the language servers will require specific arguments to work. For more information, read the corresponding sections below for the language servers you wish to use with a custom binary.

Some 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.

Visit the Configuring Zed guide for more information on how to edit your settings file.

Using ElixirLS

ElixirLS can accept workspace configuration options.

The following example disables Dialyzer:

  "lsp": {
    "elixir-ls": {
      "settings": {
        "dialyzerEnabled": false
      }
    }
  }

See the official list of ElixirLS configuration settings for all available options.

Using Expert

Expert is the official language server for Elixir. It is an amalgamation of ElixirLS, Next LS, and Lexical. The features it supports include: go-to-definition, go-to-references, hover docs, autocompletion, code actions, compiler diagnostics, and format on save.

Enable Expert by adding the following to your settings file:

  "languages": {
    "Elixir": {
      "language_servers": ["expert", "!elixir-ls", "!dexter", "!next-ls", "!lexical", "..."]
    },
    "EEx": {
      "language_servers": ["expert", "!elixir-ls", "!dexter", "!next-ls", "!lexical", "..."]
    },
    "HEEx": {
      "language_servers": ["expert", "!elixir-ls", "!dexter", "!next-ls", "!lexical", "..."]
    }
  }

Expert can accept workspace configuration options.

The following example sets the minimum number of characters required for a project symbol search to return results:

  "lsp": {
    "expert": {
      "settings": {
        "workspaceSymbols": {
          "minQueryLength": 0
        }
      }
    }
  }

See the Expert configuration page for all available options.

To use a custom Expert binary, add the following to your settings file:

  "lsp": {
    "expert": {
      "binary": {
        "path": "/path/to/expert",
        "arguments": ["--stdio"]
      }
    }
  }

Using Dexter

Dexter is a fast, full-featured Elixir language server optimized for large codebases. It works by parsing source files directly, no compilation required. The features it supports include: go-to-definition, go-to-references, hover docs, autocompletion, rename, and format on save.

Enable Dexter by adding the following to your settings file:

  "languages": {
    "Elixir": {
      "language_servers": ["dexter", "!expert", "!elixir-ls", "!next-ls", "!lexical", "..."]
    },
    "EEx": {
      "language_servers": ["dexter", "!expert", "!elixir-ls", "!next-ls", "!lexical", "..."]
    },
    "HEEx": {
      "language_servers": ["dexter", "!expert", "!elixir-ls", "!next-ls", "!lexical", "..."]
    }
  }

Dexter can accept initialization options.

The following example disables following defdelegate to the target function:

  "lsp": {
    "dexter": {
      "initialization_options": {
        "followDelegates": false
      }
    }
  }

See the official list of Dexter initialization settings for all available options.

To use a custom Dexter binary, add the following to your settings file:

  "lsp": {
    "dexter": {
      "binary": {
        "path": "/path/to/dexter",
        "arguments": ["lsp"]
      }
    }
  }

Using Next LS

Enable Next LS by adding the following to your settings file:

  "languages": {
    "Elixir": {
      "language_servers": ["next-ls", "!expert", "!elixir-ls", "!dexter", "!lexical", "..."]
    },
    "EEx": {
      "language_servers": ["next-ls", "!expert", "!elixir-ls", "!dexter", "!lexical", "..."]
    },
    "HEEx": {
      "language_servers": ["next-ls", "!expert", "!elixir-ls", "!dexter", "!lexical", "..."]
    }
  }

Next LS can accept initialization options.

Completions are an experimental feature within Next LS, and are enabled by default in Zed. Disable them by adding the following to your settings file:

  "lsp": {
    "next-ls": {
      "initialization_options": {
        "experimental": {
          "completions": {
            "enable": false
          }
        }
      }
    }
  }

Next LS also has an extension for Credo integration which is enabled by default. You can disable this by adding the following section to your settings file:

  "lsp": {
    "next-ls": {
      "initialization_options": {
        "extensions": {
          "credo": {
            "enable": false
          }
        }
      }
    }
  }

Next LS can also pass CLI options directly to Credo. The following example passes --min-priority high to it:

  "lsp": {
    "next-ls": {
      "initialization_options": {
        "extensions": {
          "credo": {
            "cli_options": ["--min-priority high"]
          }
        }
      }
    }
  }

See the Credo Command Line Switches page for more CLI options.

To use a custom Next LS binary, add the following to your settings file:

  "lsp": {
    "next-ls": {
      "binary": {
        "path": "/path/to/next-ls",
        "arguments": ["--stdio"]
      }
    }
  }

Using Lexical

Enable Lexical by adding the following to your settings file:

  "languages": {
    "Elixir": {
      "language_servers": ["lexical", "!expert", "!elixir-ls", "!dexter", "!next-ls", "..."]
    },
    "EEx": {
      "language_servers": ["lexical", "!expert", "!elixir-ls", "!dexter", "!next-ls", "..."]
    },
    "HEEx": {
      "language_servers": ["lexical", "!expert", "!elixir-ls", "!dexter", "!next-ls", "..."]
    }
  }

Formatting without a language server

If you prefer to work without a language server but would still like code formatting from Mix, you can configure it as an external formatter by adding the following to your settings file:

  "languages": {
    "Elixir": {
      "enable_language_server": false,
      "format_on_save": "on",
      "formatter": {
        "external": {
          "command": "mix",
          "arguments": ["format", "--stdin-filename", "{buffer_path}", "-"]
        }
      }
    },
    "EEx": {
      "enable_language_server": false,
      "format_on_save": "on",
      "formatter": {
        "external": {
          "command": "mix",
          "arguments": ["format", "--stdin-filename", "{buffer_path}", "-"]
        }
      }
    },
    "HEEx": {
      "enable_language_server": false,
      "format_on_save": "on",
      "formatter": {
        "external": {
          "command": "mix",
          "arguments": ["format", "--stdin-filename", "{buffer_path}", "-"]
        }
      }
    }
  }

Debugging

The Elixir extension also provides a debug adapter via ElixirLS. Like the language servers, the extension will try to find and use a local binary in your $PATH. If it cannot find one, it will fallback to installing it instead.

Alternatively, you can provide your own custom binary by passing the path and arguments in your settings file via dap.ElixirLS.binary and dap.ElixirLS.args respectively.

Refer to the Debugger documentation for more information on how debugging works in Zed.

Using ElixirLS

The following example allows you to debug the test files of a project:

[
  {
    "label": "Debug tests",
    "adapter": "ElixirLS",
    "request": "launch",
    "projectDir": "$ZED_WORKTREE_ROOT",
    "task": "test",
    "taskArgs": ["--trace"],
    "requireFiles": ["test/**/test_helper.exs", "test/**/*_test.exs"]
  }
]

The following example allows you to debug a Phoenix server:

[
  {
    "label": "Debug Phoenix server",
    "adapter": "ElixirLS",
    "request": "launch",
    "projectDir": "$ZED_WORKTREE_ROOT",
    "task": "phx.server",
    "debugAutoInterpretAllModules": false,
    "debugInterpretModulesPatterns": ["MyApp*", "MyAppWeb*"],
    "exitAfterTaskReturns": false
  }
]

See the official ElixirLS documentation for more information.

Using the Tailwind CSS Language Server with HEEx templates

To get all features (autocomplete, linting, and hover docs) from the Tailwind CSS language server in HEEx templates, add the following to your settings file:

  "lsp": {
    "tailwindcss-language-server": {
      "settings": {
        "includeLanguages": {
          "elixir": "html",
          "heex": "html"
        },
        "experimental": {
          "classRegex": ["class=\"([^\"]*)\"", "class='([^']*)'"]
        }
      }
    }
  }

With these settings, you will get completions for Tailwind CSS classes in HEEx templates. Examples:

<%!-- Standard class attribute --%>
<div class="flex items-center <completion here>">
  <p class="text-lg font-bold <completion here>">Hello World</p>
</div>

<%!-- With Elixir expression --%>
<div class={"flex #{@custom_class} <completion here>"}>
  Content
</div>

<%!-- With Phoenix function --%>
<div class={class_list(["flex", "items-center", "<completion here>"])}>
  Content
</div>

See also