Reputation: 43
I have a really hard time wanting to extend the shell-script grammar, as it only highlights bash-builtin commands. I want to basically highlight shell commands, not only builtin. For this I tried to extend the grammar with injection but this is not very well documented and so I am running into the same problem over and over, regardless what I am doing. If I inject some commands to be recognized as functions (and therefore highlighted) they are, but they also are highlighted in comments which is highly annoying. I don't get rid of it regardless which combinations I tried. As the support.function.extended.shell token is always the highest value due to injection it is always colorized. Is there any solution on that???
As you can see in the picture builtin commands like "echo" are non-colourized in comments like it hsould be
{
"scopeName": "shellcommand.injection",
"injectionSelector": "L:source.shell -support.function.builtin.shell",
"patterns": [{
"include": "#shell-commands"
}],
"repository": {
"shell-commands": {
"patterns": [{
"match": "(?<=^|;|&|\\s)(systemctl|cp|sed|awk)(?=\\s|;|&|$)",
"name": "support.function.extended.shell"
}]
}
}
}
The output looks like this then...
Upvotes: 4
Views: 2478
Reputation: 65223
You likely need a more specific injection selector. Try either targeting a more specific scope (one that does not include comments) or exclude comments from the selector. I think the second one will work better for your example. Just use the -
negation selector for this:
"injectionSelector": "L:source.shell -support.function.builtin.shell -comment"
Upvotes: 5