I am trying to write an LSP configuration for the VDMJ language server, but I cannot figure out why my current attempt isn’t working.
This is what I have in my init.vim
(note that I have my own file-type configuration that sets the vdm
file-type for files written in the various VDM dialects):
lua << EOF
local lspconfig = require'lspconfig'
local configs = require'lspconfig/configs'
-- Check if it's already defined for when reloading this file.
if not lspconfig.vdm then
local util = require 'lspconfig/util'
local mavenrepo = util.path.join(tostring(vim.fn.getenv("HOME")), "/.m2/repository/com/fujitsu")
local version = "4.4.3-SNAPSHOT"
local logfile = util.path.join(vim.fn.stdpath("cache"), "vdm-lsp.log")
local function getJarPath(string)
return util.path.join(mavenrepo, string, version, string .. "-" .. version .. ".jar")
end
local cmd = {
-- TODO: find a way to determine the correct path for a given Java version
"/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home/bin/java",
"-Xmx3000m -Xss1m",
"-Dlsp.log.filename=" .. logfile,
"-cp", table.concat({
getJarPath("vdmj"),
getJarPath("annotations"),
getJarPath("lsp"),
}, ":"),
"lsp.LSPServerStdio",
"-vdmsl"
}
configs.vdm = {
default_config = {
cmd = cmd;
filetypes = {'vdm'};
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname) or lspconfig.util.path.dirname()
end;
settings = {};
};
}
end
lspconfig.vdm.setup{}
EOF
The problem is that the server appears to exit immediately after starting: Client 1 quit with exit code 1 and signal 0
.
Now, :LspInfo
shows that the configuration has been loaded correctly:
However, both the log at ~/.cache/nvim/lsp.log
and the log at ~/.cache/nvim/vdm-lsp.log
are empty, even after setting vim.lsp.set_log_level("debug")
as suggested in the nvim-lspconfig readme. Furthermore, if I run the command shown in the output of :LspInfo
in a terminal, the server appears to run correctly and the following line gets appended to vdm-lsp.log
:
09:27:02.922: LSP VDM_SL Server listening on stdio
As I said, I am at a loss… is there any way I can gather more information from neovim about what is failing?