mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/nonels/prettier: use priority instead of null for prettier disableTsFormatting
This commit is contained in:
parent
d593b82436
commit
e552c984a2
1 changed files with 20 additions and 17 deletions
|
@ -1,38 +1,41 @@
|
||||||
{ lib, config, ... }:
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
options,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.plugins.none-ls.sources.formatting.prettier;
|
cfg = config.plugins.none-ls.sources.formatting.prettier;
|
||||||
ts-ls-cfg = config.plugins.lsp.servers.ts_ls;
|
ts-ls-cfg = config.plugins.lsp.servers.ts_ls;
|
||||||
|
opt = options.plugins.none-ls.sources.formatting.prettier;
|
||||||
|
defaultPrio = (lib.mkOptionDefault null).priority;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.plugins.none-ls.sources.formatting.prettier = {
|
options.plugins.none-ls.sources.formatting.prettier = {
|
||||||
disableTsServerFormatter = lib.mkOption {
|
disableTsServerFormatter = lib.mkOption {
|
||||||
type = with lib.types; nullOr bool;
|
type = lib.types.bool;
|
||||||
description = ''
|
description = ''
|
||||||
Disables the formatting capability of the `ts_ls` language server if it is enabled.
|
Disables the formatting capability of the `ts_ls` language server if it is enabled.
|
||||||
'';
|
'';
|
||||||
default = null;
|
default = false;
|
||||||
example = true;
|
example = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
warnings = lib.optional ((cfg.disableTsServerFormatter == null) && ts-ls-cfg.enable) ''
|
warnings =
|
||||||
You have enabled the `prettier` formatter in none-ls.
|
lib.optional (opt.disableTsServerFormatter.highestPrio == defaultPrio && ts-ls-cfg.enable)
|
||||||
You have also enabled the `ts_ls` language server which also brings a formatting feature.
|
''
|
||||||
|
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
|
- To disable the formatter built-in the `ts_ls` language server, set
|
||||||
`plugins.none-ls.sources.formatting.prettier.disableTsServerFormatter` to `true`.
|
`plugins.none-ls.sources.formatting.prettier.disableTsServerFormatter` to `true`.
|
||||||
- Else, to silence this warning, explicitly set the option to `false`.
|
- Else, to silence this warning, explicitly set the option to `false`.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
plugins.lsp.servers.ts_ls =
|
plugins.lsp.servers.ts_ls =
|
||||||
lib.mkIf
|
lib.mkIf (cfg.enable && ts-ls-cfg.enable && cfg.disableTsServerFormatter)
|
||||||
(
|
|
||||||
cfg.enable
|
|
||||||
&& ts-ls-cfg.enable
|
|
||||||
&& (lib.isBool cfg.disableTsServerFormatter)
|
|
||||||
&& cfg.disableTsServerFormatter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
onAttach.function = ''
|
onAttach.function = ''
|
||||||
client.server_capabilities.documentFormattingProvider = false
|
client.server_capabilities.documentFormattingProvider = false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue