Debian Codegraph @

runtime/queries/just/injections.scm

raw symbols SCIP
1 ; Specify nested languages that live within a `justfile`
2
3 ; ================ Always applicable ================
4
5 ((comment) @injection.content
6 (#set! injection.language "comment"))
7
8 ; Highlight the RHS of `=~` as regex
9 ((regex
10 (_) @injection.content)
11 (#set! injection.language "regex"))
12
13 ; ================ Global defaults ================
14
15 ; Default recipe lines to be bash, but exclude interpolation nodes
16 ; This prevents bash's rainbow brackets from interfering with just's {{ }} markers
17 ; Use injection.combined to combine all recipe lines so bash can parse multi-line constructs
18 (recipe_body
19 !shebang
20 (recipe_line) @injection.content
21 (#set! injection.language "bash")
22 (#set! injection.combined))
23
24 (external_command
25 (content) @injection.content
26 (#set! injection.language "bash"))
27
28 ; ================ Global language specified ================
29 ; Global language is set with something like one of the following:
30 ;
31 ; set shell := ["bash", "-c", ...]
32 ; set shell := ["pwsh.exe"]
33 ;
34 ; We can extract the first item of the array, but we can't extract the language
35 ; name from the string with something like regex. So instead we special case
36 ; two things: powershell, which is likely to come with a `.exe` attachment that
37 ; we need to strip, and everything else which hopefully has no extension. We
38 ; separate this with a `#match?`.
39 ;
40 ; Unfortunately, there also isn't a way to allow arbitrary nesting or
41 ; alternatively set "global" capture variables. So we can set this for item-
42 ; level external commands, but not for e.g. external commands within an
43 ; expression without getting _really_ annoying. Should at least look fine since
44 ; they default to bash. Limitations...
45 ; See https://github.com/tree-sitter/tree-sitter/issues/880 for more on that.
46
47 (file
48 (setting "shell" ":=" "[" (string) @_langstr
49 (#match? @_langstr ".*(powershell|pwsh|cmd).*")
50 (#set! injection.language "powershell"))
51 [
52 (recipe
53 (recipe_body
54 !shebang
55 (recipe_line) @injection.content
56 (#set! injection.combined)))
57
58 (assignment
59 (expression
60 (value
61 (external_command
62 (content) @injection.content))))
63 ])
64
65 (file
66 (setting "shell" ":=" "[" (string) @injection.language
67 (#not-match? @injection.language ".*(powershell|pwsh|cmd).*"))
68 [
69 (recipe
70 (recipe_body
71 !shebang
72 (recipe_line) @injection.content
73 (#set! injection.combined)))
74
75 (assignment
76 (expression
77 (value
78 (external_command
79 (content) @injection.content))))
80 ])
81
82 ; ================ Recipe language specified - Helix only ================
83
84 ; Set highlighting for recipes that specify a language using builtin shebang matching
85 (recipe_body
86 (shebang_line) @injection.shebang
87 (recipe_line) @injection.content
88 (#set! injection.combined))