mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 09:48:42 +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,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
{
|
||||
options.plugins.ts-autotag = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "nvim-ts-autotag";
|
||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||
name = "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"
|
||||
"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"
|
||||
"filetypes"
|
||||
"skipTags"
|
||||
];
|
||||
|
||||
extraPlugins = [ cfg.package ];
|
||||
extraConfig = cfg: {
|
||||
warnings = mkIf (!config.plugins.treesitter.enable) [
|
||||
"Nixvim: ts-autotag needs treesitter to function as intended"
|
||||
];
|
||||
};
|
||||
|
||||
plugins.treesitter.moduleConfig.autotag = {
|
||||
enable = true;
|
||||
inherit (cfg) filetypes;
|
||||
skip_tags = cfg.skipTags;
|
||||
} // cfg.extraOptions;
|
||||
settingsOptions =
|
||||
let
|
||||
opts = {
|
||||
enable_close = helpers.defaultNullOpts.mkBool true ''
|
||||
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;
|
||||
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"
|
||||
];
|
||||
|
||||
settings = {
|
||||
opts = {
|
||||
enable_close = true;
|
||||
enable_rename = true;
|
||||
enable_close_on_slash = true;
|
||||
};
|
||||
aliases = {
|
||||
"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";
|
||||
};
|
||||
per_filetype = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins = {
|
||||
treesitter.enable = true;
|
||||
ts-autotag = {
|
||||
enable = true;
|
||||
|
||||
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