How can you run the Gleam language server?

Hi all,

kudos for the gleam LS.
I read Introducing the Gleam language server! – Gleam
but something which is not clear (to me) is how I can run the server.

I would need a command to run the server because I am trying to integrate that with vim coc,
this is an (incomplete) example coc conf I am trying to use:

{
  "languageserver": {
    "gleam": {
      "command": "What should I put here?",
      "filetypes": ["gleam"]
    }
  },
  "coc.preferences.formatOnSaveFiletypes": ["gleam"]
}

Thank you

1 Like

Hello! The command is gleam lsp.

Which editor is that for? We’re aiming to have the configuration built in to every editor that will have it :slight_smile:

1 Like

The editor is vim, the plugin I use to handle lsp is called coc

If I use the configuration I posted above, I got an error, the coc logs does not look much helpful to me:

2023-03-13T08:59:11.547 INFO (pid:4714) [plugin] - coc.nvim initialized with node: v17.5.0 after ^[[33m161^[[39m
2023-03-13T08:59:11.548 INFO (pid:4714) [services] - LanguageClient gleam state change: stopped => starting
2023-03-13T08:59:11.555 INFO (pid:4714) [services] - LanguageClient gleam state change: starting => stopped
2023-03-13T08:59:11.557 ERROR (pid:4714) [services] - Server languageserver.gleam failed to start: Error: Launching server
"languageserver.gleam" using command gleam lsp failed.
    at /home/carloratm/dotfiles/vim/.vim/plugged/coc.nvim/build/index.js:248:6419
    at async Nd.createConnection (/home/carloratm/dotfiles/vim/.vim/plugged/coc.nvim/build/index.js:244:15252)
    at async Nd._start (/home/carloratm/dotfiles/vim/.vim/plugged/coc.nvim/build/index.js:244:7748)
    at async Object.start (/home/carloratm/dotfiles/vim/.vim/plugged/coc.nvim/build/index.js:249:5338)
2023-03-13T08:59:23.119 INFO (pid:4714) [attach] - receive notification: openLog []

Should I reach the coc authors for help?

If I run gleam lsp on the command line I got no output, is that correct?

Then if I press Enter I got this error:

x gleam lsp

error: Fatal compiler bug!

This is a bug in the Gleam compiler, sorry!

Please report this crash to https://github.com/gleam-lang/gleam/issues/new
with this information and the code that produces the crash.

	compiler-cli/src/lsp.rs:70
	LSP initialize: ProtocolError("expected initialize request, got Err(RecvError)")

I don’t know if that is the expected behaviour.

Thank you

Carlo

1 Like

I would guess that messages are not being sent to the language server over stdio. Are there other configuration options for your client? Perhaps something is missing

1 Like

Yeah,
my configuration was wrong, I added the correct configuration format in the coc wiki, I hope it is ok with you.

And it is working fine.

Thank you

1 Like