nvim --version: NVIM v0.5.0-660-g2cea6ab01
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-fcc306c2-8f0c-4f8c-b636-8ebb12f7e21c
nvim-lsp version(commit hash): d108d5335dada658
:checkhealth result:
jdtls
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic
gnome 3.28.4
$TERM:xterm-256color
With a minimal init.vim:
set runtimepath^=~/.local/share/nvim/plugged/nvim-lspconfig
filetype plugin indent on
syntax on
set hidden
lua << EOF
require'nvim_lsp'.jdtls.setup{}
EOF
set omnifunc=v:lua.vim.lsp.omnifunc
And in a maven workspace with a single file Main.java:
public class Main {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
Run it with nvim -u init.vim Main.java.
jdtls doesn't seem to be started, command lua print(vim.inspect(vim.lsp.buf_get_clients())) gives an empty list {}.
It just works.
Check the LSP logs:
:lua vim.lsp.set_log_level(0)
:exe 'edit' v:lua.vim.lsp.get_log_path()
I forgot to mention that the log file is full of empty lines ~/.local/share/nvim/lsp.log.
see updated instructions, I think the log level needs to be set
Using go-to-definition:
[ INFO ] 2020-09-06T21:33:54+0200 ] ...nt_nvimaZ8gOq/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:283 ] "Starting RPC client" { args = { "-Declipse.application=org.eclipse.jdt.ls.core.id1", "-Dosgi.bundles.defaultStartLevel=4", "-Declipse.product=org.eclipse.jdt.ls.core.product", "-Dlog.level=ALL", "-noverify", "-Xmx1G", "-jar", "/home/vim/.cache/nvim/nvim_lsp/jdtls/plugins/org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar", "-configuration", "/home/vim/.cache/nvim/nvim_lsp/jdtls/config_linux", "-data", "/home/vim/workspace", "--add-modules=ALL-SYSTEM", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED" }, cmd = "java", extra = {}}
[ DEBUG ] 2020-09-06T21:33:54+0200 ] ....mount_nvimaZ8gOq/usr/share/nvim/runtime/lua/vim/lsp.lua:568 ] "LSP[jdtls]" "initialize_params" { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 14204, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off"}
[ DEBUG ] 2020-09-06T21:33:54+0200 ] ...nt_nvimaZ8gOq/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:361 ] "rpc.send.payload" { id = 1, jsonrpc = "2.0", method = "initialize", params = { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 14204, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off" }}
Using hover:
[ INFO ] 2020-09-07T17:37:22+0200 ] ...nt_nvim4mMG9y/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:283 ] "Starting RPC client" { args = { "-Declipse.application=org.eclipse.jdt.ls.core.id1", "-Dosgi.bundles.defaultStartLevel=4", "-Declipse.product=org.eclipse.jdt.ls.core.product", "-Dlog.level=ALL", "-noverify", "-Xmx1G", "-jar", "/home/vim/.cache/nvim/nvim_lsp/jdtls/plugins/org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar", "-configuration", "/home/vim/.cache/nvim/nvim_lsp/jdtls/config_linux", "-data", "/home/vim/workspace", "--add-modules=ALL-SYSTEM", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED" }, cmd = "java", extra = {}}
[ DEBUG ] 2020-09-07T17:37:22+0200 ] ....mount_nvim4mMG9y/usr/share/nvim/runtime/lua/vim/lsp.lua:568 ] "LSP[jdtls]" "initialize_params" { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 15763, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off"}
[ DEBUG ] 2020-09-07T17:37:22+0200 ] ...nt_nvim4mMG9y/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:361 ] "rpc.send.payload" { id = 1, jsonrpc = "2.0", method = "initialize", params = { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 15763, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off" }}
looks like a client was started, you can verify with
:lua print(vim.inspect(vim.lsp.get_active_clients()))
seems like it wasn't associated with the *.java buffer for some reason.
I've checked that the server was started but :lua print(vim.inspect(vim.lsp.get_active_clients())) still returns an empty array.
hmm. Need to debug what's going on. Try setting some handlers to see if we can get info:
lua << EOF
require'nvim_lsp'.jdtls.setup{
on_attach = function(...)
require'vim.lsp.log'.error('xxx on_attach: '..vim.inspect(...))
end,
on_exit = function(...)
require'vim.lsp.log'.error('xxx on_exit: '..vim.inspect(...))
end,
}
EOF
(aside: wonder why we don't have logging in on_exit already. Will add that...)
With vim.lsp.get_active_clients():
lua << EOF
require'nvim_lsp'.jdtls.setup{
on_attach = function(_)
require'vim.lsp.log'.error('xxx on_attach: '..vim.inspect(vim.lsp.get_active_clients()))
end,
on_exit = function(_)
require'vim.lsp.log'.error('xxx on_exit: '..vim.inspect(vim.lsp.get_active_clients()))
end,
}
EOF
[ INFO ] 2020-09-07T23:08:16+0200 ] ...nt_nvimHa0Hu7/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:283 ] "Starting RPC client" { args = { "-Declipse.application=org.eclipse.jdt.ls.core.id1", "-Dosgi.bundles.defaultStartLevel=4", "-Declipse.product=org.eclipse.jdt.ls.core.product", "-Dlog.level=ALL", "-noverify", "-Xmx1G", "-jar", "/home/vim/.cache/nvim/nvim_lsp/jdtls/plugins/org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar", "-configuration", "/home/vim/.cache/nvim/nvim_lsp/jdtls/config_linux", "-data", "/home/vim/workspace", "--add-modules=ALL-SYSTEM", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED" }, cmd = "java", extra = {}}
[ DEBUG ] 2020-09-07T23:08:16+0200 ] ....mount_nvimHa0Hu7/usr/share/nvim/runtime/lua/vim/lsp.lua:568 ] "LSP[jdtls]" "initialize_params" { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 22365, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off"}
[ DEBUG ] 2020-09-07T23:08:16+0200 ] ...nt_nvimHa0Hu7/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:361 ] "rpc.send.payload" { id = 1, jsonrpc = "2.0", method = "initialize", params = { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 22365, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off" }}
[ ERROR ] 2020-09-07T23:08:19+0200 ] [string ":lua"]:6 ] "xxx on_exit: {}"
can you try the code I gave? (The ... parts are not pseudocode.) It will print the args given to on_exit. Printing the result of get_active_clients() isn't telling us anything.
Though we have at least confirmed that the client is exiting.
[ INFO ] 2020-09-08T00:06:06+0200 ] ...nt_nvimsob3gc/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:283 ] "Starting RPC client" { args = { "-Declipse.application=org.eclipse.jdt.ls.core.id1", "-Dosgi.bundles.defaultStartLevel=4", "-Declipse.product=org.eclipse.jdt.ls.core.product", "-Dlog.level=ALL", "-noverify", "-Xmx1G", "-jar", "/home/vim/.cache/nvim/nvim_lsp/jdtls/plugins/org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar", "-configuration", "/home/vim/.cache/nvim/nvim_lsp/jdtls/config_linux", "-data", "/home/vim/workspace", "--add-modules=ALL-SYSTEM", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED" }, cmd = "java", extra = {}}
[ DEBUG ] 2020-09-08T00:06:06+0200 ] ....mount_nvimsob3gc/usr/share/nvim/runtime/lua/vim/lsp.lua:568 ] "LSP[jdtls]" "initialize_params" { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 24856, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off"}
[ DEBUG ] 2020-09-08T00:06:06+0200 ] ...nt_nvimsob3gc/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:361 ] "rpc.send.payload" { id = 1, jsonrpc = "2.0", method = "initialize", params = { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 24856, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off" }}
[ INFO ] 2020-09-08T00:06:21+0200 ] ....mount_nvimsob3gc/usr/share/nvim/runtime/lua/vim/lsp.lua:958 ] "exit_handler" {}
Did you use function(_) instead of function(...)? Can you paste the exact config you tried?
P.S. why do your previous examples have function(_) ? That is not ever needed in Lua and is not mentioned in our docs I hope
I strictly use the above config:
init.vim
set runtimepath^=~/.local/share/nvim/plugged/nvim-lspconfig
filetype plugin indent on
syntax on
set hidden
set number
lua << EOF
require'nvim_lsp'.jdtls.setup{
on_attach = function(...)
require'vim.lsp.log'.error('xxx on_attach: '..vim.inspect(...))
end,
on_exit = function(...)
require'vim.lsp.log'.error('xxx on_exit: '..vim.inspect(...))
end,
}
EOF
Main.java
/**
* Main
*/
public class Main {
public static void main(String[] args) {
System.out.println(getMessage());
}
/**
* Returns "hello world";
*
* @return a message.
*/
public static String getMessage() {
return "Hello world";
}
}
lsp.log
[ INFO ] 2020-09-08T02:00:14+0200 ] ...nt_nvimMnHzmF/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:283 ] "Starting RPC client" { args = { "-Declipse.application=org.eclipse.jdt.ls.core.id1", "-Dosgi.bundles.defaultStartLevel=4", "-Declipse.product=org.eclipse.jdt.ls.core.product", "-Dlog.level=ALL", "-noverify", "-Xmx1G", "-jar", "/home/vim/.cache/nvim/nvim_lsp/jdtls/plugins/org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar", "-configuration", "/home/vim/.cache/nvim/nvim_lsp/jdtls/config_linux", "-data", "/home/vim/workspace", "--add-modules=ALL-SYSTEM", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED" }, cmd = "java", extra = {}}
[ DEBUG ] 2020-09-08T02:00:14+0200 ] ....mount_nvimMnHzmF/usr/share/nvim/runtime/lua/vim/lsp.lua:568 ] "LSP[jdtls]" "initialize_params" { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 25301, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off"}
[ DEBUG ] 2020-09-08T02:00:14+0200 ] ...nt_nvimMnHzmF/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:361 ] "rpc.send.payload" { id = 1, jsonrpc = "2.0", method = "initialize", params = { capabilities = { callHierarchy = { dynamicRegistration = false, <metatable> = <1>{ __tostring = <function 1> } }, textDocument = { codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = {}, <metatable> = <table 1> }, <metatable> = <table 1> }, dynamicRegistration = false, <metatable> = <table 1> }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = true, <metatable> = <table 1> }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }, <metatable> = <table 1> }, contextSupport = false, dynamicRegistration = false, <metatable> = <table 1> }, declaration = { linkSupport = true, <metatable> = <table 1> }, definition = { linkSupport = true, <metatable> = <table 1> }, documentHighlight = { dynamicRegistration = false, <metatable> = <table 1> }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false, <metatable> = <table 1> }, implementation = { linkSupport = true, <metatable> = <table 1> }, references = { dynamicRegistration = false, <metatable> = <table 1> }, signatureHelp = { dynamicRegistration = false, signatureInformation = { documentationFormat = { "markdown", "plaintext" }, <metatable> = <table 1> }, <metatable> = <table 1> }, synchronization = { didSave = true, dynamicRegistration = false, willSave = false, willSaveWaitUntil = false, <metatable> = <table 1> }, typeDefinition = { linkSupport = true, <metatable> = <table 1> }, <metatable> = <table 1> }, workspace = { applyEdit = true, configuration = true, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }, <metatable> = <table 1> }, <metatable> = <table 1> }, <metatable> = <table 1> } }, initializationOptions = { jvm_args = {}, workspace = "/home/vim/workspace", <metatable> = <table 1> }, processId = 25301, rootPath = "/home/vim/workspace", rootUri = "file:///home/vim/workspace", trace = "off" }}
[ INFO ] 2020-09-08T02:00:55+0200 ] ....mount_nvimMnHzmF/usr/share/nvim/runtime/lua/vim/lsp.lua:958 ] "exit_handler" {}
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
Go to folder my-app: cd my-app
Create init.vim and Main.java with above contents.
Open nvim with nvim -u init.vim.
Set verbose logging: :lua vim.lsp.set_log_level(0)
Open Main.java inside nvim: :e Main.java
Put cursor on getMessage().
Execute command :lua vim.lsp.buf.hover().
Open the LSP log file: :exe 'edit' v:lua.vim.lsp.get_log_path()
Regarding function(_), I thought ... was some metacode thus I decided to not use any parameters.
exit_handler comes from here https://github.com/neovim/neovim/blob/d8e6a0396a1bdc19c9e15adb233540816274487d/runtime/lua/vim/lsp.lua#L958lsp.start_client gets as far as https://github.com/neovim/neovim/blob/d8e6a0396a1bdc19c9e15adb233540816274487d/runtime/lua/vim/lsp.lua#L572on_attach handler we setup. sorry but I can't help further, need you to add logging to runtime/lua/vim/lsp.lua in your local install. Then if you figure it out, we can add extra guards/logs in there so that we aren't in the dark next time.
Testing on my work's repository makes it work.
I suspect the difference is the file pom.xml; I cannot paste it for professional reasons.
Although, I can attach the log.
Is it possible to make it work outside of a maven repo? e.g. for a quick instance of a java file.
Edit: I made it work with a simple pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I think there are other Maven configurations that make it work:
probably some commands to run (mvn package, mvn compile...).
I'll give it a look when I have time.
I had this same problem today, and found that if you use a different root_pattern from the defaults, then jtdls seems to start:
root_dir = root_pattern(".git", "pom.xml", "build.xml")
Then, pom.xml is detected as the root pattern for maven (as well as build.xml for ant). However the diagnostics seem a little slow compared to other language servers— might just be the actual LS itself though.
@Iron-E can you post your configuration? I'm having the same issue (even though my java project is in git already)
Sure thing! Here is an abbreviated version which shows the configuration for just jdtls:
-- Attach `completion-nvim` and `diagnostic-nvim` to the buffer.
local function lsp_setup()
require('completion').on_attach()
require('diagnostic').on_attach()
end
for lsp_key, lsp_settings in pairs({
--[[ NOTE: Normally, more LSPs would go here. ]]
['jdtls'] = { --------------------------- Java
['root_dir'] = nvim_lsp.util.root_pattern('.git', 'pom.xml', 'build.xml'),
['init_options'] = {
['jvm_args'] = {['java.format.settings.url'] = vim.fn.stdpath('config')..'/eclipse-formatter.xml'},
['workspace'] = vim.fn.stdpath('cache')..'/java-workspaces'
}
},
}) do -- Setup all of the language servers.
--[[ NOTE: Normally, there are more cases being handled. ]]
local on_attach_setting = lsp_settings.on_attach
lsp_settings.on_attach = function()
lsp_setup()
if on_attach_setting then on_attach_setting() end
end
nvim_lsp[lsp_key].setup(lsp_settings)
end
The full configuration is here.
Just a heads up. This wasn't obvious to me so others may be in the same boat. This language server requires Java 11 to run. It doesn't work with Java 8.
Just a heads up. This wasn't obvious to me so others may be in the same boat. This language server requires Java 11 to run. It doesn't work with Java 8.
Seems this is related to https://github.com/neoclide/coc-java/issues/99
Most helpful comment
I had this same problem today, and found that if you use a different
root_patternfrom the defaults, thenjtdlsseems to start:Then,
pom.xmlis detected as the root pattern formaven(as well asbuild.xmlforant). However the diagnostics seem a little slow compared to other language servers— might just be the actual LS itself though.