Repository navigation
Improve CMake syntax highlighting: extend variable recognition with compiler/toolchain families and add scoped property command colorization - #4527
Conversation
dcd59b4 to
f195395
Compare
d55fce6 to
38e87ab
Compare
I upgraded my grammar-generation script I use to generate the vim-syntax-highlighting-rules to put out a TextMate-grammer. The script can be found here: https://github.com/pboettch/vim-cmake-syntax/tree/textmate-grammer-generation
38e87ab to
41320ca
Compare
|
Hi Patrick Boettcher (@pboettch), thank you for this PR, and for the time you put into researching the vim syntax as a reference! The ideas here are genuinely useful and several of them are being brought in. Our grammar has evolved toward a regex-generalized architecture rather than exhaustive keyword enumeration, meaning we prefer patterns like This keeps the file maintainable as CMake grows and avoids false-positives. The tradeoff is that it doesn't match the structure of a vim syntax file very directly, so the translation isn't one-to-one. The improvements from this PR are being incorporated in a rebased form that layers your ideas on top of the current grammar's design, preserving the scoped-command architecture, the existing scope names and regex families, and the fixes already present in main. You'll be credited in the changelog for the inspiration. Thanks again for the contribution! |
|
Don't worry, I didn't do this PR for the glory. I just know from the past that finding something generic regarding CMake syntax is hard to impossible and also CMake does not provide anything in their source tree which would make a syntax-tree design easier - except the documentation. |
I upgraded my grammar-generation script I use to generate the vim-syntax-highlighting-rules to put out a TextMate-grammer.
The script can be found here: https://github.com/pboettch/vim-cmake-syntax/tree/textmate-grammer-generation
This change might address item #4508
This changes visible behavior
The following changes are proposed:
Other Notes/Information
This is a proposal for discussion. I learnt TextMate-grammar just recently and I'm relatively new to vsCode. There is
a lot of space for improvements. Modules are not at all handled, as an example.
Here is a screenshot of a CMake-Files using the Monokai Dimmed-theme
Final Version Description:
This pull request improves the CMake syntax highlighting in the extension by extending variable recognition and adding better colorization for property commands and their arguments. The changes update the grammar to recognize more CMake variables, especially those related to compiler and toolchain families, and introduce scoped highlighting for commands like
set_property,get_property, and related property commands. Test coverage is expanded to ensure these new highlighting features work as expected.Syntax highlighting improvements:
knownVariablesto include compiler/toolchain family variables and other recently added CMake variables, improving detection and highlighting in the editor.knownVariablesrule.Property command highlighting:
scopedPropertyCommandgrammar rule to highlight property-related commands (set_property,get_property, etc.), their scope keywords (likeGLOBAL,TARGET), and well-known property names with distinct colors. [1] [2]Test coverage:
test/visual-syntax-test/CMakeLists.txtwith a comprehensive set of examples covering the new variable recognition and property command highlighting, ensuring the changes are tested and validated.Documentation:
CHANGELOG.mdto document the improved CMake syntax highlighting and the extension of variable and property command recognition.