diff options
| author | Éric NICOLAS <ccjmne@gmail.com> | 2025-06-05 15:04:43 +0200 |
|---|---|---|
| committer | Christian Clason <ch.clason+github@icloud.com> | 2025-06-09 10:43:31 +0200 |
| commit | 9c03c835fb2c7f0348742221d9c9540a69f47bdd (patch) | |
| tree | aed5052e9c311e351431dee53b9751ddb6ea56ab | |
| parent | feat(cpp): highlight template method call (diff) | |
| download | nvim-treesitter-9c03c835fb2c7f0348742221d9c9540a69f47bdd.tar nvim-treesitter-9c03c835fb2c7f0348742221d9c9540a69f47bdd.tar.gz nvim-treesitter-9c03c835fb2c7f0348742221d9c9540a69f47bdd.tar.bz2 nvim-treesitter-9c03c835fb2c7f0348742221d9c9540a69f47bdd.tar.lz nvim-treesitter-9c03c835fb2c7f0348742221d9c9540a69f47bdd.tar.xz nvim-treesitter-9c03c835fb2c7f0348742221d9c9540a69f47bdd.tar.zst nvim-treesitter-9c03c835fb2c7f0348742221d9c9540a69f47bdd.zip | |
fix(bash): highlight shebang also when spaced
This commit aligns the shebang highlighting in bash syntax to what the
Linux kernel will recognise as a valid shebang construct.
In summary, the kernel will accept both headers:
#!/usr/bin/env lua
#! /usr/bin/env lua
The second one is quite prominently used throughout documentation
online, such as on Wikipedia's page for Shebang (Unix) [1].
Some sources are adamant it wouldn't be supported at a kernel level, but
it looks to me, upon closer inspection of the current kernel code [2],
that it is indeed quite evidently valid. It'll simply skip over to the
first character that's neither a space 0x20 nor a tab 0x09.
[1] https://en.wikipedia.org/wiki/Shebang_(Unix)
[2] https://github.com/torvalds/linux/blob/ec7714e4947909190ffb3041a03311a975350fe0/fs/binfmt_script.c#L44-L71
| -rw-r--r-- | runtime/queries/bash/highlights.scm | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/queries/bash/highlights.scm b/runtime/queries/bash/highlights.scm index 428207b94..6fe370011 100644 --- a/runtime/queries/bash/highlights.scm +++ b/runtime/queries/bash/highlights.scm @@ -269,4 +269,4 @@ ((program . (comment) @keyword.directive @nospell) - (#lua-match? @keyword.directive "^#!/")) + (#lua-match? @keyword.directive "^#![ \t]*/")) |
