Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No diagnostics? #709

Closed
Kevinizevbigie opened this issue Feb 19, 2024 · 7 comments
Closed

No diagnostics? #709

Kevinizevbigie opened this issue Feb 19, 2024 · 7 comments

Comments

@Kevinizevbigie
Copy link

Kevinizevbigie commented Feb 19, 2024

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:

(use-package eglot
  :ensure t
  :config
  (with-eval-after-load 'eglot
        (setq completion-category-defaults nil)
        (add-to-list 'eglot-server-programs
                     '((c-mode c++-mode)
                       . ("clangd"
                          "-j=4"
                          "--malloc-trim"
                          "--log=error"
                          "--background-index"
                          "--clang-tidy"
                          "--cross-file-rename"
                          "--completion-style=detailed"
                          "--pch-storage=memory"
                          "--header-insertion=never"
                          "--header-insertion-decorators=0")))
        (add-to-list 'eglot-server-programs
                     '((php-mode web-mode)
                       . ("intelephense" "--stdio")))
        (add-to-list 'eglot-server-programs
                     '((ruby-mode)
                       . ("solargraph" "stdio")))
        ))

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

@Mate2xo
Copy link

Mate2xo commented Feb 20, 2024

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

@castwide
Copy link
Owner

@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.

Related: #703

@Kevinizevbigie
Copy link
Author

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?

@castwide
Copy link
Owner

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

@Kevinizevbigie
Copy link
Author

Kevinizevbigie commented Feb 20, 2024

Okay, I got this working. Thank you both.

The correct steps are:

  1. put the rubocop config in ~/.rubocop

  2. Add a global config for solargraph in ~/.config/solargraph/config.yml

In this file, add rubocop under reporters:

reporters:
- rubocop  # diagnostics
  1. Inside emails, within the eglot install, add solargraph with 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

@castwide
Copy link
Owner

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.

@Kevinizevbigie
Copy link
Author

Fair point. Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants