stsewd / tree-sitter-comment

Tree-sitter grammar for comment tags like TODO, FIXME(user).
https://stsewd.dev/tree-sitter-comment/
MIT License
134 stars 9 forks source link

Is it possible to configure how certain comment tags are displayed/classified? #41

Closed nlsun closed 1 month ago

nlsun commented 1 month ago

Right now, the comment tags are displayed differently, for example TODO is more noticeable, but XXX and NOTE are less obvious. Is it possible to add some way to configure how they are displayed? For example I'd like TODO , XXX and NOTE to all be the super noticeable category.

nlsun commented 1 month ago

Ok, so I found a previous issue https://github.com/stsewd/tree-sitter-comment/issues/31 and while the suggestion

vim.api.nvim_set_hl(0, "@text.uri.comment", {bg="#333333"})

pointed me in the right direction, so i figured that what i wanted was

vim.api.nvim_set_hl(0, "@comment.note.comment", { link = "Todo" })

but then that didn't actually work for me. Nothing changed.

I then found a link to the treesitter readme with similar info https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#highlight

-- Highlight the @foo.bar capture group with the "Identifier" highlight group
vim.api.nvim_set_hl(0, "@foo.bar", { link = "Identifier" })

but that was the same info as before.

I tried a couple other things but what finally worked was this suggestion https://www.reddit.com/r/neovim/comments/13u606c/nvim_set_hl_not_working_in_the_config_file/

vim.api.nvim_create_autocmd("ColorScheme", {
    pattern = "*",
    callback = function()
        vim.api.nvim_set_hl(0, "@comment.note.comment", { link = "Todo" })
    end,
})

So now it works! But i'm curious if you have an idea of why this autocmd was necessary, otherwise feel free to close!

stsewd commented 1 month ago

Hi, as you figured out, nvim-treesitter is the place to check for customizing the colors. I guess If you don't want to use an autocommand, you can try putting those settings after your colorscheme loads.