luisiacc / gruvbox-baby

Gruvbox theme for neovim with full 🎄TreeSitter support.
MIT License
390 stars 28 forks source link

Added new Treesitter capture names #76

Closed karloskar closed 7 months ago

karloskar commented 7 months ago

A recent Treesitter change left some tokens not matched by capture names. This is an attempt to add those new capture names.

I let the old ones stay since I imagined they would be useful to others not running the most recent Neovim version(s).

gheritarish commented 7 months ago

I did similar changes recently, and it seems your list completes mine. I'll share my diff if you want, so note that I did a full change, instead of just adding the new capture names. Don't hesitate to reach out if you have questions about it / want some help.

diff --git a/lua/gruvbox-baby/theme.lua b/lua/gruvbox-baby/theme.lua
index e405763..a103377 100644
--- a/lua/gruvbox-baby/theme.lua
+++ b/lua/gruvbox-baby/theme.lua
@@ -91,6 +91,7 @@ function M.setup(config)
     EndOfBuffer = { fg = c.background },

     -- Tree Sitter
+    ["@attribute"] = { fg = c.orange, style = "bold" },
     ["@boolean"] = { fg = c.orange },
     ["@define"] = { fg = c.red },
     ["@comment"] = { fg = c.comment, style = config.comment_style },
@@ -104,43 +105,44 @@ function M.setup(config)
     ["@string"] = { fg = c.soft_green, style = config.string_style },
     ["@character"] = { fg = c.soft_green },
     ["@number"] = { fg = c.magenta },
-    ["@namespace"] = { fg = c.light_blue },
+    ["@number.float"] = { fg = c.magenta },
     ["@func.builtin"] = { fg = c.soft_yellow },
     ["@function"] = { fg = c.soft_yellow, style = config.function_style },
     ["@function.call"] = { fg = c.soft_yellow, style = config.function_style },
     ["@function.builtin"] = { fg = c.soft_yellow, style = config.function_style },
     ["@func.macro"] = { fg = c.soft_yellow },
-    ["@parameter"] = { fg = c.blue_gray, style = "nocombine" },
-    ["@parameter.reference"] = { fg = c.dark_gray },
-    ["@method"] = { fg = c.soft_yellow, style = config.function_style },
-    ["@method.call"] = { fg = c.soft_yellow, style = config.function_style },
-    ["@field"] = { fg = c.light_blue },
     ["@property"] = { fg = c.blue_gray },
     ["@constructor"] = { fg = c.clean_green, style = "nocombine" },
-    ["@conditional"] = { fg = c.red },
-    ["@repeat"] = { fg = c.red },
-    ["@label"] = { fg = c.blue_gray },
     ["@keyword"] = { fg = c.red, style = config.keyword_style },
-    ["@keyword.return"] = { fg = c.red, style = config.keyword_style },
+    ["@keyword.conditional"] = { fg = c.red },
+    ["@keyword.exception"] = { fg = c.red },
     ["@keyword.function"] = { fg = c.red, style = config.keyword_style },
     ["@keyword.operator"] = { fg = c.red },
+    ["@keyword.repeat"] = { fg = c.red },
+    ["@keyword.return"] = { fg = c.red, style = config.keyword_style },
+    ["@label"] = { fg = c.blue_gray },
+    ["@markup"] = { fg = c.soft_yellow },
+    ["@markup.strong"] = { fg = c.soft_yellow, style = "bold" },
+    ["@markup.emphasis"] = { fg = c.soft_yellow, style = "italic" },
+    ["@markup.underline"] = { fg = c.soft_yellow, style = "underline" },
+    ["@markup.strike"] = { fg = c.medium_gray, style = "strikethrough" },
+    ["@markup.title"] = { fg = c.soft_yellow },
+    ["@markup.literal"] = { fg = c.soft_yellow },
+    ["@module"] = { fg = c.light_blue },
     ["@operator"] = { fg = c.foreground },
-    ["@exception"] = { fg = c.red },
     ["@type"] = { fg = c.clean_green },
     ["@type.builtin"] = { fg = c.blue_gray },
     ["@type.qualifier"] = { fg = c.orange },
     ["@storageclass.lifetime"] = { fg = c.orange },
     ["@structure"] = { fg = c.blue_gray },
+    ["@uri"] = { fg = c.soft_yellow },
     ["@variable"] = { fg = c.light_blue, style = config.variable_style },
     ["@variable.builtin"] = { fg = c.blue_gray },
-    ["@text"] = { fg = c.soft_yellow },
-    ["@text.strong"] = { fg = c.soft_yellow, style = "bold" },
-    ["@text.emphasis"] = { fg = c.soft_yellow, style = "italic" },
-    ["@text.underline"] = { fg = c.soft_yellow, style = "underline" },
-    ["@text.strike"] = { fg = c.medium_gray, style = "strikethrough" },
-    ["@text.title"] = { fg = c.soft_yellow },
-    ["@text.literal"] = { fg = c.soft_yellow },
-    ["@uri"] = { fg = c.soft_yellow },
+    ["@variable.parameter"] = { fg = c.blue_gray, style = "nocombine" },
+    ["@variable.parameter.reference"] = { fg = c.dark_gray },
+    ["@function.method"] = { fg = c.soft_yellow, style = config.function_style },
+    ["@function.method.call"] = { fg = c.soft_yellow, style = config.function_style },
+    ["@variable.field"] = { fg = c.light_blue },
     ["@tag"] = { fg = c.clean_green },
     ["@tag.delimiter"] = { fg = c.comment },
     ["@tag.attribute"] = { fg = c.soft_yellow },
luisiacc commented 7 months ago

Thank you!

karloskar commented 7 months ago

My knowledge of Treesitter terminology is not that deep. Where does your capture names, that doesn't exist in my PR, come from @gheritarish?

I did a few visual diffs for where the highlighting were different after the Treesitter update and were satisfied by my changes.

gheritarish commented 7 months ago

I went into the code of the commit you linked mostly @karloskar. Especially for stuff like python decorators, which are now under the @attribute capture according to the CONTRIBUTING.md file. That, and the code modifications for python file.

Mostly, after a nvim upgrade I was lost with the new colors, and tried to fix it by modifying stuff as I went, until it seemed fine 😅

But your update is great and enough, the only color change before / after is python decorator, going from orange to purple. Is that a problem? Probably not, just a question of habit.

karloskar commented 7 months ago

There seem to be a specific capture for Python attributes already in place here. And my decorators are orange :sweat_smile: