1

I'm trying to run lsp-mode for elm development and according to lsp-mode elm is supported. Also according to that link, I should only have to clone the elm-language-server repository, run npm install and then tsc, all of which I did, without any errors.

After configuring emacs with the following from here

(require 'lsp-mode)
(add-hook 'elm-mode-hook #'lsp)
(setq lsp-elm-server-install-dir "~/Projects/elm-language-server")

everything should be set to go.

When I do this, everything seems to work. lsp-mode starts when I open an elm file and it starts the elm-language-server. I end up with an *lsp-log* buffer, an *elm-ls* buffer and an *elm-ls::stderr* buffer.

The output from the *lsp-log* buffer doesn't look too suspicious:

Command "node /home/chris/Projects/elm-language-server/out/index.js --stdio" is present on the path.
Found the following clients for /home/chris/Projects/select-elm/src/Main.elm: (server-id elm-ls, priority -1)
The following clients were selected based on priority: (server-id elm-ls, priority -1)
Rebuilding tree-sitter for local Electron version
Fetching tree-sitter
Downloading from https://github.com/tree-sitter/node-tree-sitter/releases/download/v0.14.0/tree-sitter-v0.14.0-node-v57-linux-x64.tar.gz
Fetching tree-sitter-elm
Downloading from https://github.com/razzeee/tree-sitter-elm/releases/download/v2.2.4/tree-sitter-elm-v2.2.4-node-v57-linux-x64.tar.gz
Rebuild succeeded!
initializing - folder: "file:///home/chris/Projects/select-elm/"
Reading elm.json from /home/chris/Projects/select-elm/elm.json
2 source-dirs found
Found 39 files to add to the project
Adding /home/chris/Projects/select-elm/src/01-button.elm
Received new elm-analyse report with 1 messages
Received new elm-analyse report with 1 messages
Adding /home/chris/Projects/select-elm/src/form.elm
Adding /home/chris/Projects/select-elm/src/Main.elm
Adding /home/chris/Projects/select-elm/src/select.elm
Adding /home/chris/Projects/select-elm/src/text.elm
....

although the "-1" in (server-id elm-ls, priority -1) might be an indicator something is wrong.

The *elm-ls* buffer is empty and the *elm-ls::stderr* is where there is a definite problem:

(node:30435) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: "file" argument must be a non-empty string
(node:30435) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:30435) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: ENOENT: no such file or directory, open 'file:///home/chris/Projects/select-elm/src/Main.elm'
(node:30435) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): TypeError: "file" argument must be a non-empty string
(node:30435) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): Error: ENOENT: no such file or directory, open 'file:///home/chris/Projects/select-elm/src/Main.elm'
(node:30435) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): TypeError: "file" argument must be a non-empty string

Unfortunately I haven't been able to find anything on the web about this. In my elm buffer I simply get an error message on the very first line "Error parsing file". The file does compile using elm make though.

Anyone have any idea how to debug this? I'm using elm 0.19.0 and unfortunately the normal elm-mode isn't an option for me because elm 0.19.0 has created a lot of breaking changes that the maintainers of elm-mode are having a hard time fixing.

1

That Error parsing file is from elm-analyse and it has to do with the file not starting with module MyModule exposing (..) which seems to wreck elm-analyse and then the server itself. I only know this because I also had this problem. More info and original discussion can be found here: https://github.com/jcollard/elm-mode/issues/142

| improve this answer | |
  • Did you happen to get flycheck type checking to work? I've got lsp-mode using lsp-ui, which uses flycheck and everything else looks really good, but I have to compile the buffer to see when I use a wrong type somewhere. – flooose Jun 7 '19 at 11:00
  • I just saw this and checked it out. I just wanted to test something small, and I can see a type mismatch if I do text 1, which is supposed to take a string. However, if I had any other error in the buffer before that one, it doesn't seem to see it. After doing some more testing around it seems like maybe elm-analyse/elm make are getting a version of the buffer that is several edits old. – Daniel Jun 12 '19 at 13:28
  • Thanks for the info. Still not working. I'll have to look into things some more. So close yet so far away! :) – flooose Jun 13 '19 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.