{ lib
, runCommand
, fetchFromGitHub
, ...
} @ inputs:
let
inherit (builtins) readFile;
extraGrammars = {
tree-sitter-d2 = {
language = "d2";
src = fetchFromGitHub {
owner = "pleshevskiy";
repo = "tree-sitter-d2";
rev = "5459cdd0656d400ca7d104de85f5df77c90e8483";
sha256 = "sha256-TmUwK047pg6J9lyl8HQYLjN463eWuY5vlNubQOp4DL8=";
};
version = "0.0.0";
tree-sitter = (inputs.tree-sitter.override { inherit extraGrammars; });
grammars = tree-sitter.withPlugins (g: [ g.tree-sitter-d2 ]);
nvim-treesitter = inputs.nvim-treesitter.withAllGrammars.overrideAttrs (oldAttrs: {
passthru.dependencies = oldAttrs.passthru.dependencies ++ [
(runCommand "nvim-treesitter-d2-grammar" { } ''
mkdir -p $out/parser
ln -s ${grammars}/d2.so $out/parser/d2.so
'')
];
postPatch = ''
ln -s ${extraGrammars.tree-sitter-d2.src}/queries queries/d2
'';
});
in
{
luaConfig = readFile ./treesitter.lua;
plugins = [
nvim-treesitter
}