Shopify / vscode-shopify-ruby

An opinionated and auto-configured set of extensions for Ruby development
MIT License
176 stars 13 forks source link

How can I add the semantic token colours to an existing theme that doesn't have them? #442

Closed unikitty37 closed 1 year ago

unikitty37 commented 1 year ago

I find the Spinel theme to be much too bright (and very distracting as a result) so I'm using Darcula IntelliJ Theme Extended instead. It doesn't have the semantic token colours needed for Ruby, though.

I've tried adding this to settings.json but it doesn't seem to make any difference to what's displayed when I open a Ruby file — I still the the same as if I hadn't added this JSON.

  "editor.semanticTokenColorCustomizations": {
    "[Darcula IntelliJ Theme Extended]": {
      "enabled": true,
      "rules": {
        "variable": "#1eda7c",
        "class": {
          "foreground": "#ec7a08",
          "fontStyle": "bold"
        }
      }
    }
  },

(Yes, those two colours are also garish, but I wanted to be sure I could see them change while I was experimenting :)

Am I actually configuring this correctly?

vinistock commented 1 year ago

The customizations are indeed correct. Not sure why it isn't working. Can you try changing this config?

{
  "editor.semanticHighlighting.enabled": true,
}

Maybe the theme doesn't support semantic highlighting and your editor is configured to enable it based on theme configurations.

You can also use the token inspector to verify that you're looking at the right tokens.

unikitty37 commented 1 year ago

Thanks — I've tried enabling semantic highlighting globally, rather than specifically for the theme, but it still doesn't seem to pick it up. The theme has semanticHighlighting: true set: https://github.com/diep89/darcula-intellij-theme-extended/blob/cc88fd727626ef94ee5210817c19e811a152a3c9/themes/darcula-intellij-theme-extended-color-theme.json#LL753

image

vinistock commented 1 year ago

Based on the token inspection, you can see that only textmate scopes are being applied. It's not showing any semantic token information.

Is the Ruby LSP running properly to provide the semantic tokens?

This is the information that needs to show up if the Ruby LSP is running and providing semantic information. Notice that there's a section for the semantic information, which is missing for you.

image
unikitty37 commented 1 year ago

Thanks — it seems I ran into the same issue I had in #443. Adding a basic Gemfile with rubocop in it allowed the LSP to start:

# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.1.3'

gem 'rubocop', '~> 1.39.0', require: false

Now I just need to pick some colours I like 😁