mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-25 10:18:36 +02:00
plugins/ts-autotag: switch to mkNeovimPlugin
This commit is contained in:
parent
7087b6014d
commit
b822078ec1
2 changed files with 138 additions and 102 deletions
|
@ -1,78 +1,103 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
helpers,
|
||||||
config,
|
config,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
{
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
options.plugins.ts-autotag = helpers.neovim-plugin.extraOptionsOptions // {
|
name = "ts-autotag";
|
||||||
enable = mkEnableOption "nvim-ts-autotag";
|
originalName = "nvim-ts-autotag";
|
||||||
|
luaName = "nvim-ts-autotag";
|
||||||
|
defaultPackage = pkgs.vimPlugins.nvim-ts-autotag;
|
||||||
|
|
||||||
package = helpers.mkPluginPackageOption "ts-autotag" pkgs.vimPlugins.nvim-ts-autotag;
|
maintainers = [ maintainers.GaetanLepage ];
|
||||||
|
|
||||||
filetypes = helpers.defaultNullOpts.mkNullable (with types; listOf str) ''
|
# TODO introduced 2024-06-17: remove 2024-08-17
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
imports =
|
||||||
|
map
|
||||||
|
(
|
||||||
|
optionName:
|
||||||
|
mkRemovedOptionModule
|
||||||
|
[
|
||||||
|
"plugins"
|
||||||
|
"ts-autotag"
|
||||||
|
optionName
|
||||||
|
]
|
||||||
|
''
|
||||||
|
The `ts-autotag` plugin is no longer configured using `nvim-treesitter.configs`.
|
||||||
|
Please, refer to upstream documentation:
|
||||||
|
https://github.com/windwp/nvim-ts-autotag#setup
|
||||||
|
''
|
||||||
|
)
|
||||||
[
|
[
|
||||||
"html"
|
"filetypes"
|
||||||
"javascript"
|
"skipTags"
|
||||||
"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 ];
|
extraConfig = cfg: {
|
||||||
|
warnings = mkIf (!config.plugins.treesitter.enable) [
|
||||||
|
"Nixvim: ts-autotag needs treesitter to function as intended"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
plugins.treesitter.moduleConfig.autotag = {
|
settingsOptions =
|
||||||
enable = true;
|
let
|
||||||
inherit (cfg) filetypes;
|
opts = {
|
||||||
skip_tags = cfg.skipTags;
|
enable_close = helpers.defaultNullOpts.mkBool true ''
|
||||||
} // cfg.extraOptions;
|
Whether or not to auto close tags.
|
||||||
|
'';
|
||||||
|
|
||||||
|
enable_rename = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Whether or not to auto rename paired tags.
|
||||||
|
'';
|
||||||
|
|
||||||
|
enable_close_on_slash = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Whether or not to auto close tags when a `/` is inserted.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit opts;
|
||||||
|
|
||||||
|
aliases = helpers.defaultNullOpts.mkAttrsOf types.str {
|
||||||
|
"astro" = "html";
|
||||||
|
"eruby" = "html";
|
||||||
|
"vue" = "html";
|
||||||
|
"htmldjango" = "html";
|
||||||
|
"markdown" = "html";
|
||||||
|
"php" = "html";
|
||||||
|
"twig" = "html";
|
||||||
|
"blade" = "html";
|
||||||
|
"javascriptreact" = "typescriptreact";
|
||||||
|
"javascript.jsx" = "typescriptreact";
|
||||||
|
"typescript.tsx" = "typescriptreact";
|
||||||
|
"javascript" = "typescriptreact";
|
||||||
|
"typescript" = "typescriptreact";
|
||||||
|
"rescript" = "typescriptreact";
|
||||||
|
"handlebars" = "glimmer";
|
||||||
|
"hbs" = "glimmer";
|
||||||
|
"rust" = "rust";
|
||||||
|
} "Filetype aliases.";
|
||||||
|
|
||||||
|
per_filetype = helpers.defaultNullOpts.mkAttrsOf (types.submodule {
|
||||||
|
freeformType = with types; attrsOf anything;
|
||||||
|
options = opts;
|
||||||
|
}) { } "Per filetype config overrides.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settingsExample = {
|
||||||
|
opts = {
|
||||||
|
enable_close = true;
|
||||||
|
enable_rename = true;
|
||||||
|
enable_close_on_slash = false;
|
||||||
|
};
|
||||||
|
per_filetype = {
|
||||||
|
html = {
|
||||||
|
enable_close = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,45 +11,56 @@
|
||||||
treesitter.enable = true;
|
treesitter.enable = true;
|
||||||
ts-autotag = {
|
ts-autotag = {
|
||||||
enable = true;
|
enable = true;
|
||||||
filetypes = [
|
|
||||||
"html"
|
settings = {
|
||||||
"javascript"
|
opts = {
|
||||||
"typescript"
|
enable_close = true;
|
||||||
"javascriptreact"
|
enable_rename = true;
|
||||||
"typescriptreact"
|
enable_close_on_slash = true;
|
||||||
"svelte"
|
};
|
||||||
"vue"
|
aliases = {
|
||||||
"tsx"
|
"astro" = "html";
|
||||||
"jsx"
|
"eruby" = "html";
|
||||||
"rescript"
|
"vue" = "html";
|
||||||
"xml"
|
"htmldjango" = "html";
|
||||||
"php"
|
"markdown" = "html";
|
||||||
"markdown"
|
"php" = "html";
|
||||||
"astro"
|
"twig" = "html";
|
||||||
"glimmer"
|
"blade" = "html";
|
||||||
"handlebars"
|
"javascriptreact" = "typescriptreact";
|
||||||
"hbs"
|
"javascript.jsx" = "typescriptreact";
|
||||||
];
|
"typescript.tsx" = "typescriptreact";
|
||||||
skipTags = [
|
"javascript" = "typescriptreact";
|
||||||
"area"
|
"typescript" = "typescriptreact";
|
||||||
"base"
|
"rescript" = "typescriptreact";
|
||||||
"br"
|
"handlebars" = "glimmer";
|
||||||
"col"
|
"hbs" = "glimmer";
|
||||||
"command"
|
"rust" = "rust";
|
||||||
"embed"
|
};
|
||||||
"hr"
|
per_filetype = { };
|
||||||
"img"
|
};
|
||||||
"slot"
|
};
|
||||||
"input"
|
};
|
||||||
"keygen"
|
};
|
||||||
"link"
|
|
||||||
"meta"
|
example = {
|
||||||
"param"
|
plugins = {
|
||||||
"source"
|
treesitter.enable = true;
|
||||||
"track"
|
ts-autotag = {
|
||||||
"wbr"
|
enable = true;
|
||||||
"menuitem"
|
|
||||||
];
|
settings = {
|
||||||
|
opts = {
|
||||||
|
enable_close = true;
|
||||||
|
enable_rename = true;
|
||||||
|
enable_close_on_slash = false;
|
||||||
|
};
|
||||||
|
per_filetype = {
|
||||||
|
html = {
|
||||||
|
enable_close = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue