wookayin / semshi

🌈 Semantic Highlighting for Python in Neovim
79 stars 5 forks source link

Different highlighting for constants a.k.a. ALL_CAPS_VARIABLES #5

Closed borea17 closed 11 months ago

borea17 commented 1 year ago

nvim-treesitter highlights all caps variables differently, while semshi does not.

treesitter semshi
image image
wookayin commented 1 year ago

Hi! I haven't checked the treesitter's query file for python but probably depending on whether it's ALL_CAPS or not, it would assign different semantic tokens. Semshi, however, relies on python's symbol table so does not distinguish tokens based on the literal representation.

So this would be technically possible, by combining "GLOBAL" token and additional regex tests to define additional highlight groups (e.g. semshiConstant) but I'm not so sure yet what would be the best name for such groups.