mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 17:03:31 +02:00
plugins/treesitter-rainbow: add plugin + test
This commit is contained in:
parent
ff791d20c8
commit
d7967f3ffd
3 changed files with 97 additions and 0 deletions
|
@ -39,6 +39,7 @@
|
|||
./languages/treesitter/treesitter.nix
|
||||
./languages/treesitter/treesitter-context.nix
|
||||
./languages/treesitter/treesitter-playground.nix
|
||||
./languages/treesitter/treesitter-rainbow.nix
|
||||
./languages/treesitter/treesitter-refactor.nix
|
||||
./languages/vimtex.nix
|
||||
./languages/zig.nix
|
||||
|
|
66
plugins/languages/treesitter/treesitter-rainbow.nix
Normal file
66
plugins/languages/treesitter/treesitter-rainbow.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
helpers = import ../../helpers.nix {inherit lib;};
|
||||
in {
|
||||
options.plugins.treesitter-rainbow =
|
||||
helpers.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "treesitter-rainbow";
|
||||
|
||||
package = helpers.mkPackageOption "treesitter-rainbow" pkgs.vimPlugins.nvim-ts-rainbow2;
|
||||
|
||||
disable =
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]"
|
||||
"List of languages you want to disable the plugin for.";
|
||||
|
||||
query =
|
||||
helpers.defaultNullOpts.mkStr "rainbow-parens"
|
||||
"The query to use for finding delimiters.";
|
||||
|
||||
strategy =
|
||||
helpers.defaultNullOpts.mkStr "require('ts-rainbow').strategy.global"
|
||||
"The query to use for finding delimiters. Directly provide lua code.";
|
||||
|
||||
hlgroups =
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
|
||||
''
|
||||
[
|
||||
"TSRainbowRed"
|
||||
"TSRainbowYellow"
|
||||
"TSRainbowBlue"
|
||||
"TSRainbowOrange"
|
||||
"TSRainbowGreen"
|
||||
"TSRainbowViolet"
|
||||
"TSRainbowCyan"
|
||||
]
|
||||
''
|
||||
"The list of highlight groups to apply.";
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.treesitter-rainbow;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
warnings = mkIf (!config.plugins.treesitter.enable) [
|
||||
"Nixvim: treesitter-rainbow needs treesitter to function as intended"
|
||||
];
|
||||
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
plugins.treesitter.moduleConfig.rainbow =
|
||||
{
|
||||
enable = true;
|
||||
|
||||
inherit (cfg) disable;
|
||||
inherit (cfg) query;
|
||||
strategy = helpers.ifNonNull' cfg.strategy (helpers.mkRaw cfg.strategy);
|
||||
inherit (cfg) hlgroups;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{pkgs}: {
|
||||
empty = {
|
||||
plugins = {
|
||||
treesitter.enable = true;
|
||||
treesitter-rainbow.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
default = {
|
||||
plugins = {
|
||||
treesitter.enable = true;
|
||||
treesitter-rainbow = {
|
||||
enable = true;
|
||||
|
||||
disable = [];
|
||||
query = "rainbow-parens";
|
||||
strategy = "require('ts-rainbow').strategy.global";
|
||||
hlgroups = [
|
||||
"TSRainbowRed"
|
||||
"TSRainbowYellow"
|
||||
"TSRainbowBlue"
|
||||
"TSRainbowOrange"
|
||||
"TSRainbowGreen"
|
||||
"TSRainbowViolet"
|
||||
"TSRainbowCyan"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue