Skip to content

Commit f2ebc37

Browse files
committed
chore(injections): add support injections for mkBefore/mkAfter in spesific namespace
1 parent a42dde4 commit f2ebc37

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed

pkgs/injections-scm/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
res =
1616
# add mkRawFn, mkLuaFn highlight
17-
lib.replaceString "mkRaw" "(mkRaw|mkRawFn|mkLuaFn)" ctx
17+
lib.replaceStrings ["mkRaw" "__raw"] ["(mkRaw|mkRawFn|mkLuaFn)" "__raw|capabilities"] ctx
1818
+ lib.concatStrings (map builtins.readFile list-scm)
1919
;
2020

pkgs/injections-scm/extras.scm

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
(binding
2+
attrpath: (attrpath
3+
(identifier) @_path)
4+
expression: [
5+
(apply_expression
6+
function: (_) @_func
7+
argument: [
8+
(string_expression
9+
((string_fragment) @injection.content
10+
(#set! injection.language "lua")))
11+
(indented_string_expression
12+
((string_fragment) @injection.content
13+
(#set! injection.language "lua")))
14+
]
15+
(#match? @_func "(^|\\.)(mkBefore|mkAfter)$"))
16+
]
17+
(#match? @_path "(^(extraConfigLua(Pre|Post)?|capabilities))$"))
18+
19+
20+
(binding
21+
attrpath: (attrpath
22+
(identifier) @_path)
23+
expression: [
24+
(apply_expression
25+
function: (_) @_func
26+
argument: [
27+
(string_expression
28+
((string_fragment) @injection.content
29+
(#set! injection.language "vim")))
30+
(indented_string_expression
31+
((string_fragment) @injection.content
32+
(#set! injection.language "vim")))
33+
]
34+
(#match? @_func "(^|\\.)(mkBefore|mkAfter)$"))
35+
]
36+
(#match? @_path "(^extraConfigVim(Pre|Post)?)$"))
37+
38+
(binding
39+
attrpath: (attrpath
40+
(identifier) @namespace
41+
(identifier) @name)
42+
expression: [
43+
(apply_expression
44+
function: (_) @_func
45+
argument: [
46+
(string_expression
47+
((string_fragment) @injection.content
48+
(#set! injection.language "lua")))
49+
(indented_string_expression
50+
((string_fragment) @injection.content
51+
(#set! injection.language "lua")))
52+
]
53+
(#match? @_func "(^|\\.)(mkBefore|mkAfter)$"))
54+
]
55+
(#match? @namespace "^luaConfig$")
56+
(#match? @name "^(pre|post|content)$"))
57+
58+
(binding
59+
attrpath: (attrpath
60+
(identifier) @_path)
61+
expression: [
62+
(attrset_expression
63+
(binding_set
64+
(binding
65+
attrpath: (attrpath
66+
(identifier) @_nested_path)
67+
expression: [
68+
(apply_expression
69+
function: (_) @_func
70+
argument: [
71+
(string_expression
72+
((string_fragment) @injection.content
73+
(#set! injection.language "lua")))
74+
(indented_string_expression
75+
((string_fragment) @injection.content
76+
(#set! injection.language "lua")))
77+
]
78+
(#match? @_func "(^|\\.)(mkBefore|mkAfter)$"))
79+
]
80+
(#match? @_nested_path "^(pre|post|content)$"))))
81+
]
82+
(#match? @_path "^luaConfig$"))

pkgs/injections-scm/onAttach-function.scm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
(indented_string_expression
1111
((string_fragment) @injection.content
1212
(#set! injection.language "lua")))
13+
(apply_expression
14+
function: (_) @_func
15+
argument: [
16+
(string_expression
17+
((string_fragment) @injection.content
18+
(#set! injection.language "lua")))
19+
(indented_string_expression
20+
((string_fragment) @injection.content
21+
(#set! injection.language "lua")))
22+
]
23+
(#match? @_func "(^|\\.)(mkBefore|mkAfter)$"))
1324
]
1425
(#match? @namespace "^onAttach$")
1526
(#match? @name "^function$"))
@@ -30,6 +41,17 @@
3041
(indented_string_expression
3142
((string_fragment) @injection.content
3243
(#set! injection.language "lua")))
44+
(apply_expression
45+
function: (_) @_func
46+
argument: [
47+
(string_expression
48+
((string_fragment) @injection.content
49+
(#set! injection.language "lua")))
50+
(indented_string_expression
51+
((string_fragment) @injection.content
52+
(#set! injection.language "lua")))
53+
]
54+
(#match? @_func "(^|\\.)(mkBefore|mkAfter)$"))
3355
]
3456
(#match? @_nested_path "^function$"))))
3557
]

0 commit comments

Comments
 (0)