I am using the Anaconda package for Sublime 3, and it works perfectly. My only problem is that linting highlights all kind of errors, warnings and PEP8 recommendations in the same color, white. I would like to change it so errors are red, warnings are yellow etc... But I can't figure out how to do that. I found this resource that basically tells me to add some XML code to my current theme to change the linting color, but I tried doing that, and it did nothing.
First of all I believe now themes are using json and not XML anymore, in filenames of the type ".sublime-color-scheme" or ".sublime-theme". Thus I found a custom theme that indeed had a ".tmtheme" file, and pasted the XML code given here, but linting was still completely white.
Then I tried translating this XML code into json, and pasting it into the ".sublime-color-scheme" file, but then again, linting was white. To be precise, I pasted it in the "rules" :[] entry, since that seemed to fit the format.
Anybody with more experience could tell me what I'm doing wrong, or point me to another way of changing linting color ? I am aware of package such as SublimeLinter, but I'd rather stick with the built-in linter of the Anaconda package since its working perfectly beside the coloring.
As you've noted, there are two different types of color schemes in Sublime Text:
The
tmThemeformat, which is an XML plist file. This format is still supported, but is considered to be a legacy file format at this point.The
sublime-color-schemeformat, which is a JSON file. This format can do everything that thetmThemeformat can do, and has extra capabilities thattmThemefiles don't.It's hard to say exactly what you might have done wrong since you didn't include the content that you tried adding to the files. Generally I would expect that anything you added in there would either work or cause an error of some sort (either a popup or in the Sublime console), barring any configuration issues with the package itself.
As an added note, I don't use this package (or linters in general), so for test purposes the Anaconda settings I tested with are stock except for the following two settings:
How you would go about adding the extra rules to your color scheme depends first on where your color scheme lives. In particular, if you have created your own custom color scheme that's stored in your
Userpackage, the steps are different than if you're using a color scheme that's being provided by someone else (Sublime Text or some package that you installed).Since most people tend to use pre-existing color schemes that they obtained from somewhere else, we'll cover that first.
The color rules that are given on the page you linked are in the
tmThemeXML format, and look like this:To add these rules, we need to first convert them into the
sublime-color-schemeJSON format, even if your color scheme is atmThemecolor scheme. The method that you use to adjust a color scheme is to create a file in yourUserpackage with the additional content, and that file is always in thesublime-color-schemeformat.The conversion of these rules to the new JSON format of a
sublime-color-schemelooks like this:Depending on your actual color scheme, the colors in here may or may not be appropriate, so you'll have to play with them to get them looking as you want. This would also require knowing what classifies as
illegalversuswarningversusviolationas well as how you've set up Anaconda's linting style. Your rules might needforeground,backgroundorbothdepending on how you've set things up.With this content in hand, we're ready to begin. In order to make the adjustment, you need to know what the name of your color scheme is. You can get this by using
Preferences > Settingsand looking at thecolor_schemesetting (if you're using syntax specific settings, then open a file of that type and usePreferences > Settings - syntax specificand get the color scheme from there).The part that we're interested in here is the name of the file; we don't care what package it might say it lives in, only the name of the file itself. We also don't care what extension the file has because we're going to assume that the extension is
sublime-color-schemeanyway.For example, with the setting set as the following, the name of the color scheme is
Cobaltand that's all we care about.With this color scheme, the configuration above and some sample code, the results I see in the buffer are this:
In order to put the new rules in place, we need to create a
sublime-color-schemefile in theUserpackage named for our color scheme. So in this case that would beCobalt.sublime-color-scheme. If you're unsure of where yourUserpackage lives, you can usePreferences > Browse Packagesto find it.The content of the file that you create should look like this (paste the content from above as appropriate; for brevity I'm not including it again here):
As soon as you save the file, it will take effect. The result of that is this:
Presuming that you're using a color scheme that you created yourself that's in your
Userpackage, this won't work and you would instead need to add the rules directly to your color scheme file in yourUserpackage. This would also be the case if you have a "patch" file like this already in yourUserpackage (if you were adding extra color rules for somethign else, for example).If your custom color scheme is in
sublime-color-schemeformat, then you can just add these rules into therulessection of your color scheme just like above to have them take effect.If your color scheme is in
tmThemeformat, then instead you'd need to copy the XML version of the settings into your color scheme. Here how you'd do that is not entirely as straight forward as with thesublime-color-schemeformatted file due to the XML nature of the file.In this case you'd instead need to note that each rule is a
<dict></dict>tag with specific keys, then examine the color scheme to see where it has similar color rules and inject yours into the correct location.Generally speaking if you get it wrong the color scheme will be ignored (everything will turn black and white) and you'll get an error dialog to tell you that something has gone wrong.
More information on how color schemes work, how to apply colors, etc can be found in this video series on color schemes in Sublime Text (with the disclaimer that I'm the author of the videos in question).