Sublime Forum

(ST3) ColorHelper

#25

ColorHelper has some new features

  • Color info panel now shows css style conversions, and should replace current syntax with chosen conversion when clicked.
  • Now scans projects for colors. Will scan CSS source and html CSS style blocks and style attributes. These colors will be available via the palette panel.
  • Can now define color palettes at the project level as well as the global level.
  • Will scan ASE binaries for colors in a project (this will be optional in the future).

Maybe other things that I have forgotten. I need expose more control over what gets displayed and what gets scanned, but now is the time feedback will help. So if your using this, feel free to let me know what you like and don’t like, or what you would like to see (keeping in mind that I may or may not implement it).

Please do report bugs as well.

0 Likes

#26

Looks nicer and nicer!

There is a way to automagically show the color picker when the text cursor gets into a color? (after x ms)

0 Likes

#27

Is it not popping up for your? Or are you just wanting to tweak the timing of the popup? It should pop up on its own when you are either in a CSS color or in an HTML attribute with a color. If it isn’t popping up, let me know what syntax languages you use. If you want to tweak, I would be interested to hear what you don’t like about the current timing.

0 Likes

#28

Well, yeah, that’s it! I’m using SCSS syntax (on plain CSS works wonderful and the timing is just right!).

And i think why. Here are the scopes for exactly same cursor position for css vs sass:

