nvim --version: NVIM v0.5.0-60c581b:checkhealth result## Checking language server protocol configuration
- INFO: vimls: configuration checked.
- INFO: gopls: configuration checked.
- INFO: tsserver: configuration checked.
$TERM: xterm-256colorAfter installing with :LspInstall I get:
Error executing vim.schedule lua callback: ...r/neovim/HEAD-60c581b/share/nvim/runtime/lua/vim/lsp.lua:460: RPC[Error] code_name = InternalError, message = "Request initialize failed with message: Couldn't find 'tsserver' e
xecutable or 'tsserver.js' module"
Uninstalled and then tried to install from npm and same issue.
gopls and vim-language-server both work perfectly.
Can you start tsserver manually?
~/src/nhooyr/websocket:dev*
$ ~/.cache/nvim/nvim_lsp/tsserver/node_modules/.bin/typescript-language-server
Connection type required (stdio, node-ipc, socket). Refer to --help for more details.
Can run the binary at least.
How do I start it up properly?
You didn't actually start it though since it failed because of missing arguments. As the error message says, you need to start it with a connection type, e.g. stdio, node-ipc, socket.
Try this instead:
-~/.cache/nvim/nvim_lsp/tsserver/node_modules/.bin/typescript-language-server
+~/.cache/nvim/nvim_lsp/tsserver/node_modules/.bin/typescript-language-server stdio
So passing --stdio and it blocks so it seems like it works but passing --node-ipc or --socket 9090 and it just exits without any error/log.
Anyway, I meant to use the node language server and it doesn't seem tsserver not working is related to nvim-lsp.
Oh wait hold on there is no node ls server. tsserver is the main one my bad.
I was looking at https://github.com/microsoft/vscode-languageserver-node but that seems to just be a library.
omfg I just had to install typescript globally
npm install -g typescript
Not sure why the package doesn't depend on typescript. interesting.
I'd say that's a bug in nvim-lsp actually, we should install tsserver on top of typescript-language-server if we have to.
I think the assumption is that you should install typescript locally in your project (i.e. add it to package.json).
I think the assumption is that you should install typescript locally in your project (i.e. add it to package.json).
Yea I should have ran yarn to install deps first but I got blocked on figuring this out lol. I think an error message would be appropriate explaining that.
Ran into this issue and @nhooyr 's typescript install did it for me too - would be nice if the docs reflected this need!
Even better, it would be awesome if Neovim printed out an error saying that the LSP is missing a typescript install
I for one still can't get JavaScript LSP working: nvim -u test.vim test.js shows no diagnosis error, where
test.vim is:
packadd nvim-lspconfig
lua require'nvim_lsp'.tsserver.setup{}
and test.js is:
var foo = 1
vax bar = 2
lua print(vim.inspect(vim.lsp.buf_get_clients())) returns {}. :checkhealth is happy, I did install typescript globally, tsserver config looks good:
{
bin_dir = "/home/alex/.cache/nvim/nvim_lsp/tsserver/node_modules/.bin",
binaries = {
["typescript-language-server"] = "/home/alex/.cache/nvim/nvim_lsp/tsserver/node_modules/.bin/typescript-language-server"
},
install_dir = "/home/alex/.cache/nvim/nvim_lsp/tsserver",
is_installed = true
}
and I can run typescript-language-server just fine. I just don't get any of the LSP goodness at all...
I use the latest master for nvim-lspconfig and nvim version is v0.5.0-715-gc5ceefca7.
@alexaandru What OS do you have? I just struggled very hard on new Linux machine, because I (wrongly) ran all the npm install -g commands with sudo (can happen on other platforms as well, I guess).
Should it be the case, make sure you follow https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally.
Thank you @miiila , my bad & sorry for the noise everyone: my test case was flawed - forgot about the trigger, which must be one of "package.json", "tsconfig.json", ".git" - without that, the LSP will not kick in :) - https://github.com/neovim/nvim-lspconfig#tsserver
It works now, I get errors, hints & all the LSP goodness :)
Is this still an issue?
FYI You don't need a trigger if you use this config root_dir = vim.loop.cwd
Here is my full code. You can simply run nvim test.ts in any folder and you get completion. No need to be in git etc..
lsp.tsserver.setup {on_attach = custom_attach, root_dir = vim.loop.cwd }
I would recommend not overriding the default, but adding a fallback
root_dir = util.root_pattern("package.json", "tsconfig.json", ".git") or vim.loop.cwd();
See:
https://github.com/neovim/nvim-lspconfig/blob/42a13e5ad99b688bc7376fa4d236e924985d04cc/lua/lspconfig/intelephense.lua#L18-L22
https://github.com/neovim/nvim-lspconfig/blob/42a13e5ad99b688bc7376fa4d236e924985d04cc/lua/lspconfig/clangd.lua#L21-L23
Thanks, I see that my approach was a bit rough. I have tried refactoring my lsp_config.lua entry for tscript like so
Now I can't seem to get any completions working when running nvim test.ts
local util = require 'lspconfig/util'
lsp.tsserver.setup {on_attach = custom_attach,
root_dir = util.root_pattern("package.json", "tsconfig.json", ".git") or vim.loop.cwd();
}
Most helpful comment
omfg I just had to install typescript globally
npm install -g typescriptNot sure why the package doesn't depend on typescript. interesting.