Skip to content

Commit

Permalink
plugins/lsp: rename tsserver to ts-ls
Browse files Browse the repository at this point in the history
  • Loading branch information
tsssni committed Sep 16, 2024
1 parent 95b322a commit 2e3083e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
17 changes: 15 additions & 2 deletions plugins/lsp/language-servers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,9 @@ let
settingsOptions = import ./tinymist-settings.nix { inherit lib helpers; };
}
{
name = "tsserver";
description = "tsserver for TypeScript";
name = "ts-ls";
serverName = "ts_ls";
description = "ts_ls for TypeScript";
package = "typescript-language-server";
}
{
Expand Down Expand Up @@ -694,14 +695,26 @@ let
description = "zls for Zig";
}
];
renamedServers = {
tsserver = "ts-ls";
};
in
{
imports =
let
mkLsp = import ./_mk-lsp.nix;
lspModules = map mkLsp servers;
baseLspPath = [
"plugins"
"lsp"
"servers"
];
renameModules = mapAttrsToList (
old: new: lib.mkRenamedOptionModule (baseLspPath ++ [ old ]) (baseLspPath ++ [ new ])
) renamedServers;
in
lspModules
++ renameModules
++ [
./ccls.nix
./efmls-configs.nix
Expand Down
14 changes: 7 additions & 7 deletions plugins/none-ls/prettier.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
with lib;
let
cfg = config.plugins.none-ls.sources.formatting.prettier;
tsserver-cfg = config.plugins.lsp.servers.tsserver;
ts-ls-cfg = config.plugins.lsp.servers.ts-ls;
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.
Disables the formatting capability of the `ts-ls` language server if it is enabled.
'';
default = null;
example = true;
};
};

config = mkIf cfg.enable {
warnings = optional ((cfg.disableTsServerFormatter == null) && tsserver-cfg.enable) ''
warnings = optional ((cfg.disableTsServerFormatter == null) && ts-ls-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.
You have also enabled the `ts-ls` language server which also brings a formatting feature.
- To disable the formatter built-in the `tsserver` language server, set
- 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.tsserver =
plugins.lsp.servers.ts-ls =
mkIf
(
cfg.enable
&& tsserver-cfg.enable
&& ts-ls-cfg.enable
&& (isBool cfg.disableTsServerFormatter)
&& cfg.disableTsServerFormatter
)
Expand Down
1 change: 1 addition & 0 deletions tests/test-sources/plugins/lsp/_lsp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
texlab.enable = true;
tflint.enable = true;
tinymist.enable = true;
ts-ls.enable = true;
typos-lsp.enable = true;
typst-lsp.enable = true;
vala-ls.enable = true;
Expand Down

0 comments on commit 2e3083e

Please sign in to comment.