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
Better "use strict" directive highlighting in ECMAScript #6606
Comments
Thank you for this! It is unfortunate that the query has to be so complicated, though. Additionally, I think it would need to support comments before the const a = function() {
'use strict'
} at which point it may not be worth the effort. My guess is it is pretty uncommon to just have a random string be |
Hmm, its not too hard to fix both of those, I did it in a couple of minutes (you can find the updated queries here) but I agree that it might be more trouble than its worth. At the very least I'd like to see it not highlighted when it isnt an expression (e.g. when its passed as an argument or if its a variable), this dosent fix highlighting the expression in invalid context but its a much simpler query |
Describe the highlighting problem
Currently in ecmascript files strings matching "use strict" exactly are highlighted using
@keyword.directive
, this is mostly fine as most of the time you'll actually see this string is in a valid context, however the current query also highlights this string in places where it makes no sense, for example inconst x = "use strict"
I have created some queries that fix the issue, however they are kinda ugly and i hope there is a better way of fixing this:
Example snippet that causes the problem
Tree-sitter parsing result
Example screenshot
Expected behavior
The Query should only highlight the use strict directive when it actually means something
Output of
:checkhealth nvim-treesitter
Output of
nvim --version
Additional context
No response
The text was updated successfully, but these errors were encountered: