typescript-tools.nvim icon indicating copy to clipboard operation
typescript-tools.nvim copied to clipboard

LspStop typescript-tools - Invalid server name 'typescript-tools'

Open tea06194 opened this issue 5 months ago • 6 comments

:LspStop typescript-tools message: Invalid server name 'typescript-tools'

try with nvim -u ~/test.lua

test.lua
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
	local lazyrepo = "https://github.com/folke/lazy.nvim.git"
	local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
	if vim.v.shell_error ~= 0 then
		vim.api.nvim_echo({
			{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
			{ out,                            "WarningMsg" },
			{ "\nPress any key to exit..." },
		}, true, {})
		vim.fn.getchar()
		os.exit(1)
	end
end
vim.opt.rtp:prepend(lazypath)

-- Setup lazy.nvim
require("lazy").setup({
	spec = {
		-- import your plugins
		-- { import = "plugins" },
		{
			"pmizio/typescript-tools.nvim",
			dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
			opts = {},
		}
	},
	-- Configure any other settings here. See the documentation for more details.
	-- colorscheme that will be used when installing plugins.
	-- install = { colorscheme = { "habamax" } },
	-- automatically check for plugin updates
	checker = { enabled = false },
})

On clean

* 3c501d7 15:40:38 25-04-2025 Jarosław Glegoła (HEAD -> master | upstream/master | upstream/HEAD | origin/master | origin/HEAD | fork/master)

tea06194 avatar Jul 12 '25 22:07 tea06194

If you're using Neovim version 0.11.2 or higher, this explains the LspRestart issue you're experiencing.

Root Cause

The LspRestart command comes from nvim-lspconfig. In Neovim ≥ 0.11.2, nvim-lspconfig uses this implementation for the LspStop command:

api.nvim_create_user_command('LspStop', function(info)
 local clients = info.fargs
 if #clients == 0 then
   clients = vim
     .iter(vim.lsp.get_clients({ bufnr = vim.api.nvim_get_current_buf() }))
     :map(function(client)
       return client.name
     end)
     :totable()
 end
 for _, name in ipairs(clients) do
   if vim.lsp.config[name] == nil then
     vim.notify(("Invalid server name '%s'"):format(name))
   else
     vim.lsp.enable(name, false)
   end
 end
end, {
 desc = 'Disable and stop the given client',
 nargs = '?',
 complete = complete_client,
})

The Problem

typescript-tools uses the deprecated lspconfig.servername.setup() method, which means it's not registered in vim.lsp.config. When the new LspStop command checks vim.lsp.config[name], it returns nil for typescript-tools, causing the command to fail.

Temporary Solution

Downgrading Neovim to a version below 0.11.2 should resolve this issue temporarily, as it will use the older lspconfig implementation that doesn't rely on vim.lsp.config.

Long-term Solution

The typescript-tools plugin needs to be updated to use the newer Neovim LSP configuration methods instead of the deprecated lspconfig.servername.setup() approach. However, this means that neovim version requirement for this plugin will be bumped to 0.11

Yuki-bun avatar Jul 13 '25 06:07 Yuki-bun

+1 I'm also having this issue on version 0.12.

diego-velez avatar Jul 16 '25 20:07 diego-velez

opened pr #366

Yuki-bun avatar Sep 02 '25 13:09 Yuki-bun

I have this issue too when I execte LspRestart.

otakutyrant avatar Sep 12 '25 02:09 otakutyrant

I have this issue too when I execte LspRestart.

Same for me.

aaronmcadam avatar Oct 11 '25 16:10 aaronmcadam

I have this issue too when I execte LspRestart.

same here

xsalman01 avatar Oct 20 '25 11:10 xsalman01