Closed vinn2010 closed 4 months ago
Hi, I know nothing about emacs or eglot, but I had a similar problem in a neovim distro.
You might need to configure it explicitely to show diagnostics, I hear it's off by default on some cases. Available LSP options are https://github.com/castwide/vscode-solargraph?tab=readme-ov-file#extension-settings (which apparently can be found here https://emacs-lsp.github.io/lsp-mode/page/lsp-solargraph/#lsp-solargraph-diagnostics if that maps to anything on your config)
Also I would suggest to check how your PATH and GEM_PATH are used/configured. For example, I would have diagnostics on a custom config, but not on a default neovim distro config, because by default on these distro the solargraph package was installed to and called from a directory specific to that distro.
For example, on the custom config, solargraph would be called from my project folder home/projects/my_project
But the distro default went to a place like home/.local/share/lvim/mason/packages/bin
(the mason
here is the distro's package manager)
So one problem I had for example is that since I use the solargraph-reek plugin, and since it's not managed by mason
, solargraph would exit.
So yeah just check from actually where solargraph is called in your config, so that you know what config is given to solargraph
@Mate2xo is almost certainly on the right track. Diagnostics are disabled by default and need to be enabled in LSP options. I plan to change the default in the next release.
I understand. How do I switch it on? I am not 100% sure yet if eglot
is reading the global config file. But assuming it is, what is the correct way to switch diagnostics on?
I'm not familiar with eglot
, but in general terms, you need to modify the server's initializationOptions
to set "diagnostics": true
.
Possibly helpful: https://joaotavora.github.io/eglot/#index-initializationOptions
Okay, I got this working. Thank you both.
The correct steps are:
put the rubocop config in ~/.rubocop
Add a global config for solargraph in ~/.config/solargraph/config.yml
In this file, add rubocop
under reporters
:
reporters:
- rubocop # diagnostics
diagnostics
set to t.(use-package eglot
:ensure t
:config
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'((ruby-mode)
. ("solargraph" "stdio" :initializationOptions
(:diagnostics t))))
))
If you tell me where, I can add this (plus more context) to the docs? @castwide
Glad you got it working. This is specific to the client implementation, so it might be better to document it somewhere in the eglot
project. However, it's probably not strictly necessary, as diagnostics will be enabled by default in the next gem release.
Fair point. Thanks for the help.
I saw the issue here #655. This person uses eglot, solargraph and flymake.
I use the same stack. I also have no diagnostics.
I have a global config file here:
~/.config/solargraph/config.yml
as instructed from this issue #197.As the person in #655 stated, the online demo also doesn't show diagnostics.
How do we turn diagnostics on?
The lsp is running. In my config I have:
This works. I get documentation popups as expected.
Just no diagnostics. As a point of reference, all other languages get correct diagnostics through eglot. So I am confident that that is not the issue.
Environment
Solargraph version: 0.50.0 RuboCop version: 1.60.2 Emacs version: 28.2 OS: Debian 12 - Bookworm Ruby: 3.1.2