neovim-flake/modules/plugins/languages/html.nix

46 lines
1.2 KiB
Nix
Raw Normal View History

2023-04-18 00:05:18 +02:00
{
config,
pkgs,
2023-04-18 00:05:18 +02:00
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) bool;
inherit (lib.lists) optional;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.dag) entryAnywhere;
2023-04-18 00:05:18 +02:00
cfg = config.vim.languages.html;
in {
options.vim.languages.html = {
enable = mkEnableOption "HTML language support";
treesitter = {
enable = mkEnableOption "HTML treesitter support" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "html";
2023-04-18 00:05:18 +02:00
autotagHtml = mkOption {
description = "Enable autoclose/autorename of html tags (nvim-ts-autotag)";
type = bool;
2023-04-18 00:05:18 +02:00
default = true;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim = {
startPlugins = optional cfg.treesitter.autotagHtml "nvim-ts-autotag";
2023-04-18 00:05:18 +02:00
treesitter = {
enable = true;
grammars = [cfg.treesitter.package];
};
2023-04-18 00:05:18 +02:00
pluginRC.html-autotag = mkIf cfg.treesitter.autotagHtml (entryAnywhere ''
require('nvim-ts-autotag').setup()
'');
};
2023-04-18 00:05:18 +02:00
})
]);
}