playground icon indicating copy to clipboard operation
playground copied to clipboard

Get highlight group function to use in lua config

Open nikolightsaber opened this issue 2 years ago • 0 comments

Hello,

I use this plugin in my neovim to work with the lsp document_highlight() function

I dynamically change the LspReferenceText", "LspReferenceRead", "LspReferenceWrite highlight groups to the highlight group under the cursor but bold see gif.

documenthighlight

To get the highlight group under the cursor felt so much more difficult than it should be as :echo synIDattr(synID(line("."), col("."), 1), "name") does not work with Treesitter.

Luckily I found this plugin, unfortunately I could not find a simple function that just returns the current highlightgroup as a string, so I used the string returned by playground.get_treesitter_hl() and parsed it to get the highlight group.

As you probably know the string changed the last few commits so I still use use { 'nvim-treesitter/playground', commit = "787a7a8d4444e58467d6b3d4b88a497e7d494643" } (3 or 4 commits behind).

I would really appreciate a function playround.get_highlight_under_cursor() to use in my config

Thanks in advance !

PS the parsing function is in the function in the GIF

nikolightsaber avatar Apr 17 '22 13:04 nikolightsaber