From dd5d3cb614dec4963bab5fe0a436ca99bb15d96f Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sat, 10 Aug 2024 14:16:38 +0300 Subject: [PATCH] modules: add typescript-tools plugin --- module-list.nix | 1 + .../language-server/typescript-tools.nix | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 modules/plugins/language-server/typescript-tools.nix diff --git a/module-list.nix b/module-list.nix index a6aaca2..7bf222a 100644 --- a/module-list.nix +++ b/module-list.nix @@ -17,6 +17,7 @@ ./modules/plugins/interface/lualine.nix ./modules/plugins/language-server/lspconfig.nix ./modules/plugins/language-server/nlsp-settings.nix + ./modules/plugins/language-server/typescript-tools.nix ./modules/plugins/navigation/hop-nvim.nix ./modules/plugins/navigation/telescope.nix ./modules/plugins/navigation/nvim-tree.nix diff --git a/modules/plugins/language-server/typescript-tools.nix b/modules/plugins/language-server/typescript-tools.nix new file mode 100644 index 0000000..005f5f4 --- /dev/null +++ b/modules/plugins/language-server/typescript-tools.nix @@ -0,0 +1,42 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.plugins.language-server.typescript-tools; +in +{ + options.plugins.language-server.typescript-tools = with lib; { + enable = lib.mkEnableOption "typescript-tools"; + + package = mkPackageOption pkgs.vimPlugins "typescript-tools-nvim" { }; + + serverSettings = mkOption { + type = with types; attrsOf attrs; + default = { }; + description = '' + Server-specific settings. + + See config options here: https://github.com/pmizio/typescript-tools.nvim + + `:help lspconfig-setup` + ''; + }; + }; + + config = lib.mkIf cfg.enable { + assertions = [ + { + assertion = !(config.plugins.language-server.lspconfig.serverSettings ? tsserver); + message = "You should not have 'typescript-language-server' and 'typescript-tools' enabled together because they are both LSP for the same language"; + } + ]; + + plugin.plenary-nvim = { }; + + plugin.typescript-tools-nvim = { + enable = true; + name = "typescript-tools"; + inherit (cfg) package; + setupSettings = cfg.serverSettings; + }; + }; +}