From 6dd623dd38c9ec5dee56063c471da66ff9aab79b Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 13 Dec 2022 00:00:47 +0300 Subject: [PATCH] plugins/syntax: fix tree-sitter parsers --- neovim.nix | 3 ++- plugins/syntax/default.nix | 11 +++++++---- plugins/syntax/treesitter.lua | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/neovim.nix b/neovim.nix index b794bac..4a64264 100644 --- a/neovim.nix +++ b/neovim.nix @@ -9,6 +9,7 @@ , theme ? { } , plugins ? { } , wrapNeovim +, runCommand , neovim-unwrapped , tree-sitter , neovimPlugins @@ -27,7 +28,7 @@ let }; pluginParams = neovimPlugins // { - inherit tree-sitter fetchFromGitHub; + inherit runCommand 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 c775dc1..067771a 100644 --- a/plugins/syntax/default.nix +++ b/plugins/syntax/default.nix @@ -1,4 +1,5 @@ { lib +, runCommand , fetchFromGitHub , ... } @ inputs: @@ -24,11 +25,13 @@ let 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 = '' - rm -r parser - mkdir parser - ln -s ${grammars}/d2.so parser/d2.so - ln -s ${extraGrammars.tree-sitter-d2.src}/queries queries/d2 ''; }); diff --git a/plugins/syntax/treesitter.lua b/plugins/syntax/treesitter.lua index 9da58ad..38a2991 100644 --- a/plugins/syntax/treesitter.lua +++ b/plugins/syntax/treesitter.lua @@ -1,3 +1,6 @@ +local parser_config = require("nvim-treesitter.parsers").get_parser_configs() +parser_config.d2 = {} + require("nvim-treesitter.configs").setup({ ensure_installed = {}, sync_install = false,