From e552c984a24c88017f8bfe6807527b7a9c77e22c Mon Sep 17 00:00:00 2001 From: Pyxels <39232833+Pyxels@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:24:33 +0100 Subject: [PATCH] plugins/nonels/prettier: use priority instead of null for prettier disableTsFormatting --- plugins/by-name/none-ls/prettier.nix | 37 +++++++++++++++------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/plugins/by-name/none-ls/prettier.nix b/plugins/by-name/none-ls/prettier.nix index 773dea558a..523a458399 100644 --- a/plugins/by-name/none-ls/prettier.nix +++ b/plugins/by-name/none-ls/prettier.nix @@ -1,38 +1,41 @@ -{ lib, config, ... }: +{ + lib, + config, + options, + ... +}: let cfg = config.plugins.none-ls.sources.formatting.prettier; ts-ls-cfg = config.plugins.lsp.servers.ts_ls; + opt = options.plugins.none-ls.sources.formatting.prettier; + defaultPrio = (lib.mkOptionDefault null).priority; in { options.plugins.none-ls.sources.formatting.prettier = { disableTsServerFormatter = lib.mkOption { - type = with lib.types; nullOr bool; + type = lib.types.bool; description = '' Disables the formatting capability of the `ts_ls` language server if it is enabled. ''; - default = null; + default = false; example = true; }; }; config = lib.mkIf cfg.enable { - warnings = lib.optional ((cfg.disableTsServerFormatter == null) && ts-ls-cfg.enable) '' - You have enabled the `prettier` formatter in none-ls. - You have also enabled the `ts_ls` language server which also brings a formatting feature. + warnings = + lib.optional (opt.disableTsServerFormatter.highestPrio == defaultPrio && ts-ls-cfg.enable) + '' + You have enabled the `prettier` formatter in none-ls. + You have also enabled the `ts_ls` language server which also brings a formatting feature. - - To disable the formatter built-in the `ts_ls` language server, set - `plugins.none-ls.sources.formatting.prettier.disableTsServerFormatter` to `true`. - - Else, to silence this warning, explicitly set the option to `false`. - ''; + - To disable the formatter built-in the `ts_ls` language server, set + `plugins.none-ls.sources.formatting.prettier.disableTsServerFormatter` to `true`. + - Else, to silence this warning, explicitly set the option to `false`. + ''; plugins.lsp.servers.ts_ls = - lib.mkIf - ( - cfg.enable - && ts-ls-cfg.enable - && (lib.isBool cfg.disableTsServerFormatter) - && cfg.disableTsServerFormatter - ) + lib.mkIf (cfg.enable && ts-ls-cfg.enable && cfg.disableTsServerFormatter) { onAttach.function = '' client.server_capabilities.documentFormattingProvider = false