mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
plugins/nonels/prettierd: add disableTsServerFormatting option to prettierd
Add a new option (and warning) to disable the typescript-language-server (ts_ls) formatting the same as for prettier.
This commit is contained in:
parent
7dc65b2d98
commit
d593b82436
2 changed files with 49 additions and 1 deletions
45
plugins/by-name/none-ls/prettierd.nix
Normal file
45
plugins/by-name/none-ls/prettierd.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
options,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.plugins.none-ls.sources.formatting.prettierd;
|
||||||
|
ts-ls-cfg = config.plugins.lsp.servers.ts_ls;
|
||||||
|
opt = options.plugins.none-ls.sources.formatting.prettierd;
|
||||||
|
defaultPrio = (lib.mkOptionDefault null).priority;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.plugins.none-ls.sources.formatting.prettierd = {
|
||||||
|
disableTsServerFormatter = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = ''
|
||||||
|
Disables the formatting capability of the `ts_ls` language server if it is enabled.
|
||||||
|
'';
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
warnings =
|
||||||
|
lib.optional (opt.disableTsServerFormatter.highestPrio == defaultPrio && ts-ls-cfg.enable)
|
||||||
|
''
|
||||||
|
You have enabled the `prettierd` 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.prettierd.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 && cfg.disableTsServerFormatter)
|
||||||
|
{
|
||||||
|
onAttach.function = ''
|
||||||
|
client.server_capabilities.documentFormattingProvider = false
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -5,7 +5,10 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports =
|
imports =
|
||||||
[ ./prettier.nix ]
|
[
|
||||||
|
./prettier.nix
|
||||||
|
./prettierd.nix
|
||||||
|
]
|
||||||
++ (lib.flatten (
|
++ (lib.flatten (
|
||||||
lib.mapAttrsToList (category: (lib.map (mkSourcePlugin category))) noneLsBuiltins
|
lib.mapAttrsToList (category: (lib.map (mkSourcePlugin category))) noneLsBuiltins
|
||||||
));
|
));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue