@elm-tooling/elm-language-server

中文文档
2.10.0发布于 2026/10/02MITTypeScriptES Module构建来源已验证近 30 天下载 4863

Implementation of an elm language server in node.

原始使用文档
文档目录16 节
  1. Installation
  2. Alternative: Compile and install from source
  3. Alternative: Install with Nix
  4. Requirements
  5. Configuration
  6. Linting
  7. Features
  8. Server Settings
  9. Editor Support
  10. VSCode
  11. Vim
  12. Kakoune
  13. Emacs
  14. Sublime
  15. Awesome libraries this is based on
  16. Contributing

elm-language-server

Matrix Build Status Open in Visual Studio Code

Packaging status

This is the language server implementation for the Elm programming language.

Table of Contents

Installation

Note for VSCode users: The plugin contains the language-server. No installation necessary.

The server can be installed via npm (or from source).

npm install -g @elm-tooling/elm-language-server

Then, you should be able to run the language server with the following command:

elm-language-server

You might need to use this, if your using powershell:

elm-language-server.cmd

Follow the instructions below to integrate the language server into your editor.

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 [email protected]: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.

Linting

The Elm Language Server has built-in support for linting. Check out the documentation for configuring the linter.

Features

Supports Elm 0.19 and up

FeatureDescription
diagnosticsProvided via elm, elm-test and our own type inference and linter
formattingProvided via elm-format and post-processed to only return a diff of changes. This way it should not be as intrusive as running elm-format normal
codeLensesCurrently only shows if a type alias, custom type or function is exposed from that module
completionsShow completions for the current file and snippets
definitionsEnables you to jump to the definition of a type alias, module, custom type or function
documentSymbolsIdentifies all symbols in a document.
foldingLet's you fold the code on certain Elm constructs
hoverShows type annotations and documentation for a type alias, module, custom type or function
linkedEditingEnables auto renaming a function name when the type annotation name is edited, or vice versa
referencesLists all references to a type alias, module, custom type or function
renameEnables you to rename a type alias, module, custom type or function
workspaceSymbolsIdentifies all symbols in the current workspace
selectionRangeEnables navigation by selectionRange (extend selection for e.g.)

Parameter hovers include a link to the inferred type's declaration when the client advertises Markdown hover support. This includes function, anonymous function, and case-pattern parameters. Resolution prefers a type alias over its underlying type; unnamed or unresolved types have no link. Links use document URIs with one-based #L line fragments, without editor-specific commands. Clients must support opening the document URI, and exact-line navigation depends on the client because LSP does not standardize these fragments.

Virtual Elm package files use the LSP 3.18 workspace/textDocumentContent request when the client advertises support. Implementations include vscode-languageclient 10, coc.nvim, and Sublime LSP 2.13. Elm clients that do not support the standard request can continue to use elm/provideFileContents during the migration.

Server Settings

This server contributes the following settings:

  • elmLS.trace.server: Enable/disable trace logging of client and server communication
  • elmLS.elmPath: The path to your elm executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder.
  • elmLS.elmReviewPath: The path to your elm-review executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder.
  • elmLS.elmReviewDiagnostics: Configure linting diagnostics from elm-review. Possible values: off, warning, error.
  • elmLS.elmFormatPath: The path to your elm-format executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder.
  • elmLS.elmTestPath: The path to your elm-test executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder.
  • elmLS.disableElmLSDiagnostics: Enable/Disable linting diagnostics from the language server.
  • elmLS.skipInstallPackageConfirmation: Skip confirmation for the Install Package code action.
  • elmLS.onlyUpdateDiagnosticsOnSave: Only update compiler diagnostics on save, not on document change.

Settings may need a restart to be applied.

Editor Support

EditorDiagnosticsFormattingCode LensesCompletionsDefinitionsDocument SymbolsFoldingHoverLinked EditingReferencesRenameWorkspace Symbols
VSCode:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
VIM CoC:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::x::heavy_check_mark::heavy_check_mark::heavy_check_mark:
VIM LanguageClient:heavy_check_mark::heavy_check_mark::grey_question::heavy_check_mark::grey_question::grey_question::grey_question::grey_question::x::grey_question::grey_question::grey_question:
VIM ALE:heavy_check_mark::x::x::grey_question::heavy_check_mark::x::x::heavy_check_mark::x::heavy_check_mark::x::heavy_check_mark:
Kakoune:heavy_check_mark::heavy_check_mark::grey_question::heavy_check_mark::heavy_check_mark::heavy_check_mark::grey_question::heavy_check_mark::x::heavy_check_mark::heavy_check_mark::grey_question:
Emacs:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::grey_question::heavy_check_mark::x::heavy_check_mark::heavy_check_mark::heavy_check_mark:
Sublime:heavy_check_mark::heavy_check_mark::x::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::x::heavy_check_mark::heavy_check_mark::heavy_check_mark:

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.

coc.nvim

To enable support with coc.nvim, run :CocConfig and add the language server config below.

If needed, you can set the paths to elm, elm-test, elm-review and elm-format with the elmPath, elmTestPath, elmReviewPath and elmFormatPath variables.

{
  "languageserver": {
    "elmLS": {
      "command": "elm-language-server",
      "filetypes": ["elm"],
      "rootPatterns": ["elm.json"]
    }
  },
  // If you use neovim you can enable codelenses with this
  "codeLens.enable": true
}

Much of this is covered in the Example vim configuration section in Coc's readme.

FeatureHow to use it
Diagnostics:CocList diagnostics
Configure refresh with "diagnostic.refreshAfterSave": false
Formatting:call CocAction('format')
CodeLensesRequires Neovim. Add "coc.preferences.codeLens.enable": true to your coc-settings.json through :CocConfig
CompletionsOn by default, see Completion with sources for customizations
DefinitionsProvided as <Plug> mapping so that you can set it yourself, e.g.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
DocumentSymbols:CocList outline
FoldingYou must set foldmethod=manual in your vimrc, one set Coc will handle folding with the usual commands, zc, zo, etc
Hover:call CocAction('doHover')
ReferencesProvided as a <Plug> mapping, e.g. nmap <silent> gr <Plug>(coc-references)
RenameProvided as a <Plug> mapping, e.g. nmap <leader>rn <Plug>(coc-rename)
Workspace Symbols:CocList symbols

ALE

ALE contains the elm_ls linter.

let g:ale_linters = { 'elm': ['elm_ls'] }

If needed, you can set the paths to elm, elm-test, elm-review and elm-format. The configuration can be found here

let g:ale_elm_ls_use_global = 1
let g:ale_elm_ls_executable = "/path/to/elm-language-server"
let g:ale_elm_ls_elm_path = "/path/to/elm"
let g:ale_elm_ls_elm_format_path = "/path/to/elm-format"
let g:ale_elm_ls_elm_test_path = "/path/to/elm-test"
FeatureHow to use it
Diagnostics:ALENext/:ALEPrevious
Configure refresh with let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
FormattingALE doesn't currently support this through the language server integration, but elm-format is a supported ALE Fixer
CodeLensesNot currently supported
CompletionsOn by default, see :h ale-completion for more info
Definitions:ALEGoToDefinition, :ALEGoToTypeDefinition, see :h ale-go-to-definition and :h ale-go-to-type-definition
DocumentSymbolsOnly workspace symbols are currently supported
FoldingNot currently supported
Hover:ALEHover
References:ALEFindReferences
RenameNot currently supported
Workspace Symbols:ALESymbolSearch <query>

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

kak-lsp

First install kak-lsp, and enable it in the kakrc. One way would be to add these lines to your .config/kak/kakrc file:

eval %sh{kak-lsp --kakoune -s $kak_session}
lsp-enable

Then, assuming installation of elm-language-server, elm-format, and elm-test, add this section to your .config/kak-lsp/kak-lsp.toml file:

[language.elm]
filetypes = ["elm"]
roots = ["elm.json"]
command = "elm-language-server"

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
FeatureHow to use it
DiagnosticsOn by default
FormattingOn save
CodeLenseslsp-lens-mode, lsp-show-lens
CompletionsOn by default
Definitionslsp-find-definition, lsp-ui-peek-find-definitions
DocumentSymbolslsp-ui-imenu
Folding+fold/open, +fold/close
Hoverlsp-ui-sideline-mode, lsp-ui-doc-mode, lsp-ui-show-doc
Referenceslsp-ui-peek-find-references, lsp-find-references
Renamelsp-rename
SelectionRangelsp-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

Contributing

Please do :) As the best thing about a language server is that multiple clients will improve that way.

版本与发布记录

@elm-tooling/elm-language-server 共发布 58 个版本,首次发布于 2019/06/08;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.10.0latest2026/10/021 个月前
2.8.02023/12/272 年前
2.7.32023/09/253 年前
2.7.12023/08/303 年前
2.7.02023/05/043 年前
2.6.02022/12/223 年前

关于 @elm-tooling/elm-language-server 的常见问题

@elm-tooling/elm-language-server 是什么?

Implementation of an elm language server in node.

如何安装 @elm-tooling/elm-language-server?

在项目目录运行 npm install @elm-tooling/elm-language-server,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 elm-language-server,可以用 npx elm-language-server 直接运行。

@elm-tooling/elm-language-server 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@elm-tooling/elm-language-server 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@elm-tooling/elm-language-server 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.17.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@elm-tooling/elm-language-server 可以商用吗?

@elm-tooling/elm-language-server 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@elm-tooling/elm-language-server 的下载量有多少?

根据 npm 官方下载统计,@elm-tooling/elm-language-server 在 2026/10/14 – 2026/11/12 这 30 天内被下载 4,863 次,日均约 162 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@elm-tooling/elm-language-server 还在维护吗?

最新版本 2.10.0 发布于 2026/10/02(1 个月前);至今共发布 58 个版本,其中过去 12 个月发布了 1 个;首次发布于 2019/06/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。