forked from nix-community/nixvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins/ts-autotag: switch to mkNeovimPlugin
- Loading branch information
1 parent
7087b60
commit b822078
Showing
2 changed files
with
134 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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."; | ||
"filetypes" | ||
"skipTags" | ||
]; | ||
|
||
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."; | ||
extraConfig = cfg: { | ||
warnings = mkIf (!config.plugins.treesitter.enable) [ | ||
"Nixvim: ts-autotag needs treesitter to function as intended" | ||
]; | ||
}; | ||
|
||
config = | ||
settingsOptions = | ||
let | ||
cfg = config.plugins.ts-autotag; | ||
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 | ||
mkIf cfg.enable { | ||
warnings = mkIf (!config.plugins.treesitter.enable) [ | ||
"Nixvim: ts-autotag needs treesitter to function as intended" | ||
]; | ||
{ | ||
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."; | ||
|
||
extraPlugins = [ cfg.package ]; | ||
per_filetype = helpers.defaultNullOpts.mkAttrsOf (types.submodule { | ||
freeformType = with types; attrsOf anything; | ||
options = opts; | ||
}) { } "Per filetype config overrides."; | ||
}; | ||
|
||
plugins.treesitter.moduleConfig.autotag = { | ||
enable = true; | ||
inherit (cfg) filetypes; | ||
skip_tags = cfg.skipTags; | ||
} // cfg.extraOptions; | ||
settingsExample = { | ||
opts = { | ||
enable_close = true; | ||
enable_rename = true; | ||
enable_close_on_slash = false; | ||
}; | ||
per_filetype = { | ||
html = { | ||
enable_close = false; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters