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

per-filetype theme overrides? #20166

Open
1 task done
machin3io opened this issue Nov 4, 2024 · 4 comments
Open
1 task done

per-filetype theme overrides? #20166

machin3io opened this issue Nov 4, 2024 · 4 comments
Labels
bug [core label] setting Feedback for preferences, configuration, etc theme Feedback for theme configuration, accessibility, visual issues, etc

Comments

@machin3io
Copy link

machin3io commented Nov 4, 2024

Check for existing issues

  • Completed

Describe the feature

To do the syntax highlighting like I prefer it in python , I have to set editor.forground color.
See
image
vs
image
with the second being my preferred look, which closely mirrors the astronvim theme, which itself seems to be a variation of One Dark (Pro?).

Now, changing editor.forground will of course also affect other filetypes. For markdown for instance, I don't want all my base text in this color. And so while the experimental.theme_overrides work well in general, the don't work when specified on a per language level.

So, if possible I would just be able to do the following:

"languages": {
    "Markdown": {
      "experimental.theme_overrides": {
        "editor.foreground": "#ffffff"
      }
    }
  }

But it has no effect.

Or maybe I'm missing something obvious? Is it possible to completely disable syntax highlighting in some file types?
I would find that acceptable, even though I prefer having markdown headlines be a discrete color, and potentially other elements too.

@machin3io machin3io added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Nov 4, 2024
@machin3io
Copy link
Author

As a workaround I have this solution now.

  1. the following color overrride in my zed settings.
  "experimental.theme_overrides": {
    "editor.foreground": "#e06c75"
 }
  1. This zed task definition:
  {
    "label": "Toggle Primary Color",
    "command": "/my/path/to/toggle_zed_primary_color.sh",
    "reveal": "never",
    "hide": "always",
    "shell": "system"
  }
  1. This zed keymap for the task:
  {
    "context": "Workspace",
    "bindings": {
      "ctrl-t": ["task::Spawn", { "task_name": "Toggle Primary Color" }]
    }
  },
  1. This shell script to change the override color in the settings:
#!/bin/bash

# Define the JSON file location
JSON_FILE="/home/username/.config/zed/settings.json"

# Define the colors to toggle between
COLOR1="#cad6eb"
COLOR2="#e06c75"

# Check if the JSON file exists
if [[ ! -f "$JSON_FILE" ]]; then
    echo "Error: JSON file not found at $JSON_FILE"
    exit 1
fi

# Check if the file contains COLOR1 or COLOR2 and toggle between them
if grep -q "\"editor.foreground\": \"$COLOR1\"" "$JSON_FILE"; then
    # Replace COLOR1 with COLOR2
    sed -i "s/\"editor.foreground\": \"$COLOR1\"/\"editor.foreground\": \"$COLOR2\"/" "$JSON_FILE"
elif grep -q "\"editor.foreground\": \"$COLOR2\"" "$JSON_FILE"; then
    # Replace COLOR2 with COLOR1
    sed -i "s/\"editor.foreground\": \"$COLOR2\"/\"editor.foreground\": \"$COLOR1\"/" "$JSON_FILE"
else
    echo "No matching color found in $JSON_FILE"
fi

Pressing ctrl + t will now switch the colors. Works for me. Maybe helpful to someone else.

@notpeter
Copy link
Member

notpeter commented Nov 4, 2024

I believe this is a duplicate of:

Thanks for reporting. While I'm excited to see your workaround @machin3io I'm sad it's come to that.

@notpeter notpeter closed this as completed Nov 4, 2024
@notpeter notpeter added duplicate Additional reports of an existing issue and removed enhancement [core label] triage Maintainer needs to classify the issue admin read Pending admin review labels Nov 4, 2024
@machin3io
Copy link
Author

machin3io commented Nov 4, 2024

I'm not 'so sure @ duplicate :) Thanks for looking into it though. I appreciate the responsiveness.

Per-project themes may not be the same as per-filetype theming. I want my themes consistent across projects, but not necessarily across file types.

I thought about per-filetype themes too, but disregarded it as the theme includes a lot of non-editor declarations too. So I'm really only interested in specific syntax/highlight group colors really. And ideally of course the primary color I'm tweaking above, should be part of the syntax key too.

@notpeter
Copy link
Member

notpeter commented Nov 4, 2024

Interesting. I'll leave it open for the moment then. Practically speaking we could add support experimental theme overrides under the language key too.

@notpeter notpeter reopened this Nov 4, 2024
@notpeter notpeter added theme Feedback for theme configuration, accessibility, visual issues, etc setting Feedback for preferences, configuration, etc and removed duplicate Additional reports of an existing issue labels Nov 4, 2024
@github-actions github-actions bot added admin read Pending admin review triage Maintainer needs to classify the issue labels Nov 5, 2024
@JosephTLyons JosephTLyons added bug [core label] and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] setting Feedback for preferences, configuration, etc theme Feedback for theme configuration, accessibility, visual issues, etc
Projects
None yet
Development

No branches or pull requests

3 participants