joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.21k stars 203 forks source link

Invalid params for initialize ":codeAction/resolve" #1255

Closed archer-n closed 12 months ago

archer-n commented 12 months ago

I tried the solution and it worked, write at the end

LSP transcript - M-x eglot-events-buffer (mandatory unless Emacs inoperable)

(:jsonrpc "2.0" :id 1 :method "initialize" :params
          (:processId 71964 :clientInfo (:name "Eglot") :rootPath
                      "/home/archer/workspace/android/foo/"
                      :rootUri
                      "file:///home/archer/workspace/android/foo"
                      :initializationOptions
                      #s(hash-table size 1 test eql rehash-size 1.5
                                    rehash-threshold 0.8125 data ())
                      :capabilities
                      (:workspace
                       (:applyEdit t :executeCommand
                                   (:dynamicRegistration :json-false)
                                   :workspaceEdit (:documentChanges t)
                                   :didChangeWatchedFiles
                                   (:dynamicRegistration t) :symbol
                                   (:dynamicRegistration :json-false)
                                   :configuration t :workspaceFolders
                                   t)
                       :textDocument
                       (:synchronization
                        (:dynamicRegistration :json-false :willSave t
                                              :willSaveWaitUntil t
                                              :didSave t)
                        :completion
                        (:dynamicRegistration :json-false
                                              :completionItem
                                              (:snippetSupport t
                                                               :deprecatedSupport
                                                               t
                                                               :resolveSupport
                                                               (:properties
                                                                ["documentation"
                                                                 "details"
                                                                 "additionalTextEdits"])
                                                               :tagSupport
                                                               (:valueSet
                                                                [1]))
                                              :contextSupport t)
                        :hover
                        (:dynamicRegistration :json-false
                                              :contentFormat
                                              ["markdown" "plaintext"])
                        :signatureHelp
                        (:dynamicRegistration :json-false
                                              :signatureInformation
                                              (:parameterInformation
                                               (:labelOffsetSupport t)
                                               :documentationFormat
                                               ["markdown" "plaintext"]
                                               :activeParameterSupport
                                               t))
                        :references (:dynamicRegistration :json-false)
                        :definition
                        (:dynamicRegistration :json-false :linkSupport
                                              t)
                        :declaration
                        (:dynamicRegistration :json-false :linkSupport
                                              t)
                        :implementation
                        (:dynamicRegistration :json-false :linkSupport
                                              t)
                        :typeDefinition
                        (:dynamicRegistration :json-false :linkSupport
                                              t)
                        :documentSymbol
                        (:dynamicRegistration :json-false
                                              :hierarchicalDocumentSymbolSupport
                                              t :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]))
                        :documentHighlight
                        (:dynamicRegistration :json-false) :codeAction
                        (:dynamicRegistration :json-false
                                              :resolveSupport t
                                              :dataSupport t
                                              :codeActionLiteralSupport
                                              (:codeActionKind
                                               (:valueSet
                                                ["quickfix" "refactor"
                                                 "refactor.extract"
                                                 "refactor.inline"
                                                 "refactor.rewrite"
                                                 "source"
                                                 "source.organizeImports"]))
                                              :isPreferredSupport t)
                        :formatting (:dynamicRegistration :json-false)
                        :rangeFormatting
                        (:dynamicRegistration :json-false) :rename
                        (:dynamicRegistration :json-false) :inlayHint
                        (:dynamicRegistration :json-false)
                        :publishDiagnostics
                        (:relatedInformation :json-false
                                             :codeDescriptionSupport
                                             :json-false :tagSupport
                                             (:valueSet [1 2])))
                       :window
                       (:showDocument (:support t) :workDoneProgress t)
                       :general
                       (:positionEncodings ["utf-32" "utf-8" "utf-16"])
                       :experimental
                       #s(hash-table size 1 test eql rehash-size 1.5
                                     rehash-threshold 0.8125 data ()))
                      :workspaceFolders
                      [(:uri
                        "file:///home/archer/workspace/android/foo"
                        :name "~/workspace/android/foo/")]))

(:id 1 :jsonrpc "2.0" :error
     (:code -32602 :message
            "Invalid params for initialize:\nparams.capabilities.textDocument.codeAction.resolveSupport must be of type CodeActionClientCapabilitiesResolveSupport"))

Backtrace (mandatory, unless no error message seen or heard):

Not possible to provide

Minimum Reproducible Example (mandatory)

  1. I start Emacs GUI
  2. I downloaded the latest dart sdk(Dart SDK version: 2.19.6 (stable) (Tue Mar 28 13:41:04 2023 +0000) on "linux_x64") executable
  3. I can reproduce on any Dart file or repository

Tried the solution, it's worked

  1. After reading the lsp document, I found that the data format is incorrect

  2. After modifying the source code, rebuild emacs, Below is my modification:

              :codeAction         (list
                                   :dynamicRegistration :json-false
    -                                  :resolveSupport t :dataSupport t
    +                                  :resolveSupport `(:properties ["edit"])
    +                                  :dataSupport t
                                   :codeActionLiteralSupport
joaotavora commented 12 months ago

Thank you. I pushed a fix https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=bc1e7b9b8e681346e407c4dc32272a0bf4decd68