Skip to content

Commit

Permalink
tree-sitter-surrealdb
Browse files Browse the repository at this point in the history
  • Loading branch information
siph committed Feb 27, 2024
1 parent 5c85ae8 commit 131a992
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 7 deletions.
18 changes: 16 additions & 2 deletions config/treesitter/treesitter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,38 @@
nixvimInjections = true;

languageRegister.nu = "nu";
languageRegister.surrealdb = "surrealdb";

grammarPackages = with pkgs;
vimPlugins.nvim-treesitter.passthru.allGrammars
++ [tree-sitter-grammars.tree-sitter-nu];
++ (with tree-sitter-grammars; [tree-sitter-nu tree-sitter-surrealdb]);
};
};

extraFiles = with pkgs.tree-sitter-grammars; {
"/queries/nu/highlights.scm" = builtins.readFile "${tree-sitter-nu}/queries/nu/highlights.scm";
"/queries/nu/injections.scm" = builtins.readFile "${tree-sitter-nu}/queries/nu/injections.scm";

"/queries/surrealdb/highlights.scm" = builtins.readFile "${tree-sitter-surrealdb}/queries/highlights.scm";
};

filetype.extension.nu = "nu";
filetype = {
extension = {
nu = "nu";
surql = "surql";
surrealql = "surql";
};
};

extraConfigLua = ''
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.nu = {
filetype = "nu",
}
parser_config.surrealdb = {
filetype = "surql",
}
'';
}
19 changes: 18 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
url = "github:nushell/tree-sitter-nu";
flake = false;
};
tree-sitter-surrealdb = {
url = "github:dariuscorvus/tree-sitter-surrealdb";
flake = false;
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -23,6 +27,7 @@
nixvim,
flake-parts,
tree-sitter-nu,
tree-sitter-surrealdb,
pre-commit-hooks,
...
} @ inputs:
Expand Down Expand Up @@ -55,7 +60,7 @@
inherit system;
overlays = builtins.attrValues {
default = import ./overlay {
inherit nixvim tree-sitter-nu lib system;
inherit nixvim tree-sitter-nu tree-sitter-surrealdb lib system;
};
};
};
Expand Down
13 changes: 10 additions & 3 deletions overlay/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
nixvim,
tree-sitter-nu,
tree-sitter-surrealdb,
...
}: let
additions = final: _prev:
Expand All @@ -11,9 +12,15 @@
};

modifications = final: prev: {
tree-sitter-grammars.tree-sitter-nu = final.callPackage ../pkgs/tree-sitter-grammars/nushell.nix {
inherit (final.tree-sitter) buildGrammar;
inherit tree-sitter-nu;
tree-sitter-grammars = {
tree-sitter-nu = final.callPackage ../pkgs/tree-sitter-grammars/nushell.nix {
inherit (final.tree-sitter) buildGrammar;
inherit tree-sitter-nu;
};
tree-sitter-surrealdb = final.callPackage ../pkgs/tree-sitter-grammars/surrealdb.nix {
inherit (final.tree-sitter) buildGrammar;
inherit tree-sitter-surrealdb;
};
};
};
in
Expand Down
12 changes: 12 additions & 0 deletions pkgs/tree-sitter-grammars/surrealdb.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
tree-sitter-surrealdb,
buildGrammar,
}: let
inherit ((builtins.fromJSON (builtins.readFile ../../flake.lock)).nodes.tree-sitter-surrealdb.locked) rev;
version = "0.0.0+${rev}";
in
buildGrammar {
inherit version;
language = "surrealdb";
src = tree-sitter-surrealdb;
}

0 comments on commit 131a992

Please sign in to comment.