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

Scheme specific to syntax #24

Closed
dubeg opened this issue Jul 22, 2015 · 11 comments
Closed

Scheme specific to syntax #24

dubeg opened this issue Jul 22, 2015 · 11 comments

Comments

@dubeg
Copy link

dubeg commented Jul 22, 2015

Just thinking out loud here, would it be possible to detect when the active opened file has a syntax specific color scheme, and change that instead of the scheme specified in Preferences?

@benweier
Copy link
Owner

That's a really good idea! I know syntax specific settings and API methods are built right into Sublime so it's definitely possible to add a "set scheme for this syntax" command.

Thanks @dubeg :)

@benweier
Copy link
Owner

Hey @dubeg so while there's no way to identify a colour scheme as specifically for a given syntax, that is, a colour scheme isn't just "a JS scheme" or "a Python scheme". I've added new commands that allow you to set a colour scheme setting for the current file's syntax.

In the same way going to Preferences -> Settings - More -> Syntax Specific - User will create a .sublime-settings file for the current syntax mode, the new Set scheme for current syntax command will save a colour scheme setting for the current syntax. Conversely, the Reset scheme for current syntax command will erase any colour scheme setting that may exist for the current syntax.

I hope this works for you, let me know if you have any feedback or issues :)

@dubeg
Copy link
Author

dubeg commented Jul 25, 2015

This is very appreciated ben, that's exactly what I had in mind. I'll test these commands asap.

@dubeg
Copy link
Author

dubeg commented Jul 26, 2015

There are a few annoyances!

It seems the Set scheme for current syntax command sets the selected scheme in both User setting (Preferences) and the syntax settings file.

Also, on cancel, the last previewed scheme is still set in User settings. I've also got a case on cancel where if there wasn't any scheme set in the syntax settings file, the scheme that was set in User settings (previous to the command) will be set in the syntax settings file.

Just to be sure: when I say "on cancel", I mean that I pressed the Esc key, or that I made the panel lose focus.

Also, ideally, when previewing a scheme for the current syntax, I'd like to preview it only on that syntax (instead of previewing it globally), but that's really just a minor thing.

:^)

@benweier
Copy link
Owner

Thanks @dubeg, I'm unable to reproduce saving the scheme in both the global and syntax settings. The scheme list should only be able to act on one preferences object (a reference to the .sublime-settings file) at a time. This also means that previewing a syntax specific scheme will only apply to that syntax. I'll keep looking into it.

I've identified why cancelling the scheme list will inadvertently persist the global setting to the syntax setting (because I was falling back to the global colour scheme so the cancel thought it had an original scheme setting to restore).

I'm currently testing a few fixes and will put out an update later today.

@benweier benweier reopened this Jul 26, 2015
@dubeg
Copy link
Author

dubeg commented Jul 26, 2015

I played with your plugin a bit, I'll create a pull request to show you what I think could be changed to fix the problems I encountered.

There's a blank line removed somewhere that I inadvertently included in :^/

@benweier
Copy link
Owner

Give the update some time to hit Package Control and let me know if you have any more problems.

@dubeg
Copy link
Author

dubeg commented Jul 26, 2015

Looks good and solid, thanks @benweier !

@dubeg dubeg closed this as completed Jul 26, 2015
@benweier
Copy link
Owner

👍

@dubeg
Copy link
Author

dubeg commented Jul 27, 2015

Hey Ben, an issue with your last commit.

At line 82, the call to filter_scheme_name will crash in the case where get_scheme returned False, because it wanted a string and not a boolean.

@benweier
Copy link
Owner

Thanks G, I've switched that back to an empty string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants