Skip to content

Commit

Permalink
plugins/nonels/prettier: use priority instead of null for prettier di…
Browse files Browse the repository at this point in the history
…sableTsFormatting
  • Loading branch information
Pyxels authored and nix-infra-bot committed Nov 13, 2024
1 parent d593b82 commit e552c98
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions plugins/by-name/none-ls/prettier.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e552c98

Please sign in to comment.