From 26d8aac941b0907c5538234c9a97540da4013151 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Wed, 7 Dec 2022 12:59:06 +0300 Subject: [PATCH] add init tree-sitter command --- Makefile | 12 ++++++++++-- flake.nix | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cd3ad44..8b1f90e 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,19 @@ - +TS_CONF := $$HOME/.config/tree-sitter/config.json test: build tree-sitter test -highlight: +highlight: build tree-sitter highlight -t test/highlight/*.d2 build: tree-sitter generate +init: + if [ ! -f "$(TS_CONF)" ]; then \ + tree-sitter init-config; \ + fi + + if [ -z $$(jq '."parser-directories"' $(TS_CONF) | grep $$(dirname $$PWD) ) ]; then \ + jq ".\"parser-directories\" |= . + [\"$$(dirname $$PWD)\"]" $(TS_CONF) > $(TS_CONF); \ + fi diff --git a/flake.nix b/flake.nix index e9d2e5e..a5d0d39 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,7 @@ { devShells.default = pkgs.mkShell { packages = with pkgs; [ + jq nodejs-18_x tree-sitter nodePackages.eslint