Nvim-lspconfig: Can't load tsserver and jdtls

Created on 21 Sep 2020  路  18Comments  路  Source: neovim/nvim-lspconfig

  • nvim --version:
NVIM v0.5.0-704-g905c2eb35
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-f2a9ebb1-a963-4862-8393-c5d9d3de43b3

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info
  • nvim-lsp version(commit hash): commit 60133c47e0fd82556d7ca092546ebfa8d047466e (grafted, HEAD -> master, origin/master, origin/HEAD)
  • :checkhealth result
health#nvim_lsp#check
========================================================================
## Checking language server protocol configuration
  - INFO: html: configuration checked.
  - INFO: jdtls: configuration checked.
  - INFO: sumneko_lua: configuration checked.
  - INFO: clangd: configuration checked.
  - INFO: pyls: configuration checked.
  - INFO: cssls: configuration checked.
  - INFO: vimls: configuration checked.
  - INFO: tsserver: configuration checked.
  - INFO: bashls: configuration checked.
  • What language server(If the problem is related to a specific language server): tsserver, jdtls
  • Operating system/version: Linux x86_64
  • Terminal name/version: alacritty 0.5.0
  • $TERM: xterm-256color

How to reproduce the problem from neovim startup

init.vim

lua << EOF
require"nvim_lsp".tsserver.setup {}
require"nvim_lsp".jdtls.setup {}
EOF

  1. Install tsserver and jdtls.
  2. Run nvim example.java

Actual behaviour

LSP doesn't load

Expected behaviour

LSP should load

bug

Most helpful comment

Also for tsserver apparently you need to have a tsconfig.json in the directory. I say apparently because I didn't try but saw it working that way for someone on youtube.

Try installing typescript as a global package. npm i -g typescript

It works for me without having to have a tsconfig.json file inside my project directory

All 18 comments

I was able to make jdtls load once or twice but it was never consistent. The only time it happened is when I set the workspace to a directory I used Eclipse for.
Maybe for jdtls we need some file present in the directory.
Also for tsserver apparently you need to have a tsconfig.json in the directory. I say apparently because I didn't try but saw it working that way for someone on youtube.

Also for tsserver apparently you need to have a tsconfig.json in the directory. I say apparently because I didn't try but saw it working that way for someone on youtube.

Try installing typescript as a global package. npm i -g typescript

It works for me without having to have a tsconfig.json file inside my project directory

I tried both the solutions neither worked.

Also for tsserver apparently you need to have a tsconfig.json in the directory. I say apparently because I didn't try but saw it working that way for someone on youtube.

Try installing typescript as a global package. npm i -g typescript

It works for me without having to have a tsconfig.json file inside my project directory

This solves it for me.

@blackCauldron7 For tsserver, you can also try installing the nodejs provider.

@ngtinsmith you mean npm install neovim? btw i have all the providers installed already.

I thought I was going crazy but it indeed does not work for me either. Nor sumneko_lua too.

My custom pyls is working but thats it

My healthcheck looks fine

https://pastebin.com/SGfs3WNA

Can you share your config because for me sumneko_lua works.@beauwilliams

maybe related to root_dir ? You might want to change it to vim.loop.cwd so the LSP will run regardless of the current cwd, it usually checks for .git directory or related files like package.json for example.

Can you share your config because for me sumneko_lua works.@beauwilliams

Absolutely. The funny thing is that the lua server definitely runs because I can see it in my activity monitor after launching an lua file for editing.

I am not getting any completion popups. Nor for jdtls. The pyls works a charm however.
Maybe I am missing something simple but I have never been able to get these working except for pyls

https://pastebin.com/BZ89BmhY

maybe related to root_dir ? You might want to change it to vim.loop.cwd so the LSP will run regardless of the current cwd, it usually checks for .git directory or related files like package.json for example.

I have made these changes

lsp.jdtls.setup {on_attach = custom_attach, root_dir = vim.loop.cwd }

And run a nvim test.java and I am not getting any completions happening either.

As a side note I have tried various different projects and structures from git to maven with a pom.xml to see if it needed a particular structure. I have not yet been able to get it workiing

Can you share your lsp log?

No problem at all

https://pastebin.com/maswSTgZ

Looks like the issue may possibly be related to this line

[ DEBUG ] 2020-12-19T10:04:46+1100 ] ...r/neovim/HEAD-c348e81/share/nvim/runtime/lua/vim/lsp.lua:491 ] "server_request: no handler found for" "client/registerCapability"

Aha. I have got .lua files working. I would have been suprised lua was not working!

They required to be in a .git cwd.

I found this out when I went to make the same source changes committed to the yamls file reference in your issue.

JDTLS is still not even launching however and I have tried everything

FYI For anyone reading this in the future. Here is a lua config that works for me in any dir (does not require you to be in a .git etc)

lsp.sumneko_lua.setup {on_attach = custom_attach, root_dir = vim.loop.cwd }

I have completion/diags after running nvim test.lua

Here is a config for typescript that works for me -- NOTE: I ran npm i -g typescript earlier so not sure if that also helped

lsp.tsserver.setup {on_attach = custom_attach, root_dir = vim.loop.cwd }

I have completion/diags after running nvim test.ts

Can you try adding this to your lua block in init.vim?

```lua
local configs = require('lspconfig/configs')
configs.jdtls.handlers = {
['client/registerCapability'] = function(_, _, _, _)
return {
result = nil;
error = nil;
}
end
}
````

Can you try adding this to your lua block in init.vim?

  local configs = require('lspconfig/configs')
  configs.jdtls.handlers = {
      ['client/registerCapability'] = function(_, _, _, _)
        return {
          result = nil;
          error = nil;
        }
      end
  }

Thanks, I have tried applying this but no luck yet. I think my issue may be related to this error
[ ERROR ] 2020-12-19T11:01:19+1100 ] ...ovim/HEAD-c348e81/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "java" "stderr" "Error: Unable to access jarfile \27[1m\27[31m/Users/admin/.cache/nvim/lspconfig/jdtls/plugins/org.eclipse.equinox.launcher_1.6.0.v20200915-1508.jar\27[39;49m\27[0m\n"

Perhaps jdtls is not compiled right

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmedelgabri picture ahmedelgabri  路  4Comments

RefusesNames picture RefusesNames  路  3Comments

matklad picture matklad  路  5Comments

DarkDefender picture DarkDefender  路  3Comments

ChrisAmelia picture ChrisAmelia  路  3Comments