'How do I get the value of @punctuation.delimiter?

I want to get information about the tree sitter. Among them, I want to get the value of @punctuation.delimiter. How can I get it?

https://github.com/nvim-treesitter/nvim-treesitter/blob/419153c1f1992ced7f9462d92f0d7505c6ff3137/queries/rust/highlights.scm#L131

In the above case, ":":",""." I want to get the string ":",";",",","".



Solution 1:[1]

You can simply check it by comparing the name of this "decorator" with the character type of the node:

for _, match, _ in query:iter_matches(parent_node, 0, start_row, end_row) do
    for id, node in pairs(match) do
        if character_type == 'punctuation.delimiter' then
            -- do your stuff
        end
    end
end

Here's is an example how I tried to "access" those "decorators" in my query files.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TornaxO7