about summary refs log tree commit diff stats
path: root/modules/by-name/nv/nvim/plgs/treesitter/default.nix
blob: 1377cb8a9dd81b96ed99bcdf4b1bf72f390bb1ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# nixos-config - My current NixOS configuration
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of my nixos-config.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
  config,
  pkgs,
  lib,
  ...
}: let
  cfg = config.soispha.programs.nvim;
in {
  home-manager.users.soispha.programs.nixvim = lib.mkIf cfg.enable {
    # NOTE: These are required to build grammars, but I already use the nix grammars <2024-07-13>
    dependencies = {
      tree-sitter.enable = false;
      nodejs.enable = false;
      gcc.enable = false;
    };

    plugins.treesitter = {
      enable = true;

      highlight.enable = true;
      indent.enable = true;
      folding.enable = false;

      # inject nixvim specific highlighting (eg in extraConfigLua).
      nixvimInjections = true;

      grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars ++ [pkgs.tree-sitter-yts];

      # Register the parser to filetype
      languageRegister.yts = "yts";
    };

    # TODO: Is that necessary? <2026-01-18>
    # extraPlugins = [pkgs.tree-sitter-yts];

    # TODO: Remove this by moving the queries in the package to `queries/<lang>/...`' <2026-01-18>
    extraFiles = {
      "queries/yts/highlights.scm".text = ''
        ${lib.strings.fileContents "${pkgs.tree-sitter-yts}/queries/highlights.scm"}
      '';
    };
  };
}