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