|
1 | 1 | { |
2 | | - pkgs, |
3 | 2 | lib, |
4 | 3 | helpers, |
5 | 4 | config, |
| 5 | + pkgs, |
6 | 6 | ... |
7 | 7 | }: |
8 | 8 | with lib; |
9 | | -{ |
10 | | - options.plugins.ts-autotag = helpers.neovim-plugin.extraOptionsOptions // { |
11 | | - enable = mkEnableOption "nvim-ts-autotag"; |
| 9 | +helpers.neovim-plugin.mkNeovimPlugin config { |
| 10 | + name = "ts-autotag"; |
| 11 | + originalName = "nvim-ts-autotag"; |
| 12 | + luaName = "nvim-ts-autotag"; |
| 13 | + defaultPackage = pkgs.vimPlugins.nvim-ts-autotag; |
12 | 14 |
|
13 | | - package = helpers.mkPluginPackageOption "ts-autotag" pkgs.vimPlugins.nvim-ts-autotag; |
| 15 | + maintainers = [ maintainers.GaetanLepage ]; |
14 | 16 |
|
15 | | - filetypes = helpers.defaultNullOpts.mkNullable (with types; listOf str) '' |
| 17 | + # TODO introduced 2024-06-17: remove 2024-08-17 |
| 18 | + deprecateExtraOptions = true; |
| 19 | + imports = |
| 20 | + map |
| 21 | + ( |
| 22 | + optionName: |
| 23 | + mkRemovedOptionModule |
| 24 | + [ |
| 25 | + "plugins" |
| 26 | + "ts-autotag" |
| 27 | + optionName |
| 28 | + ] |
| 29 | + '' |
| 30 | + The `ts-autotag` plugin is no longer configured using `nvim-treesitter.configs`. |
| 31 | + Please, refer to upstream documentation: |
| 32 | + https://github.com/windwp/nvim-ts-autotag#setup |
| 33 | + '' |
| 34 | + ) |
16 | 35 | [ |
17 | | - "html" |
18 | | - "javascript" |
19 | | - "typescript" |
20 | | - "javascriptreact" |
21 | | - "typescriptreact" |
22 | | - "svelte" |
23 | | - "vue" |
24 | | - "tsx" |
25 | | - "jsx" |
26 | | - "rescript" |
27 | | - "xml" |
28 | | - "php" |
29 | | - "markdown" |
30 | | - "astro" |
31 | | - "glimmer" |
32 | | - "handlebars" |
33 | | - "hbs" |
34 | | - ] |
35 | | - '' "Filetypes for which ts-autotag should be enabled."; |
| 36 | + "filetypes" |
| 37 | + "skipTags" |
| 38 | + ]; |
36 | 39 |
|
37 | | - skipTags = helpers.defaultNullOpts.mkNullable (with types; listOf str) '' |
38 | | - [ |
39 | | - "area" |
40 | | - "base" |
41 | | - "br" |
42 | | - "col" |
43 | | - "command" |
44 | | - "embed" |
45 | | - "hr" |
46 | | - "img" |
47 | | - "slot" |
48 | | - "input" |
49 | | - "keygen" |
50 | | - "link" |
51 | | - "meta" |
52 | | - "param" |
53 | | - "source" |
54 | | - "track" |
55 | | - "wbr" |
56 | | - "menuitem" |
57 | | - ] |
58 | | - '' "Which tags to skip."; |
| 40 | + extraConfig = cfg: { |
| 41 | + warnings = mkIf (!config.plugins.treesitter.enable) [ |
| 42 | + "Nixvim: ts-autotag needs treesitter to function as intended" |
| 43 | + ]; |
59 | 44 | }; |
60 | 45 |
|
61 | | - config = |
| 46 | + settingsOptions = |
62 | 47 | let |
63 | | - cfg = config.plugins.ts-autotag; |
| 48 | + opts = { |
| 49 | + enable_close = helpers.defaultNullOpts.mkBool true '' |
| 50 | + Whether or not to auto close tags. |
| 51 | + ''; |
| 52 | + |
| 53 | + enable_rename = helpers.defaultNullOpts.mkBool true '' |
| 54 | + Whether or not to auto rename paired tags. |
| 55 | + ''; |
| 56 | + |
| 57 | + enable_close_on_slash = helpers.defaultNullOpts.mkBool true '' |
| 58 | + Whether or not to auto close tags when a `/` is inserted. |
| 59 | + ''; |
| 60 | + }; |
64 | 61 | in |
65 | | - mkIf cfg.enable { |
66 | | - warnings = mkIf (!config.plugins.treesitter.enable) [ |
67 | | - "Nixvim: ts-autotag needs treesitter to function as intended" |
68 | | - ]; |
| 62 | + { |
| 63 | + inherit opts; |
| 64 | + |
| 65 | + aliases = helpers.defaultNullOpts.mkAttrsOf types.str { |
| 66 | + "astro" = "html"; |
| 67 | + "eruby" = "html"; |
| 68 | + "vue" = "html"; |
| 69 | + "htmldjango" = "html"; |
| 70 | + "markdown" = "html"; |
| 71 | + "php" = "html"; |
| 72 | + "twig" = "html"; |
| 73 | + "blade" = "html"; |
| 74 | + "javascriptreact" = "typescriptreact"; |
| 75 | + "javascript.jsx" = "typescriptreact"; |
| 76 | + "typescript.tsx" = "typescriptreact"; |
| 77 | + "javascript" = "typescriptreact"; |
| 78 | + "typescript" = "typescriptreact"; |
| 79 | + "rescript" = "typescriptreact"; |
| 80 | + "handlebars" = "glimmer"; |
| 81 | + "hbs" = "glimmer"; |
| 82 | + "rust" = "rust"; |
| 83 | + } "Filetype aliases."; |
69 | 84 |
|
70 | | - extraPlugins = [ cfg.package ]; |
| 85 | + per_filetype = helpers.defaultNullOpts.mkAttrsOf (types.submodule { |
| 86 | + freeformType = with types; attrsOf anything; |
| 87 | + options = opts; |
| 88 | + }) { } "Per filetype config overrides."; |
| 89 | + }; |
71 | 90 |
|
72 | | - plugins.treesitter.moduleConfig.autotag = { |
73 | | - enable = true; |
74 | | - inherit (cfg) filetypes; |
75 | | - skip_tags = cfg.skipTags; |
76 | | - } // cfg.extraOptions; |
| 91 | + settingsExample = { |
| 92 | + opts = { |
| 93 | + enable_close = true; |
| 94 | + enable_rename = true; |
| 95 | + enable_close_on_slash = false; |
| 96 | + }; |
| 97 | + per_filetype = { |
| 98 | + html = { |
| 99 | + enable_close = false; |
| 100 | + }; |
77 | 101 | }; |
| 102 | + }; |
78 | 103 | } |
0 commit comments