mirror of
https://github.com/nix-community/nixvim.git
synced 2025-12-12 03:51:10 +01:00
We now look for strings inside any function call (apply_expression) provided the root attribute matches our allow-list (e.g., extraConfigLua). Added 3 level nesting support to handle multiple layers of wrapping. Tried breaking them up into sections with some more comments to align with our test file.
187 lines
8 KiB
Scheme
187 lines
8 KiB
Scheme
;; extends
|
|
|
|
;; =============================================================================
|
|
;; Global mkRaw
|
|
;; =============================================================================
|
|
(apply_expression
|
|
function: (_) @_func
|
|
argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
]
|
|
(#match? @_func "(^|\\.)mkRaw$")
|
|
(#set! injection.language "lua"))
|
|
|
|
;; =============================================================================
|
|
;; LUA BINDINGS
|
|
;; Matches: extraConfigLua, __raw, extraConfigLuaPre, extraConfigLuaPost
|
|
;; =============================================================================
|
|
(binding
|
|
attrpath: (attrpath (identifier) @_path)
|
|
expression: [
|
|
; Direct string assignment
|
|
; extraConfigLua = ''...''
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
|
|
; Function wrappers (handles 1-2 levels of nesting)
|
|
; extraConfigLua = mkIf true "..."
|
|
; extraConfigLua = mkIf true (mkOverride 10 "...")
|
|
(apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
]))
|
|
])
|
|
|
|
; Three-level nested wrappers
|
|
; extraConfigLua = mkIf true (mkOverride 10 (mkDefault "..."))
|
|
(apply_expression argument: (parenthesized_expression (apply_expression argument:
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
])))))
|
|
|
|
; Lists (with or without wrapped items)
|
|
; extraConfigLua = mkMerge [ "..." "..." ]
|
|
; extraConfigLua = mkMerge [ (mkIf true "...") "..." ]
|
|
(apply_expression argument: (list_expression [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
]))
|
|
]))
|
|
(list_expression [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
])
|
|
]
|
|
(#any-of? @_path "__raw" "extraConfigLua" "extraConfigLuaPre" "extraConfigLuaPost")
|
|
(#set! injection.language "lua"))
|
|
|
|
;; =============================================================================
|
|
;; LUA CONFIG NESTED ATTRSET
|
|
;; Handles: luaConfig = { pre = ... }
|
|
;; =============================================================================
|
|
|
|
(binding
|
|
attrpath: (attrpath (identifier) @_path)
|
|
expression: (attrset_expression (binding_set (binding
|
|
attrpath: (attrpath (identifier) @_nested)
|
|
expression: [
|
|
; Direct string assignment
|
|
; luaConfig = { pre = ''...'' }
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
|
|
; Function wrappers (handles 1-2 levels of nesting)
|
|
; luaConfig = { pre = mkIf true "..." }
|
|
; luaConfig = { pre = mkIf true (mkOverride 10 "...") }
|
|
(apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
]))
|
|
])
|
|
|
|
; Three-level nested wrappers
|
|
; luaConfig = { pre = mkIf true (mkOverride 10 (mkDefault "...")) }
|
|
(apply_expression argument: (parenthesized_expression (apply_expression argument:
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
])))))
|
|
]
|
|
(#any-of? @_nested "pre" "post" "content")
|
|
)))
|
|
(#eq? @_path "luaConfig")
|
|
(#set! injection.language "lua"))
|
|
|
|
;; =============================================================================
|
|
;; LUA CONFIG DOT NOTATION
|
|
;; Handles: luaConfig.pre = ...
|
|
;; =============================================================================
|
|
(binding
|
|
attrpath: (attrpath (identifier) @ns (identifier) @name)
|
|
expression: [
|
|
; Direct string assignment
|
|
; luaConfig.pre = ''...''
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
|
|
; Function wrappers (handles 1-2 levels of nesting)
|
|
; luaConfig.pre = mkIf true "..."
|
|
; luaConfig.content = mkIf true (mkOverride 10 "...")
|
|
(apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
]))
|
|
])
|
|
|
|
; Three-level nested wrappers
|
|
; luaConfig.post = mkIf true (mkOverride 10 (mkDefault "..."))
|
|
(apply_expression argument: (parenthesized_expression (apply_expression argument:
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
])))))
|
|
]
|
|
(#eq? @ns "luaConfig")
|
|
(#any-of? @name "pre" "post" "content")
|
|
(#set! injection.language "lua"))
|
|
|
|
;; =============================================================================
|
|
;; VIM BINDINGS
|
|
;; Handles: extraConfigVim, extraConfigVimPre, extraConfigVimPost
|
|
;; =============================================================================
|
|
(binding
|
|
attrpath: (attrpath (identifier) @_path)
|
|
expression: [
|
|
; Direct string assignment
|
|
; extraConfigVim = ''...''
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
|
|
; Function wrappers (handles 1-2 levels of nesting)
|
|
; extraConfigVim = mkIf true "..."
|
|
; extraConfigVim = mkIf true (mkOverride 10 "...")
|
|
(apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
]))
|
|
])
|
|
|
|
; Three-level nested wrappers
|
|
; extraConfigVim = mkIf true (mkOverride 10 (mkDefault "..."))
|
|
(apply_expression argument: (parenthesized_expression (apply_expression argument:
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
])))))
|
|
|
|
; Lists (with or without wrapped items)
|
|
; extraConfigVim = mkMerge [ "..." "..." ]
|
|
; extraConfigVim = mkMerge [ (mkIf true "...") "..." ]
|
|
(apply_expression argument: (list_expression [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
(parenthesized_expression (apply_expression argument: [
|
|
(string_expression (string_fragment) @injection.content)
|
|
(indented_string_expression (string_fragment) @injection.content)
|
|
]))
|
|
]))
|
|
]
|
|
(#any-of? @_path "extraConfigVim" "extraConfigVimPre" "extraConfigVimPost")
|
|
(#set! injection.language "vim"))
|