Hi
I’m not sure if this is rather an LSP configuration problem or a Lua problem…
I’m trying to use PR#19916 for a language server that just uses a port that is available (DVT). So I can’t use connect until the server runs.
Instead of
vim.lsp.start({name="lsp", cmd=vim.lsp.rpc.connect(host, port)})
I try to do the following (simplified):
vim.lsp.start({
name="lsp",
cmd=function()
start_lsp()
port=get_lsp_port()
return vim.lsp.rpc.connect(host, port)
end
})
This fails with
Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:20: Vim(append):Error executing lua callback: /usr/share/nvim/runtime/lua/vim/lsp.lua:1283: attempt to index upvalue 'rpc' (a function value)
It looks like something local should not be so, but even making all global did not help.
If I just remove the function and keep the vim.lsp.rpc.connect it works (as expected and proposed by the PR).
Can you give me some hint what is wrong with my Lua code?
Or: Is this the completely wrong attempt? How should I get the port after server start? When should the server be started?
I’m trying to have it all in the autocmd for VHDL files, using vim.lsp.start (to hopefully have some manager that only one server is started).