Files
Grant Hutchins d8ae4348a0 patch 9.2.1254: filetype: Bats files are detected as sh
Problem:  Bats test files are detected as "sh", so plugins and parsers
          cannot tell them apart from plain Bash scripts, and Bats
          extensions are highlighted as plain Bash: the "test" in "@test"
          is highlighted as the test command and the test body is not a
          function body, so it does not fold.
Solution: Detect *.bats files and bats shebang lines as "bats", include
          filetype, indent and syntax scripts that reuse the "sh" ones
          with b:is_bash set, highlight @test with its name and fold its
          body like a function, highlight "# bats test_tags=" and
          "file_tags=" comments and the commands bats-core provides, and
          add a syntax test (Grant Hutchins).

Bats (Bash Automated Testing System) test files are Bash with extensions
such as `@test "name" { ... }` blocks, which Bash parsers like
tree-sitter-bash do not understand.  Tools that do need a filetype to key
on: bash-language-server parses .bats files with a bats dialect, ALE has
bats linters, and tree-sitter-bats provides a grammar for editors that
use tree-sitter.  Highlighting, indenting and the "sh" filetype plugin
behave as before, the same way the "bash" filetype works.

Commands from add-on libraries such as bats-assert are not highlighted.

related: #14039
closes:  #21516

Assisted-by: Claude Opus
Signed-off-by: Grant Hutchins <git@nertzy.com>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2026-10-30 18:05:44 +00:00

21 lines
2.5 KiB
Plaintext
Generated

| +0#0000e05#a8a8a8255@1|#+0#e000e06#ffffff0| |b|a|t|s| |t|e|s|t|_|t|a|g|s|=|f|a|s|t|,| |o|s|:|l|i|n|u|x| +0#0000000&@41
|-+0#0000e05#a8a8a8255| |@+0#af5f00255#ffffff0|t|e|s|t| +0#0000000&|"+0#af5f00255&|a+0#e000002&|d@1|i|t|i|o|n| |{| |w|o|r|k|s|"+0#af5f00255&| +0#0000000&|{+0#e000e06&| +0#0000000&@46
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@1|r+0#af5f00255&|u|n| +0#0000000&|-+0#e000002&|1| +0#0000000&|-+0#e000e06&@1|s|e|p|a|r|a|t|e|-|s|t|d|e|r@1| +0#0000000&|f+0#af5f00255&|a|l|s|e| +0#0000000&@40
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@1|[+0#af5f00255&| +0#0000000&|"+0#af5f00255&|$+0#e000e06&|s|t|a|t|u|s|"+0#af5f00255&| +0#0000000&|-+0#af5f00255&|e|q| +0#0000000&|1+0#e000002&| +0#0000000&|]+0#af5f00255&| +0#0000000&@51
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@1|i+0#af5f00255&|f| |t|r|u|e|;| +0#0000000&|t+0#af5f00255&|h|e|n| +0#0000000&@57
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3>s+0#af5f00255&|k|i|p| +0#0000000&|"+0#af5f00255&|n+0#e000002&|o|t| |y|e|t|"+0#af5f00255&| +0#0000000&@54
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@1|f+0#af5f00255&|i| +0#0000000&@68
||+0#0000e05#a8a8a8255| |}+0#e000e06#ffffff0| +0#0000000&@71
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1|@+0#af5f00255#ffffff0|t|e|s|t| +0#0000000&|u+0#e000002&|n|q|u|o|t|e|d| |n|a|m|e| +0#0000000&|{+0#e000e06&| +0#0000000&|r+0#af5f00255&|u|n| +0#0000000&|t+0#af5f00255&|r|u|e|;| +0#0000000&|}+0#e000e06&| +0#0000000&@39
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
|-+0#0000e05#a8a8a8255| |@+0#af5f00255#ffffff0|t|e|s|t| +0#0000000&|'+0#af5f00255&|s+0#e000002&|i|n|g|l|e| |$|q|u|o|t|e|d|'+0#af5f00255&| +0#0000000&|{+0#e000e06&| +0#0000000&@48
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@1|r+0#af5f00255&|u|n| +0#0000000&|!+0#af5f00255&| +0#0000000&|b+0#af5f00255&|a|t|s|_|p|i|p|e| +0#0000000&|e+0#af5f00255&|c|h|o| +0#e000002&|t|e|s|t| |\+0#e000e06&||| +0#e000002&|g|r|e|p| |-|q| |s|k|i|p| +0#0000000&@29
||+0#0000e05#a8a8a8255| |}+0#e000e06#ffffff0| +0#0000000&@71
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
|-+0#0000e05#a8a8a8255| |@+0#af5f00255#ffffff0|t|e|s|t| +0#0000000&|"+0#af5f00255&|e+0#e000002&|x|p|a|n|d|e|d| |$+0#e000e06&|B|A|T|S|_|T|E|S|T|_|F|I|L|E|N|A|M|E|"+0#af5f00255&| +0#0000000&|{+0#e000e06&| +0#0000000&@34
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@1|b+0#af5f00255&|a|t|s|_|l|o|a|d|_|s|a|f|e| +0#0000000&|h|e|l|p|e|r| @49
||+0#0000e05#a8a8a8255| |}+0#e000e06#ffffff0| +0#0000000&@71
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
@57|1|9|,|5| @9|9|2|%|