-
Notifications
You must be signed in to change notification settings - Fork 9
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
Allow to report syntax errors using LSP error and/or "window/showMessage" notification #2
Conversation
window/showMessage Also, fixed the fake completion item: needs isIncomplete for Emacs to not raise Lisp errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the merge request. I added a few comments. Other than that it looks good.
to make it first -- to have best looking docs about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, looks good. Is this ready to be merged?
Yes, all done, including last docs (README) improvements :) |
Looking for a perfect way to report Pascal syntax errors (easily caused by missing Pascal units), this PR gives users 2 new ways to see error:
window/showMessage
. This is supported by VS Code nicely, by Emacs too (but poorly). It is by defaulttrue
(as it seems to do no harm, in the worst case clients that don't support it will just ignore it).by returning LSP error instead of a "fake completion item". The fake completion item works poorly in Emacs, the LSP error is visible nicer. It is by default
false
to not break previous behavior. Emacs users may likely prefer to turn this on.Both these can be controlled by new
syntaxErrorCausesLspError
,syntaxErrorCausesShowMessage
flags that clients can pass as LSP initialization options.The options are documented in README.md.
See michaliskambi/elisp#1 for various details about Emacs.
Codewise, I have introduced 2 new classes:
TRpcNotification
andTRpcMessageToClient
(common ancestor forTRpcNotification
andTRpcResponse
).window/showMessage
is a "notification" in JSON-RPC sense (see https://www.jsonrpc.org/specification#notification ) and it seemed cleanest to express it as a new class (rather then overusingTRpcResponse
). Following JSON-RPC ver 2 spec, "notifications" differ from "responses" in that:Notifications do not pass any id. (Trying to pass
id
withwindow/showMessage
was leading to weirdest errors from both VS Code and Emacs :) ).The other side (LSP client in this case) is not supposed to reply. This is nice, it means we don't have to handle anything extra (no need to dispatch some LSP client answer) to support
window/showMessage
.BTW 2 fixes:
fake completion item contains
isIncomplete
, as required by LSP spec. Without it, Emacs throws scary Lisp error.I noticed that
TRpcPeer.Receive
has accidentallyResult.Reader := Reader
assignment 2 times.