Solargraph not using Rubocop reporter #10169
Replies: 24 comments
-
You will get better logs if you run |
Beta Was this translation helpful? Give feedback.
-
Weird, I thought I did that. Sorry about that! Anyway, I tried to reproduce this on a minimal example in a github repo now, and this is my log when running New log: ~/.cache/helix/helix.log
(I tried on a different computer (one running Fedora Silverblue) now. No difference.) |
Beta Was this translation helpful? Give feedback.
-
Okay, everything looks fine but it seems that solargraph needs a config option to enable diagnostics: Could you try adding this to your local helix config? [[language]]
name = "ruby"
config = { solargraph = { diagnostics = true, formatting = true } } If it works let me know and we'll add it to the built-in languages.toml |
Beta Was this translation helpful? Give feedback.
-
I actually remember now having to set diagnostics true manually for coc-solargraph on nvim years ago, it didn't occur to me to check this, sorry! So I put those lines in languages.toml and here are my findings:
Thank you so much for your help! |
Beta Was this translation helpful? Give feedback.
-
Can you tail the log in verbose mode and post what it says when you trigger formatting? |
Beta Was this translation helpful? Give feedback.
-
Sure! .cache/helix/helix.log
EDIT: Updated with new log because the first one had some bundler errors that were red herrings. After rerunning bundle install, the bundler error is gone, but it still doesn't work. |
Beta Was this translation helpful? Give feedback.
-
I don't see the formatting request happening. There should be a log that starts with something like
triggered by |
Beta Was this translation helpful? Give feedback.
-
@evenreven I guess |
Beta Was this translation helpful? Give feedback.
-
With |
Beta Was this translation helpful? Give feedback.
-
@the-mikedavis It's the entire log. I've tried and retried and run here's another log that's more or less identical, just to prove to myself that I didn't do anything weird the last time
For comparison, here's the log when (successfully) running Log for hx -vvv test.js
|
Beta Was this translation helpful? Give feedback.
-
But Helix doesn't show any error at all, that's the problem. It acts like everything is fine. Only Neovim (running the same Solargraph/Rubocop versions) shows the error. VS Code shows the error too, and I verified that it's running as Solargraph extension, i.e. with Rubocop running as a Solargraph reporter, not as a separate VS Code extension. The more I'm looking into this point, I think it might be a separate bug? Here's the helix log when opening the file with the missing end: .cache/helix/helix.log
Look at the last line in particular. The rubocop message is present in the log, but doesn't appear in the on-screen diagnostics in Helix. I don't know Rust or the innards of Helix, so I'm not sure what |
Beta Was this translation helpful? Give feedback.
-
Yep, the diagnostic is discarded because the range given by Solargraph was considered out of document range by us. I'm taking a look. |
Beta Was this translation helpful? Give feedback.
-
does the diagnostic appear if you add some more content at the end of the file? Is it incorrectly positioned in that case? |
Beta Was this translation helpful? Give feedback.
-
Adding more content didn't help, but I managed to get the diagnostic to appear when I removed the blank newline at the end of the file. So it seems that's the problem. |
Beta Was this translation helpful? Give feedback.
-
So to recap, this is actually three issues:
Thanks for the prompt and helpful responses so far, @archseer, @the-mikedavis and @danillos, I really appreciate it! |
Beta Was this translation helpful? Give feedback.
-
I've been using Helix some more and I think my description of the issue(s) in the previous comment is correct. I'm sorry I don't know enough to help this along. If I can do any more by testing various stuff, let me know. |
Beta Was this translation helpful? Give feedback.
-
Same issue here! Adding the config mentioned above to my languages.toml file enabled reporting from solargraph, but the :format command still doesn't seem to call the lsp formatting action. |
Beta Was this translation helpful? Give feedback.
-
Y'all could use the new non-LSP formatter config, I just added instructions for Rubocop n StandardRB: https://github.com/helix-editor/helix/wiki/External-binary-formatter-configuration#rubocop |
Beta Was this translation helpful? Give feedback.
-
I notice that when the formatter fails to reformat the code it returns 1 and you can't close a buffer with auto-format on.
|
Beta Was this translation helpful? Give feedback.
-
Rad. You ought add that to the wiki page as well, anyone can edit it. |
Beta Was this translation helpful? Give feedback.
-
If you've installed rubocop/standardrb/stree(SyntaxTree) globally, you should modify the formatter command.
|
Beta Was this translation helpful? Give feedback.
-
Thanks @dhnaranjo and @lrgalego for the external formatter tip! That ended up solving the issue for me. I added the suggestion to include the LSP config to the wiki so others can benefit: https://github.com/helix-editor/helix/wiki/External-binary-formatter-configuration#rubocop (feel free to further clarify) Not sure if the other issues identified in this thread are still outstanding, but if not we might be able to close this. |
Beta Was this translation helpful? Give feedback.
-
Is there an updated way to configure this? config is no longer supported under language:
|
Beta Was this translation helpful? Give feedback.
-
This is my configuration at [language-server.solargraph]
command = "/Users/danillos/.rbenv/shims/solargraph"
args = ["stdio"]
config = { diagnostics = false, formatting = false }
[language-server.rubocop]
command = "/Users/danillos/.rbenv/shims/rubocop"
args = ["--lsp", "--stderr", "--fail-level", "fatal"]
timeout = 3
[[language]]
name = "ruby"
language-servers = ["rubocop", { name = "solargraph", except-features = [ "format", "diagnostics" ] }]
auto-format = true I'm using Rubocop not inside of Solargraph because it is faster. |
Beta Was this translation helpful? Give feedback.
-
Summary
My Solargraph config works with other editors, including Neovim. I just started using Helix today, so I might mistake whether or not a feature is from the LSP or not, but Solargraph itself seems to work. It can jump to references and autocomplete seems to work too. Then again, the line where
solargraph stdio
is invoked, is marked as error in the log, and I'm a bit confused as to how serious that is with no additional stdout output.Reproduction Steps
I tried this:
hx -v test.rb
Then pasted this deliberately unindented file content to trigger a rubocop warning:
Then
:w
I expected this to happen:
A diagnostic message like this
Use 2 (not 0) spaces for indentation. (Layout/IndentationWidth)
Instead, this happened:
Nothing
Helix log
~/.cache/helix/helix.log
Platform
Linux (WSL2)
Terminal Emulator
Windows Terminal 1.12.10983.0
Helix Version
helix 22.05 (27609f5)
Beta Was this translation helpful? Give feedback.
All reactions