MCPcopy Index your code
hub / github.com/elm-tooling/elm-language-server

github.com/elm-tooling/elm-language-server @2.8.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.8.0 ↗ · + Follow
1,240 symbols 3,962 edges 162 files 15 documented · 1% updated 16d ago2.8.0 · 2023-12-26★ 44161 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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 git@github.com: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

Feature Description
diagnostics Provided via elm, elm-test and our own type inference and linter
formatting Provided 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
codeLenses Currently only shows if a type alias, custom type or function is exposed from that module
completions Show completions for the current file and snippets
definitions Enables you to jump to the definition of a type alias, module, custom type or function
documentSymbols Identifies all symbols in a document.
folding Let's you fold the code on certain Elm constructs
hover Shows type annotations and documentation for a type alias, module, custom type or function
linkedEditing Enables auto renaming a function name when the type annotation name is edited, or vice versa
references Lists all references to a type alias, module, custom type or function
rename Enables you to rename a type alias, module, custom type or function
workspaceSymbols Identifies all symbols in the current workspace
selectionRange Enables navigation by selectionRange (extend selection for e.g.)

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

Editor Diagnostics Formatting Code Lenses Completions Definitions Document Symbols Folding Hover Linked Editing References Rename Workspace 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.

Feature How to use it
Diagnostics :CocList diagnostics

Configure refresh with "diagnostic.refreshAfterSave": false | | Formatting | :call CocAction('format') | | CodeLenses | Requires Neovim. Add "coc.preferences.codeLens.enable": true to your coc-settings.json through :CocConfig | | Completions | On by default, see Completion with sources for customizations | |

Extension points exported contracts — how you extend this code

ICancellationToken (Interface)
(no doc) [4 implementers]
src/common/cancellation.ts
IElmPackageCache (Interface)
(no doc) [2 implementers]
src/compiler/elmPackageCache.ts
IInvokeTest (Interface)
(no doc)
test/utils/sourceParser.ts
IIndexedDBFileSystemProvider (Interface)
(no doc)
src/browser/fileSystem.ts
SyntaxNode (Interface)
(no doc)
src/typings/web-tree-sitter/index.d.ts
IElmAnalyseJsonService (Interface)
(no doc) [4 implementers]
src/common/providers/diagnostics/elmAnalyseJsonService.ts
IForest (Interface)
(no doc) [2 implementers]
src/compiler/forest.ts
IUnresolvedTest (Interface)
(no doc)
test/utils/sourceParser.ts

Core symbols most depended-on inside this repo

map
called by 223
src/common/util/sequence.ts
testDefinition
called by 167
test/definitionProviderTests/definitionProviderTestBase.ts
create
called by 151
src/browser/indexedDB.ts
set
called by 136
src/common/util/possibleImportsCache.ts
get
called by 125
src/common/util/possibleImportsCache.ts
forEach
called by 108
src/compiler/imports.ts
forEach
called by 75
src/common/util/multiMap.ts
testCodeAction
called by 66
test/codeActionTests/codeActionTestBase.ts

Shape

Method 682
Function 234
Class 182
Interface 140
Enum 2

Languages

TypeScript100%

Modules by API surface

src/compiler/typeInference.ts116 symbols
src/compiler/program.ts62 symbols
src/compiler/utils/expressionTree.ts52 symbols
src/common/util/treeUtils.ts52 symbols
src/compiler/typeChecker.ts35 symbols
src/common/providers/completionProvider.ts31 symbols
src/common/providers/diagnostics/diagnosticsProvider.ts30 symbols
src/compiler/patternMatches.ts29 symbols
src/compiler/typeExpression.ts26 symbols
src/common/util/refactorEditUtils.ts26 symbols
src/common/providers/codeActionProvider.ts25 symbols
src/compiler/forest.ts24 symbols

For agents

$ claude mcp add elm-language-server \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page