-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
[PackageDev] Add support for var() #186
Comments
Here's the thing. I have the capability to parse, that part isn't hard. But this requires us to parse the whole file every time to get the context of all the Currently, ColorHelper works on a sliding window. Everything that is visible (both horizontally and vertically) gets parsed and has previews added. Everything outside that window does not. This is mainly done for performance and is done in a general way. Additionally, any file that does something like this must have language context. In PackageDev, we must parse the file as JSON grab anything in In such cases, you almost need something like a language server to provide such info asynchronously. The idea was to keep things generic but simple. Or as simple as can be expected considering the complexity of specifying different color types per file along with other syntax-specific preferences. I'll be the first to admit the config file is fairly complex currently. Adding in variable detection definitely elevates the level of complexity, and then we must solve performance-related issues as we would then be scanning the entire file each time. A sliding window is no longer going to cut it. And the approach most assuredly has to be flexible enough to some mechanism to provide language-specific parsing. For these reasons, such a feature has not been added as of yet. |
@rwols I believe had made a suggestion while I was kneedeep in re-writing ColorHelper about somehow connecting LSP with ColorHelper. At the time I was so overwhelmed with work that I never had a chance to fully look into it. Theoretically, we have the capability to apply the variables if we know them: https://github.com/facelessuser/ColorHelper/blob/master/custom/st_colormod.py#L528. I'm not sure at this time what is possible with LSP and what is not. For instance, I'm not sure if LSP completely resolves colors in CSS or not, or just resolves variables. Can I get that on-demand or is the only way for LSP to send that info when it is ready, and you just have to be prepared to accept it? So, is it possible? Maybe. We'd have to figure out how to get these two separate plugin systems talking. If we just have to be ready for LSP at any time, maybe there could be a way that ColorHelper just accepts the context data we need for a given view, and then when we are evaluating patterns in a view, we then check if we have context data. They fundamentally approach things differently, but if we could work out some kind of way to pass context, maybe it would be possible. But, the important thing is that whatever we do on the ColorHelper side has to be generalized as we don't want language-specific code in the core, and if we do need language specific code, it has to be done in such a way that we provide a hook and point it at some external code that we can run on the fly. |
Can you make it work for built-in variables like |
The problems for built-in variables and other custom variables remain the same. Nothing is made easier or faster by only adding support for built-in variables. |
Oh, I meant in the context of the command palette. |
Can you elaborate? I'm not sure what your mean. |
Are you proposing it always loads the variables from the currently loaded color-scheme? Looks at the current active buffer and loads variables from there? Some combination? While I'm not sure whether we'd go this route or not, I'm not quite sure I understand the expectation with this proposal. |
|
I don't think |
Why not ? |
One of the reasons I'm not too keen on including variables is because it isn't even as simple as just get the current variables. There are complexities when trying to perform such variable resolution with Sublime themes. You have to take in consideration file overloads and such which would require us to scan all color schemes every time. We'd have to find all the like-named color schemes, overlay them in the proper order, then find all the variables, and then resolve them all. ScopeHunter used to do this to get proper color scheme variables when it was still manually parsing color schemes.
Because Anyways, you can see how this gets more and more complicated. Now, we could probably simplify all this by simplifying this process by only evaluating the text in the given active view and not scanning all the overloads. Anyways, I get the gist of what you are proposing. I'm not sure how I feel about going down this road right now, but I'll keep it in mind as a possibility. |
I don't think considering overloads is necessary, just go the easy way: |
If all you want is I'm also not really a fan of |
Description
The support for PackageDev themes and color schemes is great - it's what I most often use this plugin for. Would it be possible to add previews for the simple
"var(some_color_variable)"
syntax?For example, in a color scheme, I define a variable and then use it for a global:
The color preview shows up next to the
#0042FF
as it should, but I would like that same preview to show up next tovar(blue)
. I don't use any of thecolor()
mod function options, but I imagine those that do would probably like to see previews of those, too (if possible, given they're implemented within Sublime and not exposed via the API, that I know of). However, even if you can't do that or it would take a long time, I should think it would be fairly straightforward to highlightvar()
. Unless the variables themselves are made usingcolor()
...The text was updated successfully, but these errors were encountered: