plugins/lsp: rename tsserver to ts-ls

This commit is contained in:
tsssni 2024-09-15 23:39:21 +08:00
parent 95b322a522
commit 2e3083e425
3 changed files with 23 additions and 9 deletions

View file

@ -621,8 +621,9 @@ let
settingsOptions = import ./tinymist-settings.nix { inherit lib helpers; }; settingsOptions = import ./tinymist-settings.nix { inherit lib helpers; };
} }
{ {
name = "tsserver"; name = "ts-ls";
description = "tsserver for TypeScript"; serverName = "ts_ls";
description = "ts_ls for TypeScript";
package = "typescript-language-server"; package = "typescript-language-server";
} }
{ {
@ -694,14 +695,26 @@ let
description = "zls for Zig"; description = "zls for Zig";
} }
]; ];
renamedServers = {
tsserver = "ts-ls";
};
in in
{ {
imports = imports =
let let
mkLsp = import ./_mk-lsp.nix; mkLsp = import ./_mk-lsp.nix;
lspModules = map mkLsp servers; lspModules = map mkLsp servers;
baseLspPath = [
"plugins"
"lsp"
"servers"
];
renameModules = mapAttrsToList (
old: new: lib.mkRenamedOptionModule (baseLspPath ++ [ old ]) (baseLspPath ++ [ new ])
) renamedServers;
in in
lspModules lspModules
++ renameModules
++ [ ++ [
./ccls.nix ./ccls.nix
./efmls-configs.nix ./efmls-configs.nix

View file

@ -2,14 +2,14 @@
with lib; with lib;
let let
cfg = config.plugins.none-ls.sources.formatting.prettier; 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 in
{ {
options.plugins.none-ls.sources.formatting.prettier = { options.plugins.none-ls.sources.formatting.prettier = {
disableTsServerFormatter = mkOption { disableTsServerFormatter = mkOption {
type = with types; nullOr bool; type = with types; nullOr bool;
description = '' 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; default = null;
example = true; example = true;
@ -17,20 +17,20 @@ in
}; };
config = mkIf cfg.enable { 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 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`. `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.tsserver = plugins.lsp.servers.ts-ls =
mkIf mkIf
( (
cfg.enable cfg.enable
&& tsserver-cfg.enable && ts-ls-cfg.enable
&& (isBool cfg.disableTsServerFormatter) && (isBool cfg.disableTsServerFormatter)
&& cfg.disableTsServerFormatter && cfg.disableTsServerFormatter
) )

View file

@ -210,6 +210,7 @@
texlab.enable = true; texlab.enable = true;
tflint.enable = true; tflint.enable = true;
tinymist.enable = true; tinymist.enable = true;
ts-ls.enable = true;
typos-lsp.enable = true; typos-lsp.enable = true;
typst-lsp.enable = true; typst-lsp.enable = true;
vala-ls.enable = true; vala-ls.enable = true;