RFC: Add solargraph gem to developer environments for code completion and syntax highlighting

Context and Problem Statement

Katello development environments do not ship with an easy option for code completion and syntax highlighting.

Proposal

Add solargraph ruby gem as a dev dependency to Katello with support of solargraph config files to make intellisense easily supported in the Katello project. This would only be added to the Katello developer environment only and would not effect anything user facing. Note that for devs that still do not want solargraph enabled it can be disabled at a project level for themselves.

I have provided an example of how solargraph behaves in VSCode.

Alternative Designs

We could possibly make solargraph opt-in vs a dev dependency.

3 Likes

This seems like a great quality-of-life add. If we ever get around to adding yard documentation to katello methods, having docs auto-populate on highlight would be very nice.

2 Likes

In Foreman we load all Bundler files:

We then also have a .gitignore line:

So you can already apply this locally:

echo "gem 'solargraph'" > bundler.d/solargraph.local.rb

s/katello //
Because I’d love to have that more. In my experience it forces people to really think about what their method does, which inputs & outputs it has, etc.

Is there a reason for picking solargraph over ruby-lsp these days?

I think the formatting got corrupted here

I think Ewoud used the sed replacement syntax (replace “katello “ with nothing) to say he does not want this limited to Katello and having yard documentation to all methods.

2 Likes

I was not aware of this and it seems the people I spoke to about this as well are not. Maybe we could put this in the development docs somewhere?

The way you described applying this locally is similar to the PR I would raise only missing solargraph.yml file

1 Like

Personally solargraph is less buggy in situations in compared to when I tried ruby-lsp. I didn’t have the best experience trying to get ruby-lsp working. If you use ruby-lsp how does it work for you?

I tried solargraph in the distant past and back then it was rather slow so it never stuck with me.

Well, yes, you have to twist its hand a little. It turned out longer than I expected but here’s some relevant reading Foreman development with ruby-lsp and VSCode .

I don’t really use it all that much. I have two dev environments, I have it enabled (since like last week) in one and not in the other and I don’t really find myself using it when in the environment that has it and I don’t really miss it when I’m in the environment without it. Guess all the years without any sort of lsp have taken their toll on me

1 Like

I briefly tried solargraph and it indeed seemed slow (at least in my vim with ALE as the LSP integration).
Then I tried sorbet and it seemed much faster. Do you have any opinions on that?

I have plans today to try out sorbet + ruby-lsp from what I have read these go well together. Personally my only experience of these were not great but I believe I may have done something wrong after reading these comments on ruby-lsp.

I have no opinions on what tool is used, I prefer anything that works fast, well and consistent. I will try out sorbet + ruby-lsp today and post my thoughts today.

How were you able to get sorbet working with foreman I am getting issues running bundle exec tapioca init due to ruby version conflicts.

Other than that I am pretty happy with ruby-lsp and its fairly simple to setup.

I would say the only big downside to ruby-lsp is it works better when paired with sorbet. I am unable to get the RBI files generated with bundle exec tapioca init due to safemode not supporting a ruby version >= 3.2.

I used it w/o the stuff tapioca generates.

I’d love to get Ruby 3.4 compatibility · Issue #54 · theforeman/safemode · GitHub resolved but don’t have time for it myself.

Last time we did an update @ofedoren and I decided to be conservative given we’re actually parsing the language and weird new things may show up. But looking through Commits · seattlerb/ruby2ruby · GitHub I think parser wise there really weren’t that many changes.

I spent some time on this ruby 3.4 issue the other day and I came up with this draft pr. I was able to get this working with foreman and also supporting ruby-lsp with sorbet.

I am not 100% sure if this PR is exactly what you are looking for when you talk about supporting 3.4 if things are missing I can gladly take a look and add them.