mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/none-ls: add disableTsServerFormatter option
This commit is contained in:
parent
19b2792602
commit
944a84b2c0
2 changed files with 56 additions and 1 deletions
51
plugins/none-ls/prettier.nix
Normal file
51
plugins/none-ls/prettier.nix
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib; let
|
||||||
|
cfg = config.plugins.none-ls.sources.formatting.prettier;
|
||||||
|
tsserver-cfg = config.plugins.lsp.servers.tsserver;
|
||||||
|
in {
|
||||||
|
options.plugins.none-ls.sources.formatting.prettier = {
|
||||||
|
disableTsServerFormatter = mkOption {
|
||||||
|
type = with types; nullOr bool;
|
||||||
|
description = ''
|
||||||
|
Disables the formatting capability of the `tsserver` language server if it is enabled.
|
||||||
|
'';
|
||||||
|
default = null;
|
||||||
|
example = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
warnings =
|
||||||
|
optional
|
||||||
|
(
|
||||||
|
(cfg.disableTsServerFormatter == null)
|
||||||
|
&& tsserver-cfg.enable
|
||||||
|
)
|
||||||
|
''
|
||||||
|
You have enabled the `prettier` formatter in none-ls.
|
||||||
|
You have also enabled the `tsserver` language server which also brings a formatting feature.
|
||||||
|
|
||||||
|
- To disable the formatter built-in the `tsserver` 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.tsserver =
|
||||||
|
mkIf
|
||||||
|
(
|
||||||
|
cfg.enable
|
||||||
|
&& tsserver-cfg.enable
|
||||||
|
&& (isBool cfg.disableTsServerFormatter)
|
||||||
|
&& cfg.disableTsServerFormatter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
onAttach.function = ''
|
||||||
|
client.server_capabilities.documentFormattingProvider = false
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -179,7 +179,11 @@ with lib; let
|
||||||
serverData;
|
serverData;
|
||||||
dataFlattened = flatten serverDataFormatted;
|
dataFlattened = flatten serverDataFormatted;
|
||||||
in {
|
in {
|
||||||
imports = map helpers.mkServer dataFlattened;
|
imports =
|
||||||
|
(map helpers.mkServer dataFlattened)
|
||||||
|
++ [
|
||||||
|
./prettier.nix
|
||||||
|
];
|
||||||
|
|
||||||
config = let
|
config = let
|
||||||
cfg = config.plugins.none-ls;
|
cfg = config.plugins.none-ls;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue