mirror of
https://github.com/ivuorinen/shellspec-zed.git
synced 2026-01-26 11:14:05 +00:00
feat: plugin code, updates
This commit is contained in:
25
languages/shellspec/brackets.scm
Normal file
25
languages/shellspec/brackets.scm
Normal file
@@ -0,0 +1,25 @@
|
||||
; Quote pairs
|
||||
("'" @open "'" @close)
|
||||
("\"" @open "\"" @close)
|
||||
|
||||
; Command substitution
|
||||
("$(" @open ")" @close)
|
||||
("${" @open "}" @close)
|
||||
|
||||
; Parentheses
|
||||
("(" @open ")" @close)
|
||||
|
||||
; Square brackets
|
||||
("[" @open "]" @close)
|
||||
|
||||
; Curly braces
|
||||
("{" @open "}" @close)
|
||||
|
||||
; ShellSpec block structure (if using End keyword)
|
||||
(simple_command
|
||||
(command_name) @_cmd
|
||||
(#match? @_cmd "^(Describe|Context|It|Specify|Example)$")) @open
|
||||
|
||||
(simple_command
|
||||
(command_name) @_end
|
||||
(#eq? @_end "End")) @close
|
||||
29
languages/shellspec/config.toml
Normal file
29
languages/shellspec/config.toml
Normal file
@@ -0,0 +1,29 @@
|
||||
name = "ShellSpec"
|
||||
grammar = "bash"
|
||||
path_suffixes = ["_spec.sh", ".spec.sh"]
|
||||
line_comments = ["# "]
|
||||
tab_size = 2
|
||||
hard_tabs = false
|
||||
first_line_pattern = "^#!/.*shellspec"
|
||||
|
||||
[[brackets]]
|
||||
start = "'"
|
||||
end = "'"
|
||||
close = true
|
||||
newline = false
|
||||
not_in = ["string", "comment"]
|
||||
|
||||
[[brackets]]
|
||||
start = "\""
|
||||
end = "\""
|
||||
close = true
|
||||
newline = false
|
||||
not_in = ["string", "comment"]
|
||||
|
||||
[[brackets]]
|
||||
start = "$("
|
||||
end = ")"
|
||||
close = true
|
||||
newline = true
|
||||
|
||||
block_comment = { start = ": '", end = "'" }
|
||||
73
languages/shellspec/highlights.scm
Normal file
73
languages/shellspec/highlights.scm
Normal file
@@ -0,0 +1,73 @@
|
||||
; BDD Structure Keywords
|
||||
["Describe" "Context" "ExampleGroup"] @keyword.function
|
||||
["It" "Specify" "Example"] @keyword.function
|
||||
["Todo"] @keyword.function
|
||||
|
||||
; Prefixed block keywords
|
||||
["xDescribe" "xContext" "xExampleGroup" "xIt" "xSpecify" "xExample"] @keyword.function.inactive
|
||||
["fDescribe" "fContext" "fExampleGroup" "fIt" "fSpecify" "fExample"] @keyword.function.focus
|
||||
|
||||
; Control flow
|
||||
["Pending" "Skip"] @keyword.control
|
||||
["When" "The" "Assert"] @keyword.control
|
||||
["End"] @keyword.control
|
||||
|
||||
; Hook keywords
|
||||
["BeforeEach" "AfterEach" "BeforeAll" "AfterAll"] @keyword.function
|
||||
["BeforeCall" "AfterCall" "BeforeRun" "AfterRun"] @keyword.function
|
||||
["Before" "After"] @keyword.function
|
||||
|
||||
; Helper keywords
|
||||
["Include" "Set" "Data" "Parameters" "Dump"] @keyword
|
||||
["Path" "File" "Dir"] @keyword
|
||||
|
||||
; Evaluation keywords
|
||||
["call" "run" "command" "script" "source"] @function.method
|
||||
|
||||
; Assertion keywords
|
||||
["should" "not"] @keyword.operator
|
||||
["output" "stdout" "error" "stderr" "status" "variable" "path"] @variable.builtin
|
||||
|
||||
; Matchers
|
||||
["equal" "eq" "be" "exist" "valid" "satisfy"] @function.method
|
||||
["match" "start_with" "end_with" "include" "contain"] @function.method
|
||||
|
||||
; Modifiers
|
||||
["line" "word" "length" "contents" "result"] @variable.parameter
|
||||
["first" "second" "third" "of"] @variable.parameter
|
||||
|
||||
; Language chains
|
||||
["a" "an" "as" "the"] @keyword.operator
|
||||
|
||||
; Skip conditional
|
||||
(word) @keyword.control
|
||||
(#match? @keyword.control "^Skip\\s+if$")
|
||||
|
||||
; Test descriptions and strings
|
||||
(string) @string
|
||||
(raw_string) @string
|
||||
|
||||
; Comments
|
||||
(comment) @comment
|
||||
|
||||
; Numbers
|
||||
(number) @number
|
||||
|
||||
; Variables
|
||||
(variable_name) @variable
|
||||
(variable_assignment) @variable
|
||||
|
||||
; Function definitions
|
||||
(function_definition
|
||||
name: (word) @function)
|
||||
|
||||
; Command names
|
||||
(command_name) @function
|
||||
|
||||
; Data block markers
|
||||
(word) @punctuation.special
|
||||
(#eq? @punctuation.special "#|")
|
||||
|
||||
; Tags (key:value pairs)
|
||||
(word) @label
|
||||
(#match? @label "\\w+:\\w+")
|
||||
38
languages/shellspec/indents.scm
Normal file
38
languages/shellspec/indents.scm
Normal file
@@ -0,0 +1,38 @@
|
||||
; Indent content inside BDD blocks
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(Describe|Context|ExampleGroup|It|Specify|Example)$")) @indent
|
||||
|
||||
; Indent prefixed blocks
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^[xf](Describe|Context|ExampleGroup|It|Specify|Example)$")) @indent
|
||||
|
||||
; Indent hook content
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(BeforeEach|AfterEach|BeforeAll|AfterAll|BeforeCall|AfterCall|BeforeRun|AfterRun)$")) @indent
|
||||
|
||||
; Indent Data blocks
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(Data|Parameters)$")) @indent
|
||||
|
||||
; Indent function definitions
|
||||
(function_definition) @indent
|
||||
|
||||
; Indent compound statements
|
||||
(compound_statement) @indent
|
||||
|
||||
; Indent conditional statements
|
||||
(if_statement) @indent
|
||||
(for_statement) @indent
|
||||
(while_statement) @indent
|
||||
|
||||
; Indent pipeline continuations
|
||||
(pipeline) @indent
|
||||
|
||||
; Dedent End keyword
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#eq? @_name "End")) @dedent
|
||||
40
languages/shellspec/injections.scm
Normal file
40
languages/shellspec/injections.scm
Normal file
@@ -0,0 +1,40 @@
|
||||
; Inject shell highlighting in function definitions
|
||||
(function_definition
|
||||
body: (compound_statement) @injection.content
|
||||
(#set! injection.language "bash"))
|
||||
|
||||
; Inject shell in command substitutions
|
||||
(command_substitution
|
||||
"$(" @injection.punctuation.bracket
|
||||
(_) @injection.content
|
||||
(#set! injection.language "bash")
|
||||
")" @injection.punctuation.bracket)
|
||||
|
||||
; Inject shell in When blocks with call/run
|
||||
(simple_command
|
||||
(command_name) @_when
|
||||
(#eq? @_when "When")
|
||||
(word) @_action
|
||||
(#match? @_action "^(call|run)$")
|
||||
(word)+ @injection.content
|
||||
(#set! injection.language "bash"))
|
||||
|
||||
; Inject shell in arithmetic expressions
|
||||
(arithmetic_expansion
|
||||
"$((" @injection.punctuation.bracket
|
||||
(_) @injection.content
|
||||
(#set! injection.language "bash")
|
||||
"))" @injection.punctuation.bracket)
|
||||
|
||||
; Inject shell in process substitution
|
||||
(process_substitution
|
||||
"<(" @injection.punctuation.bracket
|
||||
(_) @injection.content
|
||||
(#set! injection.language "bash")
|
||||
")" @injection.punctuation.bracket)
|
||||
|
||||
(process_substitution
|
||||
">(" @injection.punctuation.bracket
|
||||
(_) @injection.content
|
||||
(#set! injection.language "bash")
|
||||
")" @injection.punctuation.bracket)
|
||||
33
languages/shellspec/outline.scm
Normal file
33
languages/shellspec/outline.scm
Normal file
@@ -0,0 +1,33 @@
|
||||
; Test suites
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(Describe|Context|ExampleGroup)$")
|
||||
(word) @name) @item
|
||||
|
||||
; Individual tests
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(It|Specify|Example)$")
|
||||
(word) @name) @item
|
||||
|
||||
; Focused tests
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^f(Describe|Context|It|Specify|Example)$")
|
||||
(word) @name) @item
|
||||
|
||||
; Skipped tests
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^x(Describe|Context|It|Specify|Example)$")
|
||||
(word) @name) @item
|
||||
|
||||
; Hooks
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(BeforeEach|AfterEach|BeforeAll|AfterAll)$")
|
||||
(word) @name) @item
|
||||
|
||||
; Function definitions
|
||||
(function_definition
|
||||
name: (word) @name) @item
|
||||
29
languages/shellspec/runnables.scm
Normal file
29
languages/shellspec/runnables.scm
Normal file
@@ -0,0 +1,29 @@
|
||||
; Individual test execution
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(It|Specify|Example)$")
|
||||
(word) @run) @shellspec-test
|
||||
|
||||
; Test suite execution
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(Describe|Context|ExampleGroup)$")
|
||||
(word) @run) @shellspec-suite
|
||||
|
||||
; Focused test execution
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^f(It|Specify|Example)$")
|
||||
(word) @run) @shellspec-focused-test
|
||||
|
||||
; Focused suite execution
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^f(Describe|Context|ExampleGroup)$")
|
||||
(word) @run) @shellspec-focused-suite
|
||||
|
||||
; Pending test markers
|
||||
(simple_command
|
||||
(command_name) @_name
|
||||
(#match? @_name "^(Pending|Todo)$")
|
||||
(word) @run) @shellspec-pending
|
||||
Reference in New Issue
Block a user