Closed jouyouyun closed 2 years ago
Texlab seemed to crush.
@jouyouyun, could you comment texlab version?
@pfoerster, could you identify the cause?
@ROCKTAKEY This looks like an old version of texlab
. Maybe the LSP type definitions are outdated here, so there is a deserialization error. The "Error: invalid type: map, expected u32" message originates from serde
(the serialization library).
@jouyouyun Are you using an older version?
texlab version v4.3.1,from:https://github.com/latex-lsp/texlab
@jouyouyun Can you create a log file using texlab -vvvv --log-file /tmp/texlab.log
and post it here, please?
I think you can use lsp-latex-texlab-executable-argument-list
to pass those arguments via Emacs.
I has added lsp-latex-texlab-executable-argument-list
in Emacs, but no the special logfile generated.
Sorry, I am out now and my computer is not around. I will try again after I get back to see if there is any log file.
Emacs lsp-log:
Found the following clients for /tmp/shm/test.tex: (server-id texlab, priority 1), (server-id digestif, priority -1), (server-id texlab2, priority 2)
The following clients were selected based on priority: (server-id texlab2, priority 2)
Command "texlab" is present on the path.
Command "digestif" is present on the path.
Command "texlab -vvvv --log-file /tmp/texlab.log" is present on the path.
Command "texlab" is present on the path.
Command "digestif" is present on the path.
Command "texlab -vvvv --log-file /tmp/texlab.log" is present on the path.
/tmp/texlab.log
:
DEBUG - < {"jsonrpc":"2.0","method":"initialize","params":{"processId":{},"rootPath":"/tmp/shm","clientInfo":{"name":"emacs","version":"GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)\n of 2022-11-02, unofficial emacs-snapshot build: http://emacs.ganneff.de/, git commit 83f059793af0d7191529582ce674f0af349cd1b7"},"rootUri":"file:///tmp/shm","capabilities":{"workspace":{"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"]},"applyEdit":true,"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":false},"didChangeWatchedFiles":{"dynamicRegistration":true},"workspaceFolders":true,"configuration":true,"codeLens":{"refreshSupport":true},"fileOperations":{"didCreate":false,"willCreate":false,"didRename":true,"willRename":true,"didDelete":false,"willDelete":false}},"textDocument":{"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"synchronization":{"willSave":true,"didSave":true,"willSaveWaitUntil":true},"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":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"resolveSupport":{"properties":["edit","command"]},"dataSupport":true},"completion":{"completionItem":{"snippetSupport":false,"documentationFormat":["markdown","plaintext"],"resolveAdditionalTextEditsSupport":true,"insertReplaceSupport":true,"deprecatedSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits","command"]},"insertTextModeSupport":{"valueSet":[1,2]}},"contextSupport":true,"dynamicRegistration":true},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}},"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":false},"typeHierarchy":{"dynamicRegistration":true},"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":true},"linkedEditingRange":{"dynamicRegistration":true}},"window":{"workDoneProgress":true,"showDocument":{"support":true}}},"initializationOptions":{},"workDoneToken":"1"},"id":5}
I think this problem may not be related to texlab because after changing texlab version (4.3.0, 4.2.2) I still have the same problem.
Could it be related to the version of emacs?
@jouyouyun Thanks for the log file!
"processId":{}
It looks like the params of the initialize
request sent to texlab
does not match the expected format as stated in the specification. Emacs sends "processId":{}
while LSP expects processId: integer | null
.
Why does this happen? How can I fix it?
lsp-mode.el
--> lsp--start-workspace
:
from:
(with-lsp-workspace workspace
(run-hooks 'lsp-before-initialize-hook)
(lsp-request-async
"initialize"
(append
(list :processId nil
change to
(with-lsp-workspace workspace
(run-hooks 'lsp-before-initialize-hook)
(lsp-request-async
"initialize"
(append
(list :processId 0
texlab worked
@jouyouyun Can I get the value of json-null
variable in your Emacs?
lsp-mode
uses json-encode
if json-serialize
, and it depends on json-null
value.
lsp-mode
works well only if json-null
is nil
.
json-null
:
json-null’s value is nil
Value to use when reading JSON ‘null’.
If this has the same value as ‘json-false’, you might not be able to
tell the difference between ‘false’ and ‘null’. Consider let-binding
this around your call to ‘json-read’ instead of ‘setq’ing it.
@ROCKTAKEY
@jouyouyun Umm...
Could you evaluate below and try texlab again?
(defmacro lsp--json-serialize (params)
(if (progn
(require 'json)
(fboundp 'json-serialize))
`(json-serialize ,params
:null-object nil
:false-object :json-false)
`(let ((json-false :json-false)
(json-null nil))
(json-encode ,params))))
Can I get returned value of (fboundp 'json-serialize)
?
@ROCKTAKEY (fboundp 'json-serialize)
value is t
.
@jouyouyun Can I get returned value from sexp below?
(json-serialize (list :processId nil)
:null-object nil
:false-object :json-false)
@ROCKTAKEY return:
"{\"processId\":{}}"
@jouyouyun It seems to be json-serialize
bug (i.e. Emacs inner function's bug). The expression should be return "{\"processId\":null}"
. Work around is use advice like below:
(defun advice-json-serialize (params &rest args)
(unless (plist-get args :null-object)
(let ((json-false (plist-get args :false-object))
(json-null (plist-get args :null-object)))
(json-encode params))))
(advice-add #'json-serialize :before-until #'advice-json-serialize)
This advice forces json-serialize
to use json-encode
if :null-object
is nil
. Note that json-encode
is slower than json-encode
, so lsp-mode
might become slow.
Yes, it worked fine.
Error: invalid type: map, expected u32
Process texlab2 stderr finished DEBUG - <