LanguageServer.jl
LanguageServer.jl copied to clipboard
Handle arbitrary values in response to workspace/configuration request
I am using LanguageServer with eglot and a recent update (to something) has broken things. I had customized a lint variable thru eglot. Apparently eglot sends Nothings for unchanged options in the configuration request to LS and a method of LintOptions should convert the Nothings to the default values. It looks to me like Julia cannot disambiguate the method with parameters Vararg{Union{Bool,Nothing}} from the LintOptions default constructor, and so calls the default, resulting in the below convert error. I removed the my customization and everything works fine again, so apparently eglot doesn't update the options if there are no changes.
LS Version 3.2 Julia v1.4.2
[stderr] ERROR: LoadError: MethodError: Cannot `convert` an object of type Nothing to an object of type Bool
[stderr] Closest candidates are:
[stderr] convert(::Type{T}, !Matched::T) where T<:Number at number.jl:6
[stderr] convert(::Type{T}, !Matched::Number) where T<:Number at number.jl:7
[stderr] convert(::Type{T}, !Matched::Ptr) where T<:Integer at pointer.jl:23
[stderr] ...
[stderr] ...
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr] nil
[stderr] nil
[stderr] nil
[stderr] [1] StaticLint.LintOptions(::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Int64) at /home/dale/.julia/packages/StaticLint/OfTiv/src/linting/checks.jl:65
[stderr] [2] request_julia_config(::LanguageServerInstance, ::JSONRPC.JSONRPCEndpoint) at /home/dale/.julia/packages/LanguageServer/y1ebo/src/requests/workspace.jl:119
[stderr] [3] initialized_notification(::LanguageServer.InitializedParams, ::LanguageServerInstance, ::JSONRPC.JSONRPCEndpoint) at /home/dale/.julia/packages/LanguageServer/y1ebo/src/requests/init.jl:173
[stderr] [4] (::LanguageServer.var"#112#144"{LanguageServerInstance})(::JSONRPC.JSONRPCEndpoint, ::LanguageServer.InitializedParams) at /home/dale/.julia/packages/LanguageServer/y1ebo/src/languageserverinstance.jl:284
[stderr] [5] dispatch_msg(::JSONRPC.JSONRPCEndpoint, ::JSONRPC.MsgDispatcher, ::Dict{String,Any}) at /home/dale/.julia/packages/JSONRPC/1Kq3H/src/typed.jl:66
[stderr] [6] run(::LanguageServerInstance) at /home/dale/.julia/packages/LanguageServer/y1ebo/src/languageserverinstance.jl:308
[stderr] [7] top-level scope at /home/dale/.emacs.d/elpa/eglot-jl-20200521.1739/eglot-jl.jl:37
[stderr] in expression starting at /home/dale/.emacs.d/elpa/eglot-jl-20200521.1739/eglot-jl.jl:37
I think the problem is that you tried to send a number for an option that requires a bool "julia.lint.useoffuncargs". To confirm, could you post the contents of eglot-workspace-configuration that cause this crash?
Reading the lsp spec, I don't think it's out-of-spec for the server to crash here. If the client can't provide a given configuration, it's supposed to return nil.
I think you are correct. I was using the the following config:
cat save.dir-locals.el
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((julia-mode
. ((eglot-workspace-configuration
. (("julia.lint.useoffuncargs" . 0))))))
I changed the 0 to nil and the LS no longer crashed. Since my Lisp days are far behind me, I wasn't sure nil would work here, but since its in a dotted pair it does. Since this worked before the latest release, I thought it was OK. The docstring for eglot-workspace-configuration says:
Documentation:
Alist of (SECTION . VALUE) entries configuring the LSP server.
SECTION should be a keyword or a string, value can be anything
that can be converted to JSON.
so confusing Julia with emacs-lisp I thought "0" would work (and it did).
I don't think this should crash the server though.