# Elm language server and a new VSCode Plugin

**URL:** <https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891>\
**Category:** Show and Tell\
**Created:** [June 27, 2019, 3:19pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891 "2019-06-27T15:19:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![razze](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/razze/32/1650_2.png) [@razze](https://discourse.elm-lang.org/u/razze)\
**Post date:** [June 27, 2019, 3:19pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/1 "2019-06-27T15:19:06Z")

</div>

Hey everybody,

after finishing the [Elm-tree-sitter implementation](https://discourse.elm-lang.org/t/elm-tree-sitter-implementation/3459) in April  
I set off to build a language server integration for the elm community based on that.

At the moment, there are instructions for:

- VSCode
- VIM
- Kakoune
- Emacs

More are hopefully coming, as soon as people think it’s useful.

So what can it do? (I’m using VSCode for this example)

 ![elm-ls](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/a/a49715f742d310b3d0fbaf5aa2d79345eae9a263.gif)

Those are just some of the features, here is a list of most things that are implemented:

| Feature | Description |
| --- | --- |
| Diagnostics | Provided via `elm make`, `elm-test` and `elm-analyse` |
| 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 |
| 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 |

So please see the project pages on github:

- [https://github.com/elm-tooling/elm-language-server](https://github.com/elm-tooling/elm-language-server)
- [https://github.com/elm-tooling/elm-language-client-vscode](https://github.com/elm-tooling/elm-language-client-vscode)

And feel free to test (it will need a lot of testing) and contribute in any way. That being code, issues or maybe graphics. 🙂  
Or maybe join the #elm-language-server channel on the elm slack.

I had a lot of help by some lovely people like @hpate, @buinauskas, @andys8 and various others.

Let’s build on this and make it even better!

---

<div class="post-metadata">

**Author:** ![razze](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/razze/32/1650_2.png) [@razze](https://discourse.elm-lang.org/u/razze)\
**Post date:** [June 28, 2019, 7:36am UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/2 "2019-06-28T07:36:53Z")

</div>

One thing that I’m actively looking for is what features people are missing and which would bring the biggest benefits. So if you got ideas/opinions about that feel free to reach out here, via the issue tracker or slack.

---

<div class="post-metadata">

**Author:** ![brasilikum](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/brasilikum/32/524_2.png) [@brasilikum](https://discourse.elm-lang.org/u/brasilikum)\
**Post date:** [June 28, 2019, 8:31pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/3 "2019-06-28T20:31:19Z")

</div>

> Improving your Elm experience since 2019

😂 😂 😂

---

<div class="post-metadata">

**Author:** ![gavares](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@gavares](https://discourse.elm-lang.org/u/gavares)\
**Post date:** [June 29, 2019, 5:40pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/4 "2019-06-29T17:40:03Z")

</div>

Great work. Thanks for creating this.

I’ve installed the plugin and am using it currently but I cannot seem to remove an elm-analyse error on line 1 of Main.elm that says:

```
Error parsing file elm-analyse(1)

```

Running `elm-analyse --serve` directly from the project root seems to have no problems with my `elm-analyse.json` file.

I attempted fixing any errors in the file initially and ended up deleting the file altogether but the error persists even after restarting VSCode.

Happy to open a github issue but thought I might ask here first.

---

<div class="post-metadata">

**Author:** ![razze](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/razze/32/1650_2.png) [@razze](https://discourse.elm-lang.org/u/razze)\
**Post date:** [June 30, 2019, 2:50pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/5 "2019-06-30T14:50:11Z")

</div>

Interesting, not sure how we can reproduce that best. So I would think, moving this to a github issue would be the right thing to do. Or even the slack channel?

---

<div class="post-metadata">

**Author:** ![opvasger](https://avatars.discourse-cdn.com/v4/letter/o/8e8cbc/32.png) [@opvasger](https://discourse.elm-lang.org/u/opvasger)\
**Post date:** [June 30, 2019, 3:54pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/6 "2019-06-30T15:54:50Z")

</div>

Nesting elm projects (like benchmarks and tests) seems to interfere with the plugin. For examle: I have an inner projects that utilizes ports, but because the outer project is a package, I’m getting warnings. A workaround I’ve used was to open the inner projects in a separate window. I could perhaps instead flatten my repo in a separate folder for each project.

Haven’t had any other issues so far ☀ it’s really great!

---

<div class="post-metadata">

**Author:** ![razze](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/razze/32/1650_2.png) [@razze](https://discourse.elm-lang.org/u/razze)\
**Post date:** [June 30, 2019, 4:22pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/7 "2019-06-30T16:22:11Z")

</div>

The logic for that is here. [https://github.com/elm-tooling/elm-language-client-vscode/blob/master/client/src/extension.ts#L52-L70](https://github.com/elm-tooling/elm-language-client-vscode/blob/master/client/src/extension.ts#L52-L70)

If we can find a way to autodetect all needed elm.json files that would be great. But there might be elm.json files in node\_modules or even elm-stuff?  
Well I’m filtering out node\_modules here [https://github.com/elm-tooling/elm-language-client-vscode/blob/master/client/src/extension.ts#L27](https://github.com/elm-tooling/elm-language-client-vscode/blob/master/client/src/extension.ts#L27) so we might be able to get away with a more generous logic.

---

<div class="post-metadata">

**Author:** ![ChrisWellsWood](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/chriswellswood/32/5293_2.png) [@ChrisWellsWood](https://discourse.elm-lang.org/u/ChrisWellsWood)\
**Post date:** [July 2, 2019, 5:12pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/8 "2019-07-02T17:12:57Z")

</div>

Using this with Vim and Coc and it’s excellent, with a bit of tweaking it’s buttery smooth. I didn’t realise how much I missed “gd” working properly! Good job.

---

<div class="post-metadata">

**Author:** ![andys8](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/andys8/32/280_2.png) [@andys8](https://discourse.elm-lang.org/u/andys8)\
**Post date:** [July 2, 2019, 6:55pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/9 "2019-07-02T18:55:53Z")

</div>

So awesome to have this. I’m sure Elm and its community will benefit a lot from proper tooling.

---

<div class="post-metadata">

**Author:** ![allanderek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/allanderek/32/1360_2.png) [@allanderek](https://discourse.elm-lang.org/u/allanderek)\
**Post date:** [July 3, 2019, 12:06pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/10 "2019-07-03T12:06:53Z")

</div>

Hi, I think this is some cracking work.

One feature I use a lot is ‘symbols’, so if you hit Ctrl+Shift+O you can then go to a definition in a similar way to Ctrl+g is goto line. As you type it shows you completions.

I know there is ‘go to definition’, but that requires you to be near a call site, sometimes I know for example I want to add a new message so I do `Ctrl+Shift+O Msg` and I’m at the definition for the `Msg` type.

---

<div class="post-metadata">

**Author:** ![miniBill](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/minibill/32/800_2.png) [@miniBill](https://discourse.elm-lang.org/u/miniBill)\
**Post date:** [July 3, 2019, 1:44pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/11 "2019-07-03T13:44:03Z")

</div>

Unfortunately I cannot try it as it won’t work on NixOS (hit me up on Slack if you want to talk about possible solutions), but I think having a Language Server is definitely a must have for any serious language, so kudos for the important work!

---

<div class="post-metadata">

**Author:** ![razze](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/razze/32/1650_2.png) [@razze](https://discourse.elm-lang.org/u/razze)\
**Post date:** [July 3, 2019, 4:34pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/12 "2019-07-03T16:34:50Z")

</div>

That should already work, both for symbols in the same file and global (as in the same project scope). Workspace wide might not work.

---

<div class="post-metadata">

**Author:** ![allanderek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/allanderek/32/1360_2.png) [@allanderek](https://discourse.elm-lang.org/u/allanderek)\
**Post date:** [July 4, 2019, 7:25am UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/13 "2019-07-04T07:25:54Z")

</div>

Okay great, thanks, I will investigate why that didn’t seem to work for me and report back.

---

<div class="post-metadata">

**Author:** ![allanderek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/allanderek/32/1360_2.png) [@allanderek](https://discourse.elm-lang.org/u/allanderek)\
**Post date:** [July 4, 2019, 7:33am UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/14 "2019-07-04T07:33:39Z")

</div>

Still not working for me, the only error I can see in the output is:  
`command 'elmLS.elmAnalyseFixer' already exists`

When I do `Ctrl+Shift+O` it tells me `No symbols found`.

---

<div class="post-metadata">

**Author:** ![razze](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/razze/32/1650_2.png) [@razze](https://discourse.elm-lang.org/u/razze)\
**Post date:** [July 4, 2019, 12:57pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/15 "2019-07-04T12:57:09Z")

</div>

Can you try with [https://github.com/rtfeldman/elm-spa-example](https://github.com/rtfeldman/elm-spa-example) ?  
Do you get an outline in the outline view?

While trying to repro this, I found a file that doesn’t seem to lint, that also had no symbols. Will investigate later.

---

<div class="post-metadata">

**Author:** ![allanderek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/allanderek/32/1360_2.png) [@allanderek](https://discourse.elm-lang.org/u/allanderek)\
**Post date:** [July 4, 2019, 1:20pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/16 "2019-07-04T13:20:46Z")

</div>

A ha, yes it **does** work for `elm-spa-example’, apologies I just tried it on the code I was working on and perhaps that has a file that isn’t linting or something. I will investigate further and report back.

In the folder that isn’t working, there is no outline.

---

<div class="post-metadata">

**Author:** ![allanderek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/allanderek/32/1360_2.png) [@allanderek](https://discourse.elm-lang.org/u/allanderek)\
**Post date:** [July 4, 2019, 1:49pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/17 "2019-07-04T13:49:05Z")

</div>

So the ‘folder’ I had open in VSCode actually had two elm projects, let’s call them A and B, and hence two elm.json files.  
The outline + symbols were not working in the files in project B that I was working on.  
It turns out, they _were_ working in project A (I just hadn’t noticed because I wasn’t working on that project).

If I close the containing folder and open a sub folder that contains project B but not A, then the outline+symbols works for me.

So in summary, the issue seemed to be caused by having a folder open (in the VSCode sense) which contained more than one elm project. It didn’t seem related to having a non-linting elm file (I don’t seem to have one in either project).

Thanks.

---

<div class="post-metadata">

**Author:** ![razze](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/razze/32/1650_2.png) [@razze](https://discourse.elm-lang.org/u/razze)\
**Post date:** [July 4, 2019, 2:10pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/18 "2019-07-04T14:10:59Z")

</div>

Hrm, that might actually be an upstream bug, can you create an issue on github, so that I can track this? I will probably need to report that to the [https://github.com/Microsoft/vscode-languageserver-node](https://github.com/Microsoft/vscode-languageserver-node) people. After checking if i’m using the api correctly.

---

<div class="post-metadata">

**Author:** ![allanderek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/allanderek/32/1360_2.png) [@allanderek](https://discourse.elm-lang.org/u/allanderek)\
**Post date:** [July 4, 2019, 2:16pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/19 "2019-07-04T14:16:39Z")

</div>

Sure, done: [https://github.com/elm-tooling/elm-language-client-vscode/issues/8](https://github.com/elm-tooling/elm-language-client-vscode/issues/8)

---

<div class="post-metadata">

**Author:** ![Daniel-V1](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/daniel-v1/32/1578_2.png) [@Daniel-V1](https://discourse.elm-lang.org/u/Daniel-V1)\
**Post date:** [July 7, 2019, 3:46pm UTC](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891/20 "2019-07-07T15:46:18Z")

</div>

make sure you have module Main exporting (…) or whatever it needs to export at the top. I had this issue and that fixed it for me

[Next page](https://discourse.elm-lang.org/t/elm-language-server-and-a-new-vscode-plugin/3891.md?page=2)
