-
Notifications
You must be signed in to change notification settings - Fork 135
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
LSP changes color scheme -- option to disable this behavior #1762
Comments
Hey @seanturner026, thanks for reporting this, I'm sorry you've been seeing this for years and thought you had to accept it. The good news is that we are not changing the color scheme/theme and the behavior is user configurable. Syntax highlighting in VS Code and other LSP aware editors like neovim apply highlighting to tokens in two passes. The first pass comes from a TextMate grammar (a complicated set of regular expressions) that applies almost instantaneously, and is the highlighting you see in the first screenshot. The second pass comes from Semantic Tokens, which is delivered by the language server when it's built enough context to provide more specific highlighting, which is what you see in the second screenshot. Why do we do this? We do this to provide more detailed information than what regex can provide. For example, with regex it's hard to determine if a token is valid or not depending on which version of Terraform is currently being used. We could highlight it red in versions that are not supported, and leave it unmodified in versions that are. Note that what actual colors are used are not decided by the extension/LSP, we just tell the editor that this range at this location is this kind of token. Your color theme determines what actual colors are used. If you are using one of the built in themes, they all should have colors defined for these tokens. If you are using a color theme from the gallery, you'll have to inspect that theme to see what color they set for each token. If you're using your own color theme, then you can follow the Color Theme guide to see what to implement. Now to explain the part that is user configurable. This will probably be different in neovim so you will have to look that up. In VS Code you can either turn it off entirely and lose the more specific information, or you can customize what color is used for each token. You can turn off semantic highlighting entirely: "editor.semanticHighlighting.enabled": false To customize the colors used (I picked random colors just to enumerate the different options): "editor.semanticTokenColorCustomizations": {
"enabled": true,
"rules": {
"type": "#569cd6",
"parameter": "#9cdcfe",
"variable": "#9cdcfe",
"property": "#9cdcfe",
"function": "#dcdcaa",
"method": "#dcdcaa",
"operator": "#d4d4d4",
"keyword": "#569cd6",
"string": "#ce9178",
"number": "#b5cea8",
"comment": "#6a9955",
"punctuation": "#d4d4d4",
"tag": "#569cd6",
"attribute": "#9cdcfe",
"boolean": "#569cd6",
"null": "#569cd6",
"enum": "#b5cea8",
"namespace": "#4ec9b0"
}
}
} |
Fantastic, I was able to sort this out!! Thank you very much for the thorough response! Here was the fix for neovim (disabling |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Description
For some reason enabling
terraformls
changes the color scheme of my IDE. When I open a file my theme will be correct and then after .5 seconds or so it changes. I've noticed this in vscode (for years) and now neovim.Is there a way to disable this behavior? I skimmed the docs and issues and did not see anything.
If there is no way to disable this behavior can a toggle be added?
Additionally, I have confirmed this. Disabling my
terraformls
in neovim causes my theme to be preserved.No LSP:
With LSP:
Links
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: