{ nix2lua, pkgs, ... }: let defaultGrammars = g: [ # g.agda # g.arduino # g.astro g.awk g.bash # g.beancount # g.bibtex # g.blueprint # g.c # g.c_sharp # g.clojure g.cmake g.comment # g.commonlisp # g.cooklang # g.cpp # g.css # g.cuda # g.d # g.d2 # g.dart # g.devicetree g.diff # g.dockerfile # g.dot # g.eex # g.elixir # g.elm # g.elvish g.embedded_template # g.erlang # g.fennel # g.fish # g.foam # g.fortran # g.fusion # g.gdscript g.git_rebase g.gitattributes g.gitignore # g.gleam # g.glimmer # g.glsl # g.go # g.godot_resource # g.gomod # g.gowork # g.graphql # g.hack # g.haskell # g.hcl # g.heex # g.hjson # g.hlsl # g.hocon # g.html g.http # g.java # g.javascript g.jq g.jsdoc g.json # g.json5 # g.jsonc # g.jsonnet # g.julia # g.kotlin # g.lalrpop # g.latex # g.ledger # g.llvm # g.lua # g.m68k g.make g.markdown g.markdown_inline # g.menhir # g.meson # g.nickel # g.ninja g.nix # g.norg # g.ocaml # g.ocaml_interface # g.ocamllex # g.org # g.pascal # g.perl # g.php # g.phpdoc # g.pioasm # g.prisma # g.proto # g.pug # g.python # g.ql # g.qmljs g.query # g.r # g.racket # g.rasi g.regex # g.rego # g.rnoweb # g.rst # g.ruby # g.rust # g.scala g.scheme # g.scss # g.slint # g.solidity # g.sparql # g.sql # g.supercollider # g.surface # g.svelte # g.swift # g.sxhkdrc # g.teal # g.tiger # g.tlaplus g.todotxt # g.toml # g.tsx # g.turtle # g.twig # g.typescript # g.v # g.vala # g.verilog # g.vhs # g.vim # g.vue # g.wgsl g.yaml # g.yang # g.zig ]; in { allGrammars ? false , withGrammars ? defaultGrammars }: with nix2lua.lib; let extraGrammars = { tree-sitter-d2 = { language = "d2"; version = "2023-06-21"; src = pkgs.fetchFromGitea { domain = "git.pleshevski.ru"; owner = "pleshevskiy"; repo = "tree-sitter-d2"; rev = "8a9d50043d58eedf1e375b0e2059e43efd856902"; sha256 = "sha256-ZhVjxo7Xi7DaHN3qabUcykflY74bUqPcOA410fA3zRk="; }; }; }; tree-sitter = pkgs.tree-sitter.override { inherit extraGrammars; }; customGrammars = tree-sitter.withPlugins (g: [ g.tree-sitter-d2 ]); nvimTreesitterWithGrammars = if allGrammars then pkgs.vimPlugins.nvim-treesitter.withAllGrammars else pkgs.vimPlugins.nvim-treesitter.withPlugins withGrammars; finalNvimTreesitter = nvimTreesitterWithGrammars.overrideAttrs (oldAttrs: { passthru.dependencies = oldAttrs.passthru.dependencies ++ [ (pkgs.runCommand "nvim-treesitter-d2-grammar" { } '' mkdir -p $out/parser ln -s ${customGrammars}/d2.so $out/parser/d2.so '') ]; postPatch = '' ln -s ${extraGrammars.tree-sitter-d2.src}/queries queries/d2 ''; }); in { override' = { nvim-treesitter = finalNvimTreesitter; }; nvim-treesitter = [ (local (set "parser_config" (pipe1 (require "nvim-treesitter.parsers") (call0 "get_parser_configs")) )) (set "parser_config.d2" { }) (pipe1 (require "nvim-treesitter.configs") (call "setup" { ensure_installed = { }; sync_install = false; highlight.enable = true; indent.enable = true; }) ) ]; }