Closed nhooyr closed 3 years ago
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!
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(); }
@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 haha, i had the same issue. Killing it :)))
My nvim lsp can't run tsserver,
:LspInfo
shows:
Config: tsserver
cmd is executable: False. Please check your path and ensure the server is installed
it can see executable if I set it up directly:
nvim_lsp.tsserver.setup{
cmd = {'tsserver'}
}
then I see:
LSP[tsserver]: Error INVALID_SERVER_MESSAGE: {
command = "unknown",
message = "Error processing request. Unexpected token C in JSON at position 0\nSyntaxError: Unexpected token C in JSON at position 0\n a
t JSON.parse (<anonymous>)\n at IOSession.Session.parseMessage (/usr/local/lib/node_modules/typescript/lib/tsserver.js:161029:29)\n at
IOSession.Session.onMessage (/usr/local/lib/node_modules/typescript/lib/tsserver.js:160984:36)\n at Interface.<anonymous> (/usr/local/lib/
node_modules/typescript/lib/tsserver.js:163650:31)\n at Interface.emit (events.js:315:20)\n at Interface._onLine (readline.js:337:10)\n
at Interface._normalWrite (readline.js:482:12)\n at Socket.ondata (readline.js:194:10)\n at Socket.emit (events.js:315:20)\n at
addChunk (internal/streams/readable.js:309:12)\n at readableAddChunk (internal/streams/readable.js:284:9)\n at Socket.Readable.push (in
ternal/streams/readable.js:223:10)\n at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)",
request_seq = 0,
seq = 0,
success = false,
type = "response"
I have some progress with https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/tsserver.lua#L25
npm install -g typescript typescript-language-server
now:
cmd is executable: True
@sergii4 the tsserver
binary doesn't actually implement LSP (yet, see https://github.com/microsoft/TypeScript/issues/39459). Which is why you need to install something like typescript-language-server that acts as an adapter on top of tsserver
and exposes an LSP interface:
cmd = {'typescript-language-server', '--stdio'}
thanks, @lithammer. I just expected this to be somewhere in nvim lspconfig
docs.
Fwiw you don't need to manually specify command, as you're overwriting the default (correct) value
@mjlbach the case is that I couldn't run with default settings even after I used this:
https://github.com/neovim/nvim-lspconfig/wiki/Installing-language-servers-automatically (https://github.com/alexaandru/nvim-lspupdate particulary).
So I started experimenting and ened up with: https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/tsserver.lua#L25
Probably manual needs an update
What do you mean manual needs an update
? Which manual? Which update? That command is in our docs ^
what i was looking of is how to setup nvim lspconfig with tsserver
. I haven't found it. I you have it, could you please share it with me?
what i was looking of is how to setup
nvim lspconfig with tsserver
. I haven't found it. I you have it, could you please share it with me?
As I said, it's not possible since tsserver
isn't a language server. Just install typescript-language-server and it will use tsserver
under the hood.
Добре?
what is the point of your message? you just repeated the things I listed before. what i was needed I found here. It wasn't listed in projected wiki. that was my point.
Добре?
what is the point of your message? you just repeated the things I listed before. what i was needed I found here. It wasn't listed in projected wiki. that was my point.
I am dumb, sorry
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 }
This worked. Thank you!!
I use this settings to find _rootdir with fallback to cwd.
require('lspconfig')['tsserver'].setup{
on_attach = on_attach,
root_dir = function (pattern)
local cwd = vim.loop.cwd();
local root = util.root_pattern("package.json", "tsconfig.json", ".git")(pattern);
return root or cwd;
end;
}
The problem seems to have been fixed, so one can just use the default settings. In my case, I have been using autostart = true
without customizing root_dir
and everything is working for months.
For me worked npm install -g typescript typescript-language-server
and then in my nvim config require('lspconfig').tsserver.setup{}
what is a minimum working non lspconfig setup?
nvim --version
:NVIM v0.5.0-60c581b
:checkhealth
result$TERM
: xterm-256colorHow to reproduce the problem from neovim startup
After installing with
:LspInstall
I get:Uninstalled and then tried to install from npm and same issue.
gopls
andvim-language-server
both work perfectly.