diff --git a/neovim.nix b/neovim.nix index 1603afc..b794bac 100644 --- a/neovim.nix +++ b/neovim.nix @@ -4,7 +4,6 @@ , enableOrgMode ? false , viAlias ? false , vimAlias ? false -, grammarFileTypes ? [ "nix" ] , extraConfig ? "" , extraPlugins ? [ ] , theme ? { } @@ -16,6 +15,7 @@ , lib , nix2lua , substituteAll +, fetchFromGitHub , ... }: @@ -27,9 +27,8 @@ let }; pluginParams = neovimPlugins // { - inherit plugins; - inherit tree-sitter grammarFileTypes; - inherit enableDevIcons enableTabby enableOrgMode; + inherit tree-sitter fetchFromGitHub; + inherit plugins enableDevIcons enableTabby enableOrgMode; themeCfg = theme; lib = myLib; }; diff --git a/plugins/syntax/default.nix b/plugins/syntax/default.nix index a220827..b119c98 100644 --- a/plugins/syntax/default.nix +++ b/plugins/syntax/default.nix @@ -1,18 +1,41 @@ { lib -, nvim-treesitter +, fetchFromGitHub , ... -}: +} @ inputs: let 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 { luaConfig = readFile ./treesitter.lua; plugins = [ - nvimTreesitterWithGrammars + nvim-treesitter ]; }