Nvim-lspconfig: Can't get tsserver to work

Created on 7 Mar 2020  路  10Comments  路  Source: neovim/nvim-lspconfig

  • nvim --version: NVIM v0.5.0-397-g96059d72e
    Build type: RelWithDebInfo
    LuaJIT 2.1.0-beta3
  • nvim-lsp version: 7c2bc9a
  • What language server(If the problem is related to a specific language server): tsserver
  • Operating system/version: Windows 10 1903
  • Terminal name/version: windows console
  • $TERM: vtpcon

How to reproduce the problem from neovim startup

  • After npm install -g typescript-language-server, configure with :lua require('nvim_lsp').tsserver.setup{}
  • Then edit a JS file in a folder with a package.json.

Actual behaviour

It gives me this error:

Error detected while processing FileType Autocommands for "javascript":
E5108: Error executing lua ...evPrograms\Neovim\share\nvim\runtime\lua\vim\lsp\rpc.lua:259: attempt to index upvalue 'handle' (a nil value)

and doesn't work.

Expected behaviour

It just works

bug

Most helpful comment

@h-michael I just found the problem. On Windows, the binary for typescript-language-server is not really a binary (.exe file) but a batch file (.cmd). That means it cannot be found with just the name typescript-language-server as a normal binary by nvim/libuv. Simply changing the command to typescript-language-server.cmd solved the problem. Now this change can be made permanent in the config by checking if the platform is win32 and appending .cmd to the command. (I could submit a pull request but I'm on mobile.)

All 10 comments

Does your project's package.json includes typescript?
typescript-language-server needs tsc command.
If not, you should add typescript to your package.json or execute npm install -g typescript.

I tried both installing typescript globally and locally, but it didn't work. I also installed the typescript-language-server and typescript to the folder the automatic installer would install to (from :LspInstallInfo) if it worked but still doesn't work. Same error.

Sorry about the closing, chrome's dark mode made the button text unreadable.

@K1DV5 Would you paste the result of executing :lua print(vim.inspect(vim.lsp.buf_get_clients())) after the error.

Weird, its {}

@h-michael any news yet?

@K1DV5 Can you use other language servers?
Does it occur with only typescript-language-server?

@h-michael Yes, texlab and pyls work just fine. Only tsserver is not working.

@h-michael I just found the problem. On Windows, the binary for typescript-language-server is not really a binary (.exe file) but a batch file (.cmd). That means it cannot be found with just the name typescript-language-server as a normal binary by nvim/libuv. Simply changing the command to typescript-language-server.cmd solved the problem. Now this change can be made permanent in the config by checking if the platform is win32 and appending .cmd to the command. (I could submit a pull request but I'm on mobile.)

I have also met a similar issue with pyls on Linux. In my case, it is the pyls executable is not properly installed and broken. I uninstalled the old pyls and reinstalled. Everything works now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacksonludwig picture jacksonludwig  路  3Comments

JamesGreenaway picture JamesGreenaway  路  9Comments

RefusesNames picture RefusesNames  路  3Comments

mjlbach picture mjlbach  路  8Comments

nhooyr picture nhooyr  路  3Comments