-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Description
Hello, I just upgraded to Emacs 27.1, and it seems that there was some change to the handling of JSON serialization. When trying the various lsp-set-formatter
commands:
lsp-set-formatter-ormolu
lsp-set-formatter-brittany
lsp-set-formatter-floskell
I get a: (wrong-type-argument json-value-p :ormolu)
, (wrong-type-argument json-value-p :brittany)
, or (wrong-type-argument json-value-p :floskell)
, respectively.
Here's a Backtrace from trying lsp-set-formatter-brittany
:
Debugger entered--Lisp error: (wrong-type-argument json-value-p :brittany)
json-serialize((:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings (:languageServerHaskell #<hash-table eql 3/65 0x1ff4d46f7b2d>))) :null-object nil :false-object :json-false)
(let ((body (json-serialize params :null-object nil :false-object :json-false))) (concat "Content-Length: " (number-to-string (1+ (string-bytes body))) "\15\n\15\n" body "\n"))
lsp--make-message((:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings (:languageServerHaskell #<hash-table eql 3/65 0x1ff4d46f7b2d>))))
(lsp--send-no-wait (lsp--make-message body) (progn (or (and (memq (type-of lsp--cur-workspace) cl-struct-lsp--workspace-tags) t) (signal 'wrong-type-argument (list 'lsp--workspace lsp--cur-workspace))) (aref lsp--cur-workspace 7)))
(let ((lsp--cur-workspace it)) (if lsp-print-io (progn (lsp--log-entry-new (lsp--make-log-entry (plist-get body :method) nil (plist-get body :params) 'outgoing-notif) lsp--cur-workspace))) (lsp--send-no-wait (lsp--make-message body) (progn (or (and (memq (type-of lsp--cur-workspace) cl-struct-lsp--workspace-tags) t) (signal 'wrong-type-argument (list 'lsp--workspace lsp--cur-workspace))) (aref lsp--cur-workspace 7))))
(closure ((body :jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings (:languageServerHaskell #<hash-table eql 3/65 0x1ff4d46f7b2d>))) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines dap-ui-menu-items dap-auto-configure-mode t) (it) (let ((lsp--cur-workspace it)) (if lsp-print-io (progn (lsp--log-entry-new (lsp--make-log-entry (plist-get body :method) nil (plist-get body :params) 'outgoing-notif) lsp--cur-workspace))) (lsp--send-no-wait (lsp--make-message body) (progn (or (and (memq ... cl-struct-lsp--workspace-tags) t) (signal 'wrong-type-argument (list ... lsp--cur-workspace))) (aref lsp--cur-workspace 7)))))(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 17/17 0x1ff4d6363c41> :registered-server-capabilities (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :root "/Users/shaun/workspa..." :client #s(lsp--client :language-id nil :add-on? nil :new-connection ... :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff4d377d0c1> :request-handlers #<hash-table equal 0/65 0x1ff4d37d6cb1> :response-handlers #<hash-table eql 3/65 0x1ff4d37d6fa9> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff4d37d7281> :action-handlers #<hash-table equal 0/65 0x1ff4d37d72a1> :major-modes ... :activation-fn nil :priority 0 :server-id hie :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil ...) :host-root nil :proc #<process hie> :cmd-proc #<process hie> :buffers (#<buffer Scenes.hs> #<buffer Lib.hs> #<buffer Random.hs> #<buffer Main.hs>) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff4d6518a55> :watches #<hash-table equal 0/65 0x1ff4d6518d2d> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x1ff4d6518dd1> ...))
mapcar((closure ((body :jsonrpc "2.0" :method "workspace/didChangeConfigu..." :params ...) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines dap-ui-menu-items dap-auto-configure-mode t) (it) (let (...) (if lsp-print-io ...) (lsp--send-no-wait ... ...))) (#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 17/17 0x1ff4d6363c41> :registered-server-capabilities (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :root "/Users/shaun/workspace/ray..." :client #s(lsp--client :language-id nil :add-on? nil :new-connection ... :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff4d377d0c1> :request-handlers #<hash-table equal 0/65 0x1ff4d37d6cb1> :response-handlers #<hash-table eql 3/65 0x1ff4d37d6fa9> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff4d37d7281> :action-handlers #<hash-table equal 0/65 0x1ff4d37d72a1> :major-modes ... :activation-fn nil :priority 0 :server-id hie :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn ... :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil ...) :host-root nil :proc #<process hie> :cmd-proc #<process hie> :buffers (#<buffer Scenes.hs> #<buffer Lib.hs> #<buffer Random.hs> #<buffer Main.hs>) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff4d6518a55> :watches #<hash-table equal 0/65 0x1ff4d6518d2d> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x1ff4d6518dd1> :work-done-tokens #<hash-table equal 0/65 0x1ff4d64fd4c1>)))
lsp--send-notification((:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings (:languageServerHaskell #<hash-table eql 3/65 0x1ff4d46f7b2d>))))
lsp-notify("workspace/didChangeConfiguration" (:settings (:languageServerHaskell #<hash-table eql 3/65 0x1ff4d46f7b2d>)))
lsp--set-configuration((:languageServerHaskell #<hash-table eql 3/65 0x1ff4d46f7b2d>))
lsp-haskell--set-configuration()
lsp-haskell-set-formatter-brittany()
funcall-interactively(lsp-haskell-set-formatter-brittany)
call-interactively(lsp-haskell-set-formatter-brittany record nil)
command-execute(lsp-haskell-set-formatter-brittany record)
execute-extended-command(nil "lsp-haskell-set-formatter-brittany" "lsp-haskell-set-formatter-brit")
funcall-interactively(execute-extended-command nil "lsp-haskell-set-formatter-brittany" "lsp-haskell-set-formatter-brit")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
As an experiment, modifying the lsp-haskell-set-formatter
functions to use strings seems to solve the issue:
(defun lsp-haskell-set-formatter-brittany ()
"Use brittany."
(interactive)
(lsp-haskell-set-formatter "brittany")
(lsp-haskell--set-configuration))
(defun lsp-haskell-set-formatter-floskell ()
"Use floskell."
(interactive)
(lsp-haskell-set-formatter "floskell")
(lsp-haskell--set-configuration))
(defun lsp-haskell-set-formatter-ormolu ()
"Use ormolu."
(interactive)
(lsp-haskell-set-formatter "ormolu")
(lsp-haskell--set-configuration))
However, I don't know if this breaks compatibility with prior versions of Emacs.
Edit: Using strings instead of symbols, as shown above, also works on Emacs 26.3.
CarlosMChica, pbogdan, NickSeagull, dschrempf and michaelpj
Metadata
Metadata
Assignees
Labels
No labels