From 7355debede2f2c286804e9754b2f1889216bea0d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 18 Apr 2023 01:05:18 +0300 Subject: [PATCH] feat: move html into languages --- extra.nix | 1 + flake/overlays.nix | 7 +++++- modules/languages/default.nix | 1 + modules/languages/html.nix | 42 +++++++++++++++++++++++++++++++++++ modules/lsp/default.nix | 2 +- modules/treesitter/config.nix | 7 ------ 6 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 modules/languages/html.nix diff --git a/extra.nix b/extra.nix index 2880d5b..c1d444f 100644 --- a/extra.nix +++ b/extra.nix @@ -36,6 +36,7 @@ inputs: let enableExtraDiagnostics = true; nix.enable = true; + html.enable = isMaximal; clang.enable = isMaximal; sql.enable = isMaximal; rust = { diff --git a/flake/overlays.nix b/flake/overlays.nix index 1850a91..8a2dfb8 100644 --- a/flake/overlays.nix +++ b/flake/overlays.nix @@ -1,4 +1,8 @@ -{inputs, ...}: let +{ + inputs, + pkgs, + ... +}: let inherit (import ../extra.nix inputs) neovimConfiguration mainConfig; buildPkg = pkgs: modules: @@ -14,5 +18,6 @@ in { neovim-nix = buildPkg prev [nixConfig]; neovim-maximal = buildPkg prev [maximalConfig]; neovim-tidal = buildPkg prev [tidalConfig]; + devPkg = buildPkg pkgs [nixConfig {config.vim.languages.html.enable = pkgs.lib.mkForce true;}]; }; } diff --git a/modules/languages/default.nix b/modules/languages/default.nix index ee7cb4c..3708737 100644 --- a/modules/languages/default.nix +++ b/modules/languages/default.nix @@ -19,6 +19,7 @@ in { ./sql.nix ./ts.nix ./zig.nix + ./html.nix ]; options.vim.languages = { diff --git a/modules/languages/html.nix b/modules/languages/html.nix new file mode 100644 index 0000000..b897e1c --- /dev/null +++ b/modules/languages/html.nix @@ -0,0 +1,42 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.languages.html; +in { + options.vim.languages.html = { + enable = mkEnableOption "HTML language support"; + + treesitter = { + enable = mkOption { + description = "Enable HTML treesitter"; + type = types.bool; + default = config.vim.languages.enableTreesitter; + }; + package = nvim.types.mkGrammarOption pkgs "html"; + + autotagHtml = mkOption { + description = "Enable autoclose/autorename of html tags (nvim-ts-autotag)"; + type = types.bool; + default = true; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + + vim.startPlugins = optional cfg.treesitter.autotagHtml "nvim-ts-autotag"; + + vim.luaConfigRC.html-autotag = mkIf cfg.treesitter.autotagHtml (nvim.dag.entryAnywhere '' + require('nvim-ts-autotag').setup() + ''); + }) + ]); +} diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 16b7f47..b9a39c6 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -1,4 +1,4 @@ -{...}: { +_: { imports = [ # nvim lsp support ./config.nix diff --git a/modules/treesitter/config.nix b/modules/treesitter/config.nix index c38b2b9..27744ef 100644 --- a/modules/treesitter/config.nix +++ b/modules/treesitter/config.nix @@ -12,7 +12,6 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["nvim-treesitter"] - ++ optional cfg.autotagHtml "nvim-ts-autotag" ++ optional usingNvimCmp "cmp-treesitter"; vim.autocomplete.sources = ["treesitter"]; @@ -43,12 +42,6 @@ in { node_decremental = "grm", }, }, - - ${optionalString cfg.autotagHtml '' - autotag = { - enable = true, - }, - ''} } ''; };