add d2 tree-sitter grammar

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-12 21:50:03 +03:00
parent 70c85a004f
commit d576379760
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
2 changed files with 30 additions and 8 deletions

View file

@ -4,7 +4,6 @@
, enableOrgMode ? false , enableOrgMode ? false
, viAlias ? false , viAlias ? false
, vimAlias ? false , vimAlias ? false
, grammarFileTypes ? [ "nix" ]
, extraConfig ? "" , extraConfig ? ""
, extraPlugins ? [ ] , extraPlugins ? [ ]
, theme ? { } , theme ? { }
@ -16,6 +15,7 @@
, lib , lib
, nix2lua , nix2lua
, substituteAll , substituteAll
, fetchFromGitHub
, ... , ...
}: }:
@ -27,9 +27,8 @@ let
}; };
pluginParams = neovimPlugins // { pluginParams = neovimPlugins // {
inherit plugins; inherit tree-sitter fetchFromGitHub;
inherit tree-sitter grammarFileTypes; inherit plugins enableDevIcons enableTabby enableOrgMode;
inherit enableDevIcons enableTabby enableOrgMode;
themeCfg = theme; themeCfg = theme;
lib = myLib; lib = myLib;
}; };

View file

@ -1,18 +1,41 @@
{ lib { lib
, nvim-treesitter , fetchFromGitHub
, ... , ...
}: } @ inputs:
let let
inherit (builtins) readFile; inherit (builtins) readFile;
nvimTreesitterWithGrammars = nvim-treesitter.withAllGrammars; 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: tree-sitter.allGrammars);
nvim-treesitter = inputs.nvim-treesitter.overrideAttrs (oldAttrs: {
postPatch = ''
rm -r parser
ln -s ${grammars} parser
ln -s ${../.}/queries queries/d2
'';
});
in in
{ {
luaConfig = readFile ./treesitter.lua; luaConfig = readFile ./treesitter.lua;
plugins = [ plugins = [
nvimTreesitterWithGrammars nvim-treesitter
]; ];
} }