*(http://i.imgur.com/rl58vFe.png)
*(http://i.imgur.com/BTcCIa6.png)

long story short, property-value is not a thing on sass syntax (i also have an ancient version of sass; let’s see if i can update)**

0 Likes

#29

Hmm. Well that is the down side of these types of projects, you spend most of your time processing more and more variants. So are SCSS and SASS the same thing?

Anyways, I can probably take a look at the SCSS and/or SASS. if I can’t refine the scope search, I can probably relax detection for that/those syntax(s). What gets more annoying is indexing the file’s and project colors. I index the file colors by using the scope to make it quick to make it so I search less code and get more relevant results. I guess I could run it through the project indexer which just parses plain text. But then I also have to support more syntax. The current CSS indexer is really basic an probably doens’t handle a couple of corner cases ideally yet, but it is so far good enough. But now I would have to parse more style variants ughhh. Hopefully there is a good python library with a compatible license that I can just convert it to CSS.

0 Likes

#30

Well, not really. Even i’m using one of these on a daily basis, i’m not sure which is which, but the main difference is that one it looks like a plain CSS, the other one doesn’t need curly braces and semicolon at the end (other than that, they both work the same).

I’ve tested a couple of other packages and none of them doesn’t provide a compatible scope. The variant i use provide a color.rgb-value.css scope on #hexcolors but nothing for rgb or rgba.

So most likely I will start digging into the tmLanguage file and see how i could add these extra scopes.

Thanks!

0 Likes

#31

Scopes would make it work the best for auto popup and current file color indexing. Worst case scenario, I can still filter out comments and strings, but you could possibly get a false positive if you use a hex color as a class name or id or used a web color name in a class name etc. It would also probably pick up things like css attribute nameswhite-space but I could probably tweak the regex to avoid stuff like that by avoiding colors preceded or followed by dashes.

The biggest hurdle is providing a way to index a SCSS and SASS without scopes for project indexing. I would have to build up some kind of sass and scss parser. CSS is pretty basic, so it is easiest to parse as plain text, though I think I will need to tweak things for @media etc.; it will handle the nesting, just no ideally like it should, and false positives are possible., but SCSS and Sass make things more complicated for accurate color detection via this simplistic approach. I will almost have to write up a simple lexer…ughh. I guess if I am just lazy I could just parse search for colors and ignore the nuances of the language.

0 Likes

#32

@iamntz, you can try this which should get scss and sass working if you are using this package: packagecontrol.io/packages/Synt … for%20Sass. The scoping was unique enough that I think this works. You should get auto pop ups and indexing of current file colors on save and such. Other sass, sccs syntaxes may not work, but they may very likely be resolved in a similar way, or better scoping would have to be added to them. So I would currently recommend the package above.

The only problem is going to be with certain sass/scss variables as the current regex and code doesn’t filter out color names that might start with $ or have dashes in front of them. I will tweak that stuff later, and I think we can overcome that. Now project indexing is going to be a bit tougher as I have to come up with a way to parse this stuff, so that is going to be put on hold.

Anyways, here is the new rules. I will commit these later today along with some better regex and such.
[pre=#FAFDFF] // File syntaxes that will be scanned on file open, save.
// These are the syntaxes in which the auto popup tooltip uses as well.
“supported_syntax”:
“meta.property-value.css -comment -string”, // CSS, CSS in HTML etc.
“meta.value.css -comment -string”, // CSS3, CSS3 in HTML etc.
“meta.property-list.css.sass -comment -string”, // sass and scss
“sass-script-maps -variable.other -comment -string”, // sass script maps
“meta.tag.inline.any.html string.quoted” // HTML attributes
][/pre]

0 Likes

#33

Works great! Thanks!

0 Likes

#34

Thinking about this more, if my regex is good enough, I may be able to just strip out comments and strings when scanning project files, and successfully scan CSS, SCSS, and Sass without having any additional special parsers. All I care about is the colors, so if I can isolate them well enough with solid regex, I may be able to get this working. I may give it a shot tonight.

0 Likes

#35

Okay, full SCSS and Sass support should now be in (project scanning and everything). Also made just about every option configurable, so you can turn off whatever you don’t like or don’t use.

So, feature wise, I am going to freeze this. From now on, I will be taking input about current functionality, fixing bugs, possibly cutting features if people feel they don’t make sense or aren’t practical, and tweaking the look.

So please do give feedback, before we get to a final release.

0 Likes

#36

Hi,
This plugin has a ton of potential and I love how it’s shaping up to be, however, I am having some issues though with the indexing (I am assuming) in a big plone project, and the plugin_host ends up eating all my cpu for quite some time. Would it be possible to have a setting to turn off indexing?

0 Likes

#37

At a quick glance, everything seems to work pretty damn good (at least in a single file mode). These day i’ll start a new project and i’ll be able to give a more complete feedback (i.e. find bugs) :sunglasses:

Thanks!

0 Likes

#38

At first sight, sublime became very sluggish (plugin_host.exe uses up to 25% cpu) when i try to open a fairly large project (e.g. laravel codebase). Disabling the plugin will make everything goes smooth again.

0 Likes

#39

@iamntz, I will need a bit of info.

  1. How sluggish are we talking?

  2. Do you get console errors.

  3. If you turn off “enable_project_palette”: false, and restarting, do things pick up (this is the only thing that has to do with big projects; if this doesn’t help it can’t be the indexing).

  4. Try turning off “enable_current_file_palette”: true, (maybe it has to do with a big file)?

I was running this in really large projects. Some projects we have at work are very, very large; once built, they take up over a gig with object files and source code and other crap. They don’t have any real web stuff (or very little), so it probably isn’t indexing many files, but it would have to crawl the entire tree. If you know of a public repo that would be good for me to try, please point me at a link. The whole process is threaded, but python threads are not truly parallel. Maybe I need more than a big project, but the right kind of project to see your problem?

0 Likes

#40

Setting “enable_project_palette”: false solves the problem for me. This is in a project of approx 4GB counting about 127k files, mostly python files. No errors in the console with debug set to true.

0 Likes

#41

I can try and push project size to reproduce, but it may be that project indexing needs to be an external process. If that is the case, I will need a cross platform solution, and may need to disable project indexing until that time. I figured this might be the route I would have to take.

0 Likes

#42

I pushed a couple of fixes, but I also disabled project indexing for now. I need to look into it more. Anyone is welcome to try it, but it appears it may work best in small projects. If you discover anything helpful about the project indexer, then please do share, but I am already aware of performance; though I need to spend more time to try and reproduce.

0 Likes

#43

I think I ran into the same issue with my smart color picker plugin when I tried to run a thread indexer on a large project. I think the multiprocessing module would be better since that module makes better use of multi-core processors, but for the life of me I cannot figure out how to implement it through sublime.

For a plugin I am writing for work I am looking at writing a C# program that will do my indexing as an external process which is what you had talked about doing. All of my users for this plugin are on windows, but making something cross platform may be tough. If I finish the tool and get good performance I will let you know!

0 Likes

#44

The solution needs to be cross platform, not the tool, but I don’t think it would be too hard to have both.

Sublime bombs on multiprocessor, so that is out of the question. I could rely on OSXs and Linux’s python and just call an external python script. That is actually pretty easy. Windows doesn’t come with python installed, so I could bundle a python app with the same code.

I think this would be easily doable.

0 Likes