45 lines
1 KiB
Nix
45 lines
1 KiB
Nix
{ lib
|
|
, runCommand
|
|
, fetchFromGitHub
|
|
, ...
|
|
} @ inputs:
|
|
|
|
|
|
let
|
|
inherit (builtins) readFile;
|
|
|
|
extraGrammars = {
|
|
tree-sitter-d2 = {
|
|
language = "d2";
|
|
src = fetchFromGitHub {
|
|
owner = "pleshevskiy";
|
|
repo = "tree-sitter-d2";
|
|
rev = "a1a2091ebf4521d965e13c918a601b5acb4d1a72";
|
|
sha256 = "sha256-1ZcWhbtmdPDkBoFfswfhlwbFLb2Uwq7lbSTs5wqiFzY=";
|
|
};
|
|
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
|
|
];
|
|
}
|