LanguageServer.jl icon indicating copy to clipboard operation
LanguageServer.jl copied to clipboard

MethodError while using LSP in Neovim

Open ronisbr opened this issue 6 months ago • 4 comments

Hi!

I am trying to use the LSP in Neovim and I am getting the following error:

[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"ERROR: "
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"MethodError: "
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"no method matching "
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"get_preexisting_using_stmts(::Nothing, ::LanguageServer.Document)"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"\nThe function `get_preexisting_using_stmts` exists, but no method is defined for this combination of argument types."
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"\n\nClosest candidates are:\n  get_preexisting_using_stmts(!Matched::CSTParser.EXPR, ::LanguageServer.Document)\n   @ LanguageServer ~/.julia/dev/LanguageServer/src/requests/completions.jl:505\n"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"\nStacktrace:"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"\n"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	" "
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"[1]"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	" "
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"textDocument_completion_request(params::LanguageServer.CompletionParams, server::LanguageServerInstance, conn::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint})"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"\n"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"   @"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	" "
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"LanguageServer"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	" "
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"~/.julia/dev/LanguageServer/src/requests/"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"completions.jl:47"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"\n"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	" "
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	"[2]"
[ERROR][2025-05-14 13:10:59] ...p/_transport.lua:36	"rpc"	"julia"	"stderr"	" "

I tried also with the dev version and nothing has changed.

ronisbr avatar May 14 '25 16:05 ronisbr

It works if I define:

function get_preexisting_using_stmts(::Nothing, doc::Document)
    return Dict{String,Any}()
end

in src/requests/completions.jl.

ronisbr avatar May 14 '25 16:05 ronisbr

It was caused by my configuration when I started to use the new API. It was fixed by adding:

      vim.lsp.config(
        "*",
        {
          capabilities = require('blink.cmp').get_lsp_capabilities()
        }
      )

ronisbr avatar May 14 '25 16:05 ronisbr

It still shouldn't error.

fredrikekre avatar May 15 '25 10:05 fredrikekre

It is somewhat random to reproduce the problem. But it seems to happen "most" of the time if you have a blank file and type using <some package>.

ronisbr avatar May 20 '25 13:05 ronisbr

Same issue using Helix editor. Happens when creating a new file w/ Helix then typing anything in it.

2025-06-26T21:49:26.557 helix_lsp::transport [ERROR] julia-lsp err <- "ERROR: MethodError: no method matching get_preexisting_using_stmts(::Nothing, ::LanguageServer.Document)\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- "The function `get_preexisting_using_stmts` exists, but no method is defined for this combination of argument types.\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- "\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- "Closest candidates are:\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- "  get_preexisting_using_stmts(!Matched::CSTParser.EXPR, ::LanguageServer.Document)\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- "   @ LanguageServer ~/.julia/packages/LanguageServer/Fwm1f/src/requests/completions.jl:505\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- "\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- "Stacktrace:\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- " [1] textDocument_completion_request(params::LanguageServer.CompletionParams, server::LanguageServerInstance, conn::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint})\n"
2025-06-26T21:49:26.687 helix_lsp::transport [ERROR] julia-lsp err <- "   @ LanguageServer ~/.julia/packages/LanguageServer/Fwm1f/src/requests/completions.jl:47\n"
2025-06-26T21:49:26.706 helix_lsp::transport [ERROR] julia-lsp err <- " [2] (::LanguageServer.var\"#116#117\"{typeof(LanguageServer.textDocument_completion_request), LanguageServerInstance})(conn::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::LanguageServer.CompletionParams)\n"
2025-06-26T21:49:26.706 helix_lsp::transport [ERROR] julia-lsp err <- "   @ LanguageServer ~/.julia/packages/LanguageServer/Fwm1f/src/languageserverinstance.jl:273\n"
2025-06-26T21:49:26.706 helix_lsp::transport [ERROR] julia-lsp err <- " [3] dispatch_msg(x::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::JSONRPC.MsgDispatcher, msg::Dict{String, Any})\n"
2025-06-26T21:49:26.706 helix_lsp::transport [ERROR] julia-lsp err <- "   @ JSONRPC ~/.julia/packages/JSONRPC/RIWyo/src/typed.jl:67\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- " [4] run(server::LanguageServerInstance; timings::Vector{Any})\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- "   @ LanguageServer ~/.julia/packages/LanguageServer/Fwm1f/src/languageserverinstance.jl:405\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- " [5] run\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- "   @ ~/.julia/packages/LanguageServer/Fwm1f/src/languageserverinstance.jl:283 [inlined]\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- " [6] runserver(pipe_in::Base.PipeEndpoint, pipe_out::Base.PipeEndpoint, env_path::String, depot_path::String, err_handler::Nothing, symserver_store_path::Nothing)\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- "   @ LanguageServer ~/.julia/packages/LanguageServer/Fwm1f/src/runserver.jl:41\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- " [7] runserver()\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- "   @ LanguageServer ~/.julia/packages/LanguageServer/Fwm1f/src/runserver.jl:39\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- " [8] top-level scope\n"
2025-06-26T21:49:26.707 helix_lsp::transport [ERROR] julia-lsp err <- "   @ none:1\n"

kazzarahw avatar Jun 27 '25 03:06 kazzarahw

@kazzarahw can you please check if this modification fixes the problem in Helix please? If so, I will submit a PR to close this bug:

It works if I define:

function get_preexisting_using_stmts(::Nothing, doc::Document) return Dict{String,Any}() end in src/requests/completions.jl.

ronisbr avatar Jun 27 '25 14:06 ronisbr

Yeah, that seems to have fixed it.

kazzarahw avatar Jun 28 '25 00:06 kazzarahw

Done! I have opened a PR that should fix this issue.

ronisbr avatar Jul 09 '25 23:07 ronisbr