Skip to content

Doesn't work with native json (which also means emacs 27 if correctly built) #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
walseb opened this issue Jul 16, 2019 · 6 comments
Closed

Comments

@walseb
Copy link

walseb commented Jul 16, 2019

Emacs 27 comes with fast native json support. However if emacs is built with this (check system-configuration-features for "JSON" entry) and lsp-use-native-json is t, starting the server results in an error and then nothing happens. This is the backtrace I got from having backtrace on error set to t.

Debugger entered--Lisp error: (wrong-type-argument json-value-p lsp-haskell--make-init-options)
  json-serialize((:jsonrpc "2.0" :method "initialize" :params (:processId 27696 :rootPath "/home/admin/TestProject/" :rootUri "file:///home/admin/TestProject/" :capabilities ((workspace (workspaceEdit (documentChanges . t) (resourceOperations . ["create" "rename" "delete"])) (applyEdit . t) (symbol (symbolKind (valueSet . ...))) (executeCommand (dynamicRegistration . :json-false)) (didChangeWatchedFiles (dynamicRegistration . t)) (workspaceFolders . t) (configuration . t)) (textDocument (declaration (linkSupport . t)) (definition (linkSupport . t)) (implementation (linkSupport . t)) (typeDefinition (linkSupport . t)) (synchronization (willSave . t) (didSave . t) (willSaveWaitUntil . t)) (documentSymbol (symbolKind (valueSet . ...)) (hierarchicalDocumentSymbolSupport . t)) (formatting (dynamicRegistration . t)) (codeAction (dynamicRegistration . t) (codeActionLiteralSupport (codeActionKind ...))) (completion (completionItem (snippetSupport . t) (documentationFormat . ...)) (contextSupport . t)) (signatureHelp (signatureInformation (parameterInformation ...))) (documentLink (dynamicRegistration . t)) (hover (contentFormat . ["markdown" "plaintext"])) (foldingRange (dynamicRegistration . t) (rangeLimit) (lineFoldingOnly)))) :initializationOptions lsp-haskell--make-init-options) :id 11) :null-object nil :false-object :json-false)
  lsp--make-message((:jsonrpc "2.0" :method "initialize" :params (:processId 27696 :rootPath "/home/admin/TestProject/" :rootUri "file:///home/admin/TestProject/" :capabilities ((workspace (workspaceEdit (documentChanges . t) (resourceOperations . ["create" "rename" "delete"])) (applyEdit . t) (symbol (symbolKind (valueSet . ...))) (executeCommand (dynamicRegistration . :json-false)) (didChangeWatchedFiles (dynamicRegistration . t)) (workspaceFolders . t) (configuration . t)) (textDocument (declaration (linkSupport . t)) (definition (linkSupport . t)) (implementation (linkSupport . t)) (typeDefinition (linkSupport . t)) (synchronization (willSave . t) (didSave . t) (willSaveWaitUntil . t)) (documentSymbol (symbolKind (valueSet . ...)) (hierarchicalDocumentSymbolSupport . t)) (formatting (dynamicRegistration . t)) (codeAction (dynamicRegistration . t) (codeActionLiteralSupport (codeActionKind ...))) (completion (completionItem (snippetSupport . t) (documentationFormat . ...)) (contextSupport . t)) (signatureHelp (signatureInformation (parameterInformation ...))) (documentLink (dynamicRegistration . t)) (hover (contentFormat . ["markdown" "plaintext"])) (foldingRange (dynamicRegistration . t) (rangeLimit) (lineFoldingOnly)))) :initializationOptions lsp-haskell--make-init-options) :id 11))
  lsp--send-request-async((:jsonrpc "2.0" :method "initialize" :params (:processId 27696 :rootPath "/home/admin/TestProject/" :rootUri "file:///home/admin/TestProject/" :capabilities ((workspace (workspaceEdit (documentChanges . t) (resourceOperations . ["create" "rename" "delete"])) (applyEdit . t) (symbol (symbolKind (valueSet . ...))) (executeCommand (dynamicRegistration . :json-false)) (didChangeWatchedFiles (dynamicRegistration . t)) (workspaceFolders . t) (configuration . t)) (textDocument (declaration (linkSupport . t)) (definition (linkSupport . t)) (implementation (linkSupport . t)) (typeDefinition (linkSupport . t)) (synchronization (willSave . t) (didSave . t) (willSaveWaitUntil . t)) (documentSymbol (symbolKind (valueSet . ...)) (hierarchicalDocumentSymbolSupport . t)) (formatting (dynamicRegistration . t)) (codeAction (dynamicRegistration . t) (codeActionLiteralSupport (codeActionKind ...))) (completion (completionItem (snippetSupport . t) (documentationFormat . ...)) (contextSupport . t)) (signatureHelp (signatureInformation (parameterInformation ...))) (documentLink (dynamicRegistration . t)) (hover (contentFormat . ["markdown" "plaintext"])) (foldingRange (dynamicRegistration . t) (rangeLimit) (lineFoldingOnly)))) :initializationOptions lsp-haskell--make-init-options) :id 11) #f(compiled-function (response) #<bytecode 0x1778579>) detached nil nil)
  lsp-request-async("initialize" (:processId 27696 :rootPath "/home/admin/TestProject/" :rootUri "file:///home/admin/TestProject/" :capabilities ((workspace (workspaceEdit (documentChanges . t) (resourceOperations . ["create" "rename" "delete"])) (applyEdit . t) (symbol (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]))) (executeCommand (dynamicRegistration . :json-false)) (didChangeWatchedFiles (dynamicRegistration . t)) (workspaceFolders . t) (configuration . t)) (textDocument (declaration (linkSupport . t)) (definition (linkSupport . t)) (implementation (linkSupport . t)) (typeDefinition (linkSupport . t)) (synchronization (willSave . t) (didSave . t) (willSaveWaitUntil . t)) (documentSymbol (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])) (hierarchicalDocumentSymbolSupport . t)) (formatting (dynamicRegistration . t)) (codeAction (dynamicRegistration . t) (codeActionLiteralSupport (codeActionKind (valueSet . ...)))) (completion (completionItem (snippetSupport . t) (documentationFormat . ["markdown"])) (contextSupport . t)) (signatureHelp (signatureInformation (parameterInformation (labelOffsetSupport . t)))) (documentLink (dynamicRegistration . t)) (hover (contentFormat . ["markdown" "plaintext"])) (foldingRange (dynamicRegistration . t) (rangeLimit) (lineFoldingOnly)))) :initializationOptions lsp-haskell--make-init-options) #f(compiled-function (response) #<bytecode 0x1778579>) :mode detached)
  lsp--start-workspace(#s(lsp-session :folders ("/home/admin/TestProject/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x1886889> :folder->servers #<hash-table equal 1/65 0x191ae8d> :metadata #<hash-table equal 1/65 0x194ae7d>) #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1319171>) :test\? #f(compiled-function () #<bytecode 0x1319189>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1319195> :request-handlers #<hash-table equal 0/65 0x13192bd> :response-handlers #<hash-table eql 0/65 0x13192dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x13218c5> :action-handlers #<hash-table equal 0/65 0x1321f39> :major-modes (haskell-mode) :activation-fn nil :priority 0 :server-id hie :multi-root nil :initialization-options lsp-haskell--make-init-options :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil) "/home/admin/TestProject/" lsp-haskell--make-init-options)
  lsp--start-connection(#s(lsp-session :folders ("/home/admin/TestProject/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x1886889> :folder->servers #<hash-table equal 1/65 0x191ae8d> :metadata #<hash-table equal 1/65 0x194ae7d>) #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1319171>) :test\? #f(compiled-function () #<bytecode 0x1319189>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1319195> :request-handlers #<hash-table equal 0/65 0x13192bd> :response-handlers #<hash-table eql 0/65 0x13192dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x13218c5> :action-handlers #<hash-table equal 0/65 0x1321f39> :major-modes (haskell-mode) :activation-fn nil :priority 0 :server-id hie :multi-root nil :initialization-options lsp-haskell--make-init-options :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil) "/home/admin/TestProject/")
  #f(compiled-function (client) #<bytecode 0x15b6d71>)(#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1319171>) :test\? #f(compiled-function () #<bytecode 0x1319189>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1319195> :request-handlers #<hash-table equal 0/65 0x13192bd> :response-handlers #<hash-table eql 0/65 0x13192dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x13218c5> :action-handlers #<hash-table equal 0/65 0x1321f39> :major-modes (haskell-mode) :activation-fn nil :priority 0 :server-id hie :multi-root nil :initialization-options lsp-haskell--make-init-options :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil))
  mapcar(#f(compiled-function (client) #<bytecode 0x15b6d71>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1319171>) :test\? #f(compiled-function () #<bytecode 0x1319189>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1319195> :request-handlers #<hash-table equal 0/65 0x13192bd> :response-handlers #<hash-table eql 0/65 0x13192dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x13218c5> :action-handlers #<hash-table equal 0/65 0x1321f39> :major-modes (haskell-mode) :activation-fn nil :priority 0 :server-id hie :multi-root nil :initialization-options lsp-haskell--make-init-options :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil)))
  -map(#f(compiled-function (client) #<bytecode 0x15b6d71>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1319171>) :test\? #f(compiled-function () #<bytecode 0x1319189>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1319195> :request-handlers #<hash-table equal 0/65 0x13192bd> :response-handlers #<hash-table eql 0/65 0x13192dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x13218c5> :action-handlers #<hash-table equal 0/65 0x1321f39> :major-modes (haskell-mode) :activation-fn nil :priority 0 :server-id hie :multi-root nil :initialization-options lsp-haskell--make-init-options :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil)))
  lsp--ensure-lsp-servers(#s(lsp-session :folders ("/home/admin/TestProject/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x1886889> :folder->servers #<hash-table equal 1/65 0x191ae8d> :metadata #<hash-table equal 1/65 0x194ae7d>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1319171>) :test\? #f(compiled-function () #<bytecode 0x1319189>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1319195> :request-handlers #<hash-table equal 0/65 0x13192bd> :response-handlers #<hash-table eql 0/65 0x13192dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x13218c5> :action-handlers #<hash-table equal 0/65 0x1321f39> :major-modes (haskell-mode) :activation-fn nil :priority 0 :server-id hie :multi-root nil :initialization-options lsp-haskell--make-init-options :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil)) "/home/admin/TestProject/" nil)
  lsp--try-project-root-workspaces(nil nil)
  lsp()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook haskell-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook haskell-mode-hook))
  run-mode-hooks(haskell-mode-hook)
  haskell-mode()
  set-auto-mode-0(haskell-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer Main.hs> "~/TestProject/src/Main.hs" nil nil "~/TestProject/src/Main.hs" (2805026 2049))
  find-file-noselect("/home/admin/TestProject/src/Main.hs" nil nil nil)
  find-file("/home/admin/TestProject/src/Main.hs")
  dired-find-file()
  funcall-interactively(dired-find-file)
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)
@walseb walseb changed the title Doesn't work with native json Doesn't work with native json (which also means emacs 27 if correctly built) Jul 27, 2019
@walseb
Copy link
Author

walseb commented Jul 27, 2019

I just got it working by commenting out :initialization-options from make-lsp--client. Seems like the way initialization options are formatted has changed between the new and the old json implementation.

@walseb
Copy link
Author

walseb commented Jul 27, 2019

Also I'm not too sure about this but it also seems like HIE doesn't break on my projects any more after removing :initialization-options. Before pretty much all projects wouldn't work correctly but now everything seems to be working fine. The bug messages were also all coercion errors going from Config type to String, so I think somethings up with the init options even without native json

@yyoncho
Copy link
Member

yyoncho commented Jul 27, 2019

FTR native json serialization requires lists to be vectors otherwise it tries to serialize them like objects and fails.

@walseb
Copy link
Author

walseb commented Dec 30, 2019

Closing because #60 got rid of the init options. I haven't tried it however but the change should fix it

@walseb walseb closed this as completed Dec 30, 2019
@alanz
Copy link
Contributor

alanz commented Dec 30, 2019

FYI the init options were not well-formed json, just a string, since the function quoted was never actually implemented.

@d12frosted
Copy link

It seems that lsp-use-native-json is no longer available, but after #60 I don't experience the issue anymore (built with native json support).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants