mirror of
https://github.com/vim/vim.git
synced 2026-11-24 13:04:46 +01:00
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>
21 lines
2.3 KiB
Plaintext
Generated
21 lines
2.3 KiB
Plaintext
Generated
| +0#0000e05#a8a8a8255@1>#+0&#ffffff0|!|/|u|s|r|/|b|i|n|/|e|n|v| |b|a|t|s| +0#0000000&@53
|
|
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l|o|c|a|l| |f|e|n| |f|d|c|=|2| |f|d|l|=|8| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@20
|
|
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|s|h|_|f|o|l|d|_|e|n|a|b|l|e|d| |=| |1| +0#0000000&@30
|
|
| +0#0000e05#a8a8a8255@1|#+0#e000e06#ffffff0| |b|a|t|s| |f|i|l|e|_|t|a|g|s|=|s|l|o|w| +0#0000000&@51
|
|
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |b|a|t|s| |i|s| |n|o|t| |a| |t|a|g| |c|o|m@1|e|n|t| +0#0000000&@45
|
|
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
|
|
| +0#0000e05#a8a8a8255@1|b+0#af5f00255#ffffff0|a|t|s|_|r|e|q|u|i|r|e|_|m|i|n|i|m|u|m|_|v|e|r|s|i|o|n| +0#0000000&|1+0#e000002&|.+0#0000000&|5+0#e000002&|.+0#0000000&|0+0#e000002&| +0#0000000&@38
|
|
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
|
|
|-+0#0000e05#a8a8a8255| |s+0#00e0e07#ffffff0|e|t|u|p|(+0#e000e06&|)| +0#0000000&|{+0#e000e06&| +0#0000000&@63
|
|
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@1|l+0#af5f00255&|o|a|d| +0#0000000&|t|e|s|t|_|h|e|l|p|e|r| @54
|
|
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@1|b+0#af5f00255&|a|t|s|_|l|o|a|d|_|l|i|b|r|a|r|y| +0#0000000&|b|a|t|s|-|a|s@1|e|r|t| @41
|
|
||+0#0000e05#a8a8a8255| |}+0#e000e06#ffffff0| +0#0000000&@71
|
|
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
|
|
| +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
|
|
@57|1|,|1| @10|T|o|p|
|