Sublime Forum

Changing color of specific text in code blocks


Hello, I am currently working on a plugin for the lua syntax. It is supposed to get all of the arguments in the function then check the function code block for the arguments and alter the color of the text to match the same color of the argument while its in the function. I have done a ton of research into it, but have not found any real way to do it besides bypassing the restrictions on add_regions.

This is what I currently got it to do, but it just highlights everything.

I need it to have the colors reversed so that the text color is orange and not the background.

The only thing I was really able to find on this issue was this request on github:



Sadly, that issue is exactly what you are seeing, there is really only a few work arounds

  1. Create a User Override, with your defined colors, the background color has to be slightly different then the current background. One way to get around this is to make the background something like rgba(1,1,1,0.01) so that it is a different color but only has a 1% opacity.

Then in your add_regions command you would use that scope name that you created.



I was trying to figure out how to make a color but was having trouble. How would I go about making an override color like you described, that I could call as a scope?



Forget that, I found out how to do it when I did some more research on that. If anyone else is interested, all I did was create a new file called Monokai.sublime-color-scheme that had this text in it { "name": "Monokai", "variables": { "fakeblack" : "rgba(1,1,1,0.01)" }, "rules": [ { "name": "Argument", "scope": "argument", "foreground": "var(orange)", "background": "var(fakeblack)", }, ] }