mirror of
https://github.com/vim/vim.git
synced 2026-11-23 12:03:36 +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
353 B
Plaintext
Generated
21 lines
353 B
Plaintext
Generated
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
|
|
| +0#0000e05#a8a8a8255@1>e+0#af5f00255#ffffff0|c|h|o| +0#e000002&|@|t|e|s|t| |r|u|n| |s|k|i|p| |l|o|a|d| +0#0000000&@48
|
|
|~+0#4040ff13&| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
|~| @73
|
|
| +0#0000000&@56|3@1|,|1| @9|B|o|t|
|