feat: add initial Nix support

This commit is contained in:
SamuelSehnert 2023-06-01 18:02:08 -07:00 committed by Lewis Russell
parent 2182556aab
commit e2ea37627c
3 changed files with 97 additions and 1 deletions

View file

@ -56,6 +56,7 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [x] `lua`
- [x] `markdown`
- [x] `matlab`
- [x] `nix`
- [x] `norg`
- [x] `ocaml_interface`
- [x] `ocaml`
@ -146,7 +147,6 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [ ] `mermaid`
- [ ] `meson`
- [ ] `nickel`
- [ ] `nix`
- [ ] `ocamllex`
- [ ] `pascal`
- [ ] `perl`

2
queries/nix/context.scm Normal file
View file

@ -0,0 +1,2 @@
(function_expression body: (_ (_) @context.end)) @context
(binding expression: (_ (_) @context.end)) @context

94
test/test.nix Normal file
View file

@ -0,0 +1,94 @@
{
output =
let
l = {
a = false;
b = false;
c = false;
}; #Succe
m = {
a = false;
b = true;
c = false;
}; #Success
n = {
a = false;
b = true;
c = true;
}; #Fail
functions = {
check = pkgs:
list:
let
length =
builtins.length (pkgs.lib.remove false list);
otherfunc = { a, b, c, ... }@nice: a + b + c;
setFunc =
{ a
, b
, c
, ...
}@extras: (
a * b * c
);
in
(length == 0) || (length == 1);
};
in
functions.check l;
}