craftzdog / solarized-osaka.nvim

🏯 A clean, dark Neovim theme written in Lua, with support for lsp, treesitter and lots of plugins.
Apache License 2.0
650 stars 29 forks source link

feature: Better syntax highlighting. #22

Closed Redoxahmii closed 5 months ago

Redoxahmii commented 6 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I only use 2 themes in neovim which is this one and tokyonight.nvim and i noticed that tokyonight provides a little more differentiation and highlighting for some tags which do not reciprocate in solarized-osaka and also this theme has some bad highlighting when it comes to markdown. One more thing i wanted to add is if it will have some good support working with flash.nvim as the colors do not match when using it and it is very difficult to differentiate when using it.

Describe the solution you'd like

I would like this to also have that same highlighting as it helps a lot in visually differentiating between tags.

Screenshot from 2024-03-02 08-28-29

This is the solarized-osaka where the components that are being imported and used are not differentiating in color from the other basic html tags whereas if we check this in tokyonight:

Screenshot from 2024-03-02 08-28-44

This shows a clear difference between those tags. This was created from a fork of Tokyonight so implementing those features should not be too difficult as it just needs a value of a different color for that treesitter object as far as i can think.

Describe alternatives you've considered

Currently it seems that only Tokyonight has this implemented and i did check it on gruvbox and catppuccin and they show the same behavior.

Additional context

No response

0xfraso commented 6 months ago

Hi, since solarized-osaka provides on_highlights callback to override your highlights you can use treesitter to do like so:

in you init.lua (or anywhere inside your nvim config) define a user command

vim.api.nvim_create_user_command("HightlightUnderCursor", function()
    local result = vim.treesitter.get_captures_at_cursor(0)
    print(vim.inspect(result))
end, {})

Then call It using :HighlightUnderCursor with your cursor on your HTML custom tag. It will give you a list of available treesitter highlights

Then you can override them using your preferred colors inside the on_highlights function inside your plugin setup:

on_highlights = function(hl, col)
      hl["your treesitter highlight here"] = { fg = "your custom color here" } 

      --- or use provided col param to retrieve colorscheme's palette
      hl["@tag"] = { fg = c.orange }
end,

Remember that you might need to prepend a @ when referencing a treesitter highlight.

Hope It helps

craftzdog commented 6 months ago

Can you tell me which token to update?

0xfraso commented 6 months ago

Just made a quick research and found that the method mentioned above is just deprecated and possible to achieve directly by executing :Inspect with cursor on the interested treesitter node (in our case the react component)

for example, I get the following in a javascript react component

Treesitter
  - @variable.javascript links to @variable javascript
  - @type.javascript links to Type javascript
  - @tag.builtin.javascript links to Statement javascript
  - @tag.javascript links to Statement javascript

the same command executed in a tsx react component gives the following output:

Treesitter
  - @variable.tsx links to @variable tsx
  - @type.tsx links to Type tsx
  - @tag.builtin.tsx links to Statement tsx
  - @tag.tsx tsx

So I guess since solarized-osaka uses mostly treesitter based highlights you can easily override them but It depends on specific language needs

Redoxahmii commented 6 months ago

Just made a quick research and found that the method mentioned above is just deprecated and possible to achieve directly by executing :Inspect with cursor on the interested treesitter node (in our case the react component)

for example, I get the following in a javascript react component

Treesitter
  - @variable.javascript links to @variable javascript
  - @type.javascript links to Type javascript
  - @tag.builtin.javascript links to Statement javascript
  - @tag.javascript links to Statement javascript

the same command executed in a tsx react component gives the following output:

Treesitter
  - @variable.tsx links to @variable tsx
  - @type.tsx links to Type tsx
  - @tag.builtin.tsx links to Statement tsx
  - @tag.tsx tsx

So I guess since solarized-osaka uses mostly treesitter based highlights you can easily override them but It depends on specific language needs

Thanks for the info i also created another issue in the repo where i was facing the same kind of issues when working with .jsx format files as the tags would have altogether different colors for the < signs.

Redoxahmii commented 6 months ago

Can you tell me which token to update?

Treesitter

Redoxahmii commented 6 months ago

@0xfraso sorry for tagging you but would this be considered correct ?

{
    "craftzdog/solarized-osaka.nvim",
    lazy = true,
    config = {
      function()
        require("solarized-osaka").setup({
          on_highlights = function(hl, col)
            hl["@tag.tsx"] = { fg = "#ffffff" }
          end,
        })
      end,
    },
  }

I am not too familiar with treesitter and themes so not sure if this is the right method. Currently this is not displaying any results.

It was a bad mistake of using {} in the config which needed to be removed.

Redoxahmii commented 6 months ago

created a pull which fixes this and also the the white <> tag issue.