diff --git a/config/treesitter/treesitter.nix b/config/treesitter/treesitter.nix index 484cef1..4f6cb6c 100644 --- a/config/treesitter/treesitter.nix +++ b/config/treesitter/treesitter.nix @@ -6,18 +6,28 @@ 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() @@ -25,5 +35,9 @@ parser_config.nu = { filetype = "nu", } + + parser_config.surrealdb = { + filetype = "surql", + } ''; } diff --git a/flake.lock b/flake.lock index c85972d..ca8c5f2 100644 --- a/flake.lock +++ b/flake.lock @@ -324,7 +324,8 @@ "nixpkgs": "nixpkgs", "nixvim": "nixvim", "pre-commit-hooks": "pre-commit-hooks_2", - "tree-sitter-nu": "tree-sitter-nu" + "tree-sitter-nu": "tree-sitter-nu", + "tree-sitter-surrealdb": "tree-sitter-surrealdb" } }, "systems": { @@ -372,6 +373,22 @@ "repo": "tree-sitter-nu", "type": "github" } + }, + "tree-sitter-surrealdb": { + "flake": false, + "locked": { + "lastModified": 1708450003, + "narHash": "sha256-/xX5lEQKFuLQl6YxUA2WLKGX5P2GBugtYj42WCtA0xU=", + "owner": "dariuscorvus", + "repo": "tree-sitter-surrealdb", + "rev": "17a7ed4481bdaaa35a1372f3a94bc851d634a19e", + "type": "github" + }, + "original": { + "owner": "dariuscorvus", + "repo": "tree-sitter-surrealdb", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 4651348..2b809e7 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; @@ -23,6 +27,7 @@ nixvim, flake-parts, tree-sitter-nu, + tree-sitter-surrealdb, pre-commit-hooks, ... } @ inputs: @@ -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; }; }; }; diff --git a/overlay/default.nix b/overlay/default.nix index d52e1dc..ad743f1 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -2,6 +2,7 @@ lib, nixvim, tree-sitter-nu, + tree-sitter-surrealdb, ... }: let additions = final: _prev: @@ -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 diff --git a/pkgs/tree-sitter-grammars/surrealdb.nix b/pkgs/tree-sitter-grammars/surrealdb.nix new file mode 100644 index 0000000..60a7b52 --- /dev/null +++ b/pkgs/tree-sitter-grammars/surrealdb.nix @@ -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; + }