Nvim-lspconfig: avoid Press Enter prompt for multiple errors

Created on 22 Apr 2020  路  5Comments  路  Source: neovim/nvim-lspconfig

  • nvim --version: v0.5.0-445-gca02db1f9
  • nvim-lsp version(commit hash): 39b743b9b36be26a5e58278d7608fe456a0ad3f8
  • :checkhealth result:
health#nvim_lsp#check
========================================================================
## Checking language server protocol configuration
  - INFO: clangd: configuration checked.
  - INFO: als: configuration checked.
  - INFO: tsserver: configuration checked.
  • What language server: Ada Language Server (ALS)
  • Operating system/version: Linux 5.3.0-46-generic Ubuntu
  • Terminal name/version: kitty 0.13.1
  • $TERM: xterm-kitty

How to reproduce the problem from neovim startup

  • Create empty files named /tmp/a.gpr, /tmp/b.gpr and /tmp/a.adb
  • Install nvim-lsp
  • Run :LspInstall als
  • Run the following lua snippet:
local options = {}
options["ada.projectFile"] = "a.gpr"
require("nvim_lsp").als.setup{ init_options = options }
  • Open /tmp/a.adb

Actual behaviour

The Ada language server will throw the following error and ask you to press enter:

LSP[als] More than one .gpr found.
Note: you can configure a project  through the ada.projectFile setting. 

The error and the Press Enter prompt will appear on each modification applied to the file.

Expected behaviour

There are two things that I would like to see.

First, if an error message has already been displayed to the user with a Press enter prompt, it should not ask for the user to press enter again. This can be achieved by forcing a :redraw after displaying the message a second time (or maybe just not displaying the message again?).

Second, I would expect the Ada Language Server to be able to detect the ada.projectFile setting I've set with init_options. I believe the ada.projectFile setting is an InitializationOption because the Ada Language Server provides an example showing how to configure this setting with LanguageClient-Neovim. LanguageClient-Neovim reads the settings and sends them as initializationOptions.

bug

All 5 comments

Actually, it looks like this the setting I'm trying to set isn't an InitializationOption:
https://github.com/AdaCore/ada_language_server/blob/01808399b01849b83367722f0fa1ff6aaac5781a/source/protocol/lsp-messages.ads#L3194

It looks like it is instead transmitted with a DidChangeConfiguration notification:
https://github.com/AdaCore/ada_language_server/blob/2215d7ac15473296b7da31f7e349598d0a6a9b01/source/ada/lsp-ada_handlers.adb#L2383

Not sure how to send these with nvim's lsp.

Hm, maybe in the on_attach callback? I didn't look closely, but that might be a good place to start.

Nvim-lsp already sends didChangeConfiguration notifications:
https://github.com/neovim/nvim-lsp/blob/68873604e1cbadf784e864c4ff08ff1735ca9be2/lua/nvim_lsp/configs.lua#L125

You just need to set the settings key instead of init_options. So this should work:

require("nvim_lsp").als.setup{ settings = { ["ada.projectFile"] = "a.gpr" } }

But it doesn't.

Adding

print(vim.inspect(encoded))

Right before this line:
https://github.com/neovim/neovim/blob/6c9a5743a0c296e74a48368a65783b9d49e6f702/runtime/lua/vim/lsp/rpc.lua#L272

Results in the following message being printed:

'{"method": "workspace/didChangeConfiguration", "jsonrpc": "2.0", "params": {"settings": {"ada.projectFile": "a.gpr"}}}'

Which should be exactly what the ALS is expecting, if I understand everything correctly.

Ah reading the Ada Language Server's source code, settings should actually be { ada = { projectFile = "a.gpr" } }! LanguageClient-Neovim's config file is weird.

I guess the only remaining issue I have with nvim-lsp is the blocking errors that spawn on every keystroke then :).

if an error message has already been displayed to the user with a Press enter prompt, it should not ask for the user to press enter again. This can be achieved by forcing a :redraw after displaying the message a second time (or maybe just not displaying the message again?).

馃憤 definitely in favor of that, need to track down the code doing that echo...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacksonludwig picture jacksonludwig  路  11Comments

matklad picture matklad  路  5Comments

mcepl picture mcepl  路  8Comments

dlukes picture dlukes  路  4Comments

JamesGreenaway picture JamesGreenaway  路  9Comments