plugins/ts-autotag: init + test

This commit is contained in:
Gaetan Lepage 2023-06-01 10:31:35 +02:00 committed by Gaétan Lepage
parent 535fc7d5d3
commit df25456aaa
3 changed files with 146 additions and 0 deletions

View file

@ -43,6 +43,7 @@
./languages/treesitter/treesitter-playground.nix
./languages/treesitter/treesitter-rainbow.nix
./languages/treesitter/treesitter-refactor.nix
./languages/treesitter/ts-autotag.nix
./languages/typst/typst-vim.nix
./languages/vimtex.nix
./languages/zig.nix

View file

@ -0,0 +1,89 @@
{
pkgs,
lib,
config,
...
}:
with lib; let
helpers = import ../../helpers.nix {inherit lib;};
in {
options.plugins.ts-autotag =
helpers.extraOptionsOptions
// {
enable = mkEnableOption "nvim-ts-autotag";
package = helpers.mkPackageOption "ts-autotag" pkgs.vimPlugins.nvim-ts-autotag;
filetypes =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''
[
"html"
"javascript"
"typescript"
"javascriptreact"
"typescriptreact"
"svelte"
"vue"
"tsx"
"jsx"
"rescript"
"xml"
"php"
"markdown"
"astro"
"glimmer"
"handlebars"
"hbs"
]
''
"Filetypes for which ts-autotag should be enabled.";
skipTags =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''
[
"area"
"base"
"br"
"col"
"command"
"embed"
"hr"
"img"
"slot"
"input"
"keygen"
"link"
"meta"
"param"
"source"
"track"
"wbr"
"menuitem"
]
''
"Which tags to skip.";
};
config = let
cfg = config.plugins.ts-autotag;
in
mkIf cfg.enable {
warnings = mkIf (!config.plugins.treesitter.enable) [
"Nixvim: ts-autotag needs treesitter to function as intended"
];
extraPlugins = [cfg.package];
plugins.treesitter.moduleConfig.autotag =
{
enable = true;
inherit (cfg) filetypes;
skip_tags = cfg.skipTags;
}
// cfg.extraOptions;
};
}

View file

@ -0,0 +1,56 @@
{
empty = {
plugins = {
treesitter.enable = true;
ts-autotag.enable = true;
};
};
default = {
plugins = {
treesitter.enable = true;
ts-autotag = {
enable = true;
filetypes = [
"html"
"javascript"
"typescript"
"javascriptreact"
"typescriptreact"
"svelte"
"vue"
"tsx"
"jsx"
"rescript"
"xml"
"php"
"markdown"
"astro"
"glimmer"
"handlebars"
"hbs"
];
skipTags = [
"area"
"base"
"br"
"col"
"command"
"embed"
"hr"
"img"
"slot"
"input"
"keygen"
"link"
"meta"
"param"
"source"
"track"
"wbr"
"menuitem"
];
};
};
};
}