Skip to content

Custom tree-sitter grammars. #540

Closed Answered by siph
siph asked this question in Q&A
Aug 24, 2023 · 4 comments · 6 replies
Discussion options

You must be logged in to vote

Ok, with the parser working I did some digging and I can see that extraFiles can be used to add files to runtimepath. I can grab those .scm files from the derivation and add them using extraFiles, which will enable those features (highlights, folds, etc...).

Here is the fully working solution I have:

# treesitter.nix
{pkgs, ...}: let
  tree-sitter-nu = pkgs.callPackage ./grammars/nushell.nix {inherit (pkgs.tree-sitter) buildGrammar;};
in {
  plugins.treesitter = {
    enable = true;

    languageRegister.nu = "nu";

    grammarPackages =
      pkgs.vimPlugins.nvim-treesitter.passthru.allGrammars
      ++ [tree-sitter-nu];
  };

  extraFiles = {
    "queries/nu/highlights.scm" = builtins.r…

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@siph
Comment options

Comment options

You must be logged in to vote
1 reply
@GaetanLepage
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@GaetanLepage
Comment options

@GaetanLepage
Comment options

@traxys
Comment options

@siph
Comment options

Answer selected by GaetanLepage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants