diff --git a/flake.lock b/flake.lock index 6b4b7155..377c0847 100644 --- a/flake.lock +++ b/flake.lock @@ -1136,11 +1136,11 @@ "plugin-nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1716498901, - "narHash": "sha256-PMMqPDnq4Q8gWeKQ2WPE+pOf1R1G61wJ+bAWkHpQlzE=", + "lastModified": 1727085470, + "narHash": "sha256-IPpUZEMIL7+4mmqQLy9JeT0cW15/SH3Hx8kyksVcqC0=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "b972e7154bc94ab4ecdbb38c8edbccac36f83996", + "rev": "dd329912c8d446240584a2dbcd3802af3a19105a", "type": "github" }, "original": { diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index dd1bde69..e6e718ed 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -17,12 +17,12 @@ cfg = config.vim.languages.ts; - defaultServer = "tsserver"; + defaultServer = "ts_ls"; servers = { - tsserver = { + ts_ls = { package = pkgs.typescript-language-server; lspConfig = '' - lspconfig.tsserver.setup { + lspconfig.ts_ls.setup { capabilities = capabilities; on_attach = attach_keymaps, cmd = ${ @@ -49,6 +49,24 @@ } ''; }; + + # Here for backwards compatibility. Still consider tsserver a valid + # configuration in the enum, but assert if it's set to *properly* + # redirect the user to the correct server. + tsserver = { + package = pkgs.typescript-language-server; + lspConfig = '' + lspconfig.ts_ls.setup { + capabilities = capabilities; + on_attach = attach_keymaps, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}'' + } + } + ''; + }; }; # TODO: specify packages @@ -65,6 +83,7 @@ ) ''; }; + prettierd = { package = pkgs.prettierd; nullConfig = '' @@ -94,6 +113,7 @@ }; }; in { + _file = ./ts.nix; options.vim.languages.ts = { enable = mkEnableOption "Typescript/Javascript language support"; @@ -190,11 +210,32 @@ in { }; }) + # Extensions (mkIf cfg.extensions."ts-error-translator".enable { vim.startPlugins = ["ts-error-translator"]; vim.pluginRC.ts-error-translator = entryAnywhere '' require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts}) ''; }) + + # Warn the user if they have set the default server name to tsserver to match upstream (us) + # The name "tsserver" has been deprecated in lspconfig, and now should be called ts_ls. This + # is a purely cosmetic change, but emits a warning if not accounted for. + { + assertions = [ + { + assertion = cfg.lsp.enable -> cfg.lsp.server != "tsserver"; + message = '' + As of a recent lspconfig update, he `tsserver` configuration has been renamed + to `ts_ls` to match upstream behaviour of `lspconfig`, and the name `tsserver` + is no longer considered valid by nvf. Please set `vim.languages.ts.lsp.server` + to `"ts_ls"` instead of to `${cfg.lsp.server}` + + Please see for more details + about this change. + ''; + } + ]; + } ]); }