Created
May 6, 2023 12:48
-
-
Save akiya64/6533dcc0b29bb254777ee74b8cecd6ca to your computer and use it in GitHub Desktop.
:ShowRootHighlightUnderCursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim.api.nvim_create_user_command('ShowRootHighlightUnderCursor', function() | |
local function findRoot(id, tree) | |
local transId = vim.fn.synIDtrans(id) | |
local name = vim.fn.synIDattr(id, 'name') | |
table.insert(tree, name) | |
if id == transId then | |
print(table.concat(tree, ' -> ')) | |
else | |
findRoot(transId, tree) | |
end | |
end | |
local id = vim.fn.synID(vim.fn.line("."), vim.fn.col("."), 0) | |
findRoot(id, {}) | |
end, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By cursor you don't mean mouse cursor, right?
I can't get this to print anything at all 🤔
When executing the user command and my cursor is over a JS variable, for example, it just throws an empty notification window (I changed
print
tovim.notify
).Any idea what could be going on here?