cobalt2-vscode icon indicating copy to clipboard operation
cobalt2-vscode copied to clipboard

Add Functionality for Python Decorators

Open VoxelMC opened this issue 1 year ago • 3 comments

Hello! I hope you like this contribution! If you want any changes let me know :)

All I did was add some recognition for decorators in Python.

Before: image

After: image

VoxelMC avatar Jul 22 '23 19:07 VoxelMC

Hello @VoxelMC, thanks for your contribution. These days I've struggled to make cobalt2 to be more compatible with Python (I'm new to this language).

I'm glad to find our thoughts coincide. With your commit I find it impossible to highlight builtin function decorators, including @staticmethod, @classmethod and @property (maybe more? I'm not sure). That's because these builtin decorators use different textmate scopes.

Besides, I'm trying to add some Python semantic token (provided by the extension Pylance) supports to the theme recently.

image

rennsax avatar Jul 25 '23 17:07 rennsax

Hello @VoxelMC,

To deal with the problem I mentioned yesterday, I suggest also adding rules to semanticTokenColors field. Here is an example.

  "semanticTokenColors": {
    // ...
    "*.decorator": {
      "fontStyle": "italic bold" // I prefer bold to underline
    },
  }

image

It looks great for Python. But till now I'm not sure whether this patch would affect other languages.

rennsax avatar Jul 26 '23 12:07 rennsax

Hello @VoxelMC,

To deal with the problem I mentioned yesterday, I suggest also adding rules to semanticTokenColors field. Here is an example.

  "semanticTokenColors": {
    // ...
    "*.decorator": {
      "fontStyle": "italic bold" // I prefer bold to underline
    },
  }

image

It looks great for Python. But till now I'm not sure whether this patch would affect other languages.

Hello @Eitheages, its nice to meet you! I have been busy moving as of late, but I would love to explore this further with you. I like cobalt2 in general and have just started working a lot more in python and I notice a lot of possible semantics improvements. I love the suggestion that you make here, it looks way better than what I proposed.

I will let you know when I get back on this train!

VoxelMC avatar Jul 27 '23 21:07 VoxelMC