-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can you tell markid to ignore some identifiers? #5
Comments
Hi @Jacob-Flasheye , Thanks a lot! In principle, you can create a custom Tree-Sitter query for identifier selection and set it in Hint: You can use the tool Tree-Sitter Playground to play around with queries. Best regards, |
Thanks for the answer. I've tried to use the playground, but the problem is I don't understand the language used to perform queries, and I've struggled to find resources explaining it. If you know a good resource, please share it, otherwise I'll keep looking! |
Here are some tips for writing queries. |
Thank you, that's exactly what I needed! |
I use this query to ignore any markit.queries = {
default = '((identifier) @markid (#not-any-of? @markid "require" "ipairs"))',
} |
@David-Kunz Hi sir. I wonder if it's possible for Markid to match any ((function_declaration name:(identifier) @ignoreMe)) Or is there a way for me to write a query that ignores any |
Hi @ziontee113 , Unfortunately I haven't played around with exclusion queries, but you can try it with treesitter-playground. Maybe with negated fields?
|
Hi @David-Kunz , I did try around with exclusion queries with no success. I feel that it's up to Markid to handle exclusion queries logic if there's not a way to write exclusion queries like so 🤔 Also |
@ziontee113 , I see. I'd rather not include that in markid as this would mean to not only retrieve all matches for the first query, but also for the exclusion query and then comparing both. This could cripple the performance. |
I agree. Thank you very much for the amazing plugin ❤️ |
Thank you, @ziontee113 ! |
@David-Kunz I was trying to ignore the params highlight and I found of a useful queries = {
default = '((identifier) @markid (#not-has-parent? @markid parameters typed_parameter typed_default_parameter))',
}, But doesn't really |
Thanks for the info @igorgue . What happens if you run this query in TSPlayground, are the right identifiers highlighted? I would imagine that only the identifiers in the function signature are excluded, not the ones un the function body. |
Hi @David-Kunz , @igorgue , I can confirm this query works on Treesitter Playground and with Markid:
or
|
@David-Kunz It's okay I just wanted to help, but no, the query would get the identifier in the params but it'd still get selected since it's an identifier in the block of the function... I'm still thinking about the query |
@David-Kunz maybe like [1] https://github.com/mhartington/formatter.nvim/tree/master/lua/formatter/filetypes |
That's true @igorgue , for many it's too colourful. It's just hard to come up with better defaults without introducing many language-specific queries. I haven't yet come to a solution. |
Hi!
I really like the idea behind this plugin, but there are some identifiers that I do not want it to highlight, for example the identifier in between the
from
andimport
in this python code:How would I instruct markid to ignore identifiers depending on their place in the tree?
The text was updated successfully, but these errors were encountered: