From de08e209472c0774f48fc6519b6f1a3f7fcca5c8 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Wed, 7 Dec 2022 17:14:44 +0300 Subject: [PATCH] add d2 tree-sitter to dev editor --- dev/nvim-ts.nix | 49 +++++++++++++++++++++++++++++++++++++++---------- dev/vimrc.vim | 3 +++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/dev/nvim-ts.nix b/dev/nvim-ts.nix index fbc432e..78389ee 100644 --- a/dev/nvim-ts.nix +++ b/dev/nvim-ts.nix @@ -1,29 +1,58 @@ { pkgs ? import { } }: let - d2-vim = pkgs.vimUtils.buildVimPluginFrom2Nix { - name = "d2-vim"; - src = pkgs.fetchFromGitHub { - owner = "terrastruct"; - repo = "d2-vim"; - rev = "ac58c07ba192d215cbbd2b2207f9def808a9283d"; - hash = "sha256-rXUhXVmva4K0PqUboSXUpTqNttwehjkjjsEgTCZbGKI="; + extraGrammars = { + tree-sitter-d2 = { + language = "d2"; + src = ../.; + version = "0.0.0"; }; }; + tree-sitter = (pkgs.tree-sitter.override { inherit extraGrammars; }); + grammars = tree-sitter.withPlugins (g: [ g.tree-sitter-d2 ]); + + nvim-treesitter = pkgs.vimPlugins.nvim-treesitter.overrideAttrs (oldAttrs: { + postPatch = '' + rm -r parser + ln -s ${grammars} parser + + ln -s ${../.}/queries queries/d2 + ''; + }); + + luaRc = '' + local parser_config = require "nvim-treesitter.parsers".get_parser_configs() + parser_config.d2 = {} + + require("nvim-treesitter.configs").setup({ + ensure_installed = { }, + sync_install = false, + + highlight = { + enable = true, + }, + + indent = { + enable = true, + }, + }) + ''; + neovim = pkgs.neovim.override { configure = { customRC = '' source ${./vimrc.vim} + lua <