2024-03-30 14:31:36 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
config =
|
2024-05-29 20:40:03 +02:00
|
|
|
lib.mkIf (config.user.nvim.enable-treesitter && config.user.nvim.enable)
|
2024-03-30 14:31:36 +01:00
|
|
|
{
|
|
|
|
programs.nixvim = let
|
|
|
|
nu-grammar = pkgs.tree-sitter.buildGrammar {
|
|
|
|
language = "nu";
|
|
|
|
version = "0.0.0+rev=358c4f5";
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "nushell";
|
|
|
|
repo = "tree-sitter-nu";
|
|
|
|
rev = "c5b7816043992b1cdc1462a889bc74dc08576fa6";
|
|
|
|
hash = "sha256-P+ixE359fAW7R5UJLwvMsmju7UFmJw5SN+kbMEw7Kz0=";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
# Set filetype to "nu" for files named "*.nu"
|
|
|
|
filetype.extension.nu = "nu";
|
|
|
|
|
|
|
|
# Add our nu parser to treesitter and associate it with nu filetype.
|
|
|
|
extraConfigLua = ''
|
|
|
|
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
|
|
|
parser_config.nu = {
|
|
|
|
filetype = "nu",
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Add the nu injections
|
|
|
|
extraFiles = {
|
|
|
|
"/queries/nu/highlights.scm" = builtins.readFile "${nu-grammar}/queries/nu/highlights.scm";
|
|
|
|
"/queries/nu/injections.scm" = builtins.readFile "${nu-grammar}/queries/nu/injections.scm";
|
|
|
|
"/queries/nu/indents.scm" = builtins.readFile "${nu-grammar}/queries/nu/indents.scm";
|
|
|
|
};
|
|
|
|
|
|
|
|
plugins = {
|
|
|
|
treesitter = {
|
|
|
|
# Register the nu parser for files with "nu" filetype
|
|
|
|
languageRegister.nu = "nu";
|
|
|
|
grammarPackages =
|
|
|
|
[
|
|
|
|
nu-grammar
|
|
|
|
]
|
|
|
|
++ pkgs.vimPlugins.nvim-treesitter.allGrammars;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|