AvinZarlez / processing-vscode

A Visual Studio Code extension for the programming language Processing
https://marketplace.visualstudio.com/items?itemName=Tobiah.language-pde
MIT License
178 stars 25 forks source link

Highlighting doesn't pick up built-in functions/variables #51

Open lachlansleight opened 6 years ago

lachlansleight commented 6 years ago

Presently processing-specific variables like width, height, frameRate, PI etc. aren't highlighted (and neither are built-in functions like setup(), keyPressed() etc), which can be confusing to beginners (I'm currently teaching someone to code using Processing so I've been thinking a lot about this kind of stuff lately).

Here's a comparison image (Processing editor on top, VSCode on bottom - note setup(), width and PI): highlightcomparison

I have no idea how .tmlanguage files work but I would imagine it could be as simple as manually adding them to the dictionary somehow?

AvinZarlez commented 6 years ago

This is a feature that doesn't exist in the extension. It's a good idea, just a matter updating the .tmlanguage file. Honestly, I haven't touched it in over 3 years I think, so it might be out of date for multiple reasons.

I didn't even make the file, just borrowed the one that the Processing Sublime plugin uses https://github.com/b-g/processing-sublime - Which also hasn't been updated in about 3 years it seems?

If you'd like to figure out what the syntax is for adding those build in function names, please feel free to make a PR updating the tmlanguage file!

lachlansleight commented 6 years ago

The extension still works great - I might make figuring out the tmlanguage file a weekend project one of these days :)

On Thu, Aug 16, 2018 at 1:38 PM Tobiah Zarlez notifications@github.com wrote:

This is a feature that doesn't exist in the extension. It's a good idea, just a matter updating the .tmlanguage file. Honestly, I haven't touched it in over 3 years I think, so it might be out of date for multiple reasons.

I didn't even make the file, just borrowed the one that the Processing Sublime plugin uses https://github.com/b-g/processing-sublime - Which also hasn't been updated in about 3 years it seems?

If you'd like to figure out what the syntax is for adding those build in function names, please feel free to make a PR updating the tmlanguage file!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TobiahZ/processing-vscode/issues/51#issuecomment-413414904, or mute the thread https://github.com/notifications/unsubscribe-auth/AXt09UtsY68CKYLq8wn4f3tsWSuQQ3Dzks5uROkhgaJpZM4V_G5r .

atnbueno commented 4 years ago

Those variables are in the TextMate grammar, but the default VSCode themes don't have a different color for everything. You have to find the corresponding scope (e.g. constant.other.processing is the scope for the frameRate, width, and mouseX tokens). And then you can add a custom color to those in settings.json with something like this:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "constant.other.processing",
            "settings": {
                "foreground": "#00FF00"
            }
        }
    ]
}

Before: imagen

After: imagen

You can also specify different colors for each available theme. See https://code.visualstudio.com/docs/getstarted/themes#_customizing-a-color-theme

P.S. Instead/In addition of the color ("foreground") you can change the "fontStyle" (e.g. to "Italic")

AvinZarlez commented 4 years ago

That explanation seems like something that could be turned into an useful instructional blurb in the readme!