mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 18:00:07 -04:00
perf(nix): replace match with lua-match
This commit is contained in:
parent
6e42d823ce
commit
7ba26e7685
2 changed files with 101 additions and 31 deletions
|
|
@ -34,7 +34,7 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "regex")))
|
(#set! injection.language "regex")))
|
||||||
]
|
]
|
||||||
(#match? @_func "(^|\\.)match$")
|
(#lua-match? @_func "^%a*%.*match$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
(binding
|
(binding
|
||||||
|
|
@ -48,7 +48,46 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "bash")))
|
(#set! injection.language "bash")))
|
||||||
]
|
]
|
||||||
(#match? @_path "(^\\w+(Phase|Hook|Check)|(pre|post)[A-Z]\\w+|script)$"))
|
(#lua-match? @_path "^%a+Phase$"))
|
||||||
|
|
||||||
|
(binding
|
||||||
|
attrpath: (attrpath
|
||||||
|
(identifier) @_path)
|
||||||
|
expression: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
]
|
||||||
|
(#lua-match? @_path "^pre%a+$"))
|
||||||
|
|
||||||
|
(binding
|
||||||
|
attrpath: (attrpath
|
||||||
|
(identifier) @_path)
|
||||||
|
expression: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
]
|
||||||
|
(#lua-match? @_path "^post%a+$"))
|
||||||
|
|
||||||
|
(binding
|
||||||
|
attrpath: (attrpath
|
||||||
|
(identifier) @_path)
|
||||||
|
expression: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
]
|
||||||
|
(#lua-match? @_path "^script$"))
|
||||||
|
|
||||||
(apply_expression
|
(apply_expression
|
||||||
function: (_) @_func
|
function: (_) @_func
|
||||||
|
|
@ -67,8 +106,8 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "bash")))
|
(#set! injection.language "bash")))
|
||||||
])))
|
])))
|
||||||
(#match? @_func "(^|\\.)writeShellApplication$")
|
(#lua-match? @_func "^%a*%.*writeShellApplication$")
|
||||||
(#match? @_path "^text$")
|
(#lua-match? @_path "^text$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
(apply_expression
|
(apply_expression
|
||||||
|
|
@ -83,7 +122,7 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "bash")))
|
(#set! injection.language "bash")))
|
||||||
]
|
]
|
||||||
(#match? @_func "(^|\\.)runCommand((No)?CC)?(Local)?$")
|
(#lua-match? @_func "^%a*%.*runCommand%a*$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
((apply_expression
|
((apply_expression
|
||||||
|
|
@ -97,7 +136,35 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "bash")))
|
(#set! injection.language "bash")))
|
||||||
])
|
])
|
||||||
(#match? @_func "(^|\\.)write(Bash|Dash|ShellScript)(Bin)?$")
|
(#lua-match? @_func "^%a*%.*writeBash%a*$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func)
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
])
|
||||||
|
(#lua-match? @_func "^%a*%.*writeDash%a*$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func)
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
])
|
||||||
|
(#lua-match? @_func "^%a*%.*writeShellScript%a*$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
((apply_expression
|
((apply_expression
|
||||||
|
|
@ -111,7 +178,7 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "fish")))
|
(#set! injection.language "fish")))
|
||||||
])
|
])
|
||||||
(#match? @_func "(^|\\.)writeFish(Bin)?$")
|
(#lua-match? @_func "^%a*%.*writeFish%a*$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
((apply_expression
|
((apply_expression
|
||||||
|
|
@ -126,13 +193,12 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "haskell")))
|
(#set! injection.language "haskell")))
|
||||||
])
|
])
|
||||||
(#match? @_func "(^|\\.)writeHaskell(Bin)?$")
|
(#lua-match? @_func "^%a*%.*writeHaskell%a*$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
((apply_expression
|
((apply_expression
|
||||||
function: (apply_expression
|
function: (apply_expression
|
||||||
function: (apply_expression
|
function: (_) @_func)
|
||||||
function: (_) @_func))
|
|
||||||
argument: [
|
argument: [
|
||||||
(string_expression
|
(string_expression
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
|
|
@ -141,13 +207,12 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "javascript")))
|
(#set! injection.language "javascript")))
|
||||||
])
|
])
|
||||||
(#match? @_func "(^|\\.)writeJS(Bin)?$")
|
(#lua-match? @_func "^%a*%.*writeJS%a*$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
((apply_expression
|
((apply_expression
|
||||||
function: (apply_expression
|
function: (apply_expression
|
||||||
function: (apply_expression
|
function: (_) @_func)
|
||||||
function: (_) @_func))
|
|
||||||
argument: [
|
argument: [
|
||||||
(string_expression
|
(string_expression
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
|
|
@ -156,13 +221,12 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "perl")))
|
(#set! injection.language "perl")))
|
||||||
])
|
])
|
||||||
(#match? @_func "(^|\\.)writePerl(Bin)?$")
|
(#lua-match? @_func "^%a*%.*writePerl%a*$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
((apply_expression
|
((apply_expression
|
||||||
function: (apply_expression
|
function: (apply_expression
|
||||||
function: (apply_expression
|
function: (_) @_func)
|
||||||
function: (_) @_func))
|
|
||||||
argument: [
|
argument: [
|
||||||
(string_expression
|
(string_expression
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
|
|
@ -171,13 +235,11 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "python")))
|
(#set! injection.language "python")))
|
||||||
])
|
])
|
||||||
(#match? @_func "(^|\\.)write(PyPy|Python)[23](Bin)?$")
|
(#lua-match? @_func "^%a*%.*writePy%a*%d*%a*$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
((apply_expression
|
((apply_expression
|
||||||
function: (apply_expression
|
function: (_) @_func
|
||||||
function: (apply_expression
|
|
||||||
function: (_) @_func))
|
|
||||||
argument: [
|
argument: [
|
||||||
(string_expression
|
(string_expression
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
|
|
@ -186,7 +248,7 @@
|
||||||
((string_fragment) @injection.content
|
((string_fragment) @injection.content
|
||||||
(#set! injection.language "rust")))
|
(#set! injection.language "rust")))
|
||||||
])
|
])
|
||||||
(#match? @_func "(^|\\.)writeRust(Bin)?$")
|
(#lua-match? @_func "^%a*%.*writeRust%a*$")
|
||||||
(#set! injection.combined))
|
(#set! injection.combined))
|
||||||
|
|
||||||
; (nixosTest) testScript
|
; (nixosTest) testScript
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
{ pkgs, stdenv }:
|
|
||||||
# NOTE: This file is for testing queries. If evaluated with nix, this will probably error.
|
# NOTE: This file is for testing queries. If evaluated with nix, this will probably error.
|
||||||
{
|
{ pkgs, stdenv }: let
|
||||||
|
match = builtins.match;
|
||||||
|
in {
|
||||||
regex = builtins.match "^.*[{](.+)[}].*$" "blahblah {something} blahblah" [ "something" ];
|
regex = builtins.match "^.*[{](.+)[}].*$" "blahblah {something} blahblah" [ "something" ];
|
||||||
|
|
||||||
|
regex2 = match "^.*[{](.+)[}].*$" "blahblah {something} blahblah" [ "something" ];
|
||||||
|
|
||||||
drv1 = stdenv.mkDerivation {
|
drv1 = stdenv.mkDerivation {
|
||||||
buildPhase = "mkdir $out";
|
buildPhase = "mkdir $out";
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
|
@ -23,38 +26,43 @@
|
||||||
echo "bar" > $out/foo.txt
|
echo "bar" > $out/foo.txt
|
||||||
'';
|
'';
|
||||||
|
|
||||||
drv4 = pkgs.writeShellScriptBin "hello" ''
|
drv4 = pkgs.runCommandNoCC "foo-bar" {} ''
|
||||||
|
mkir $out
|
||||||
|
echo "bar" > $out/foo.txt
|
||||||
|
'';
|
||||||
|
|
||||||
|
drv5 = pkgs.writeShellScriptBin "hello" ''
|
||||||
echo "Hello world!"
|
echo "Hello world!"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
drv5 = pkgs.writeFishBin "hello" ''
|
drv6 = pkgs.writeFishBin "hello" ''
|
||||||
echo "Hello world!"
|
echo "Hello world!"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
drv6 = pkgs.writeHaskellBin "hello" ''
|
drv7 = pkgs.writeHaskellBin "hello" ''
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = putStrLn "Hello world!"
|
main = putStrLn "Hello world!"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
drv7 = pkgs.writeJSBin "hello" ''
|
drv8 = pkgs.writeJSBin "hello" ''
|
||||||
console.log('Hello world!');
|
console.log('Hello world!');
|
||||||
'';
|
'';
|
||||||
|
|
||||||
drv8 = pkgs.writePerlBin "hello" ''
|
drv9 = pkgs.writePerlBin "hello" ''
|
||||||
print("Hello world!\n");
|
print("Hello world!\n");
|
||||||
'';
|
'';
|
||||||
|
|
||||||
drv9 = pkgs.writePythonBin "hello" ''
|
drv10 = pkgs.writePythonBin "hello" ''
|
||||||
print("Hello world!");
|
print("Hello world!");
|
||||||
'';
|
'';
|
||||||
|
|
||||||
drv10 = pkgs.writeRustBin "hello" ''
|
drv11 = pkgs.writeRustBin "hello" ''
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello world!");
|
println!("Hello world!");
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
drv11 = {
|
drv12 = {
|
||||||
nodes = null;
|
nodes = null;
|
||||||
testScript = ''
|
testScript = ''
|
||||||
print("Hello world!");
|
print("Hello world!");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue