-
-
Notifications
You must be signed in to change notification settings - Fork 866
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
Native json support #691
Native json support #691
Conversation
5517198
to
005c2db
Compare
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.
#690 is indeed fixed with these changes.
lsp-mode.el
Outdated
(end (if (stringp selected-param-label) | ||
(+ start (length selected-param-label)) | ||
(seq-elt selected-param-label (1- (seq-length selected-param-label)))))) | ||
(last (append selected-param-label nil))))) |
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.
last
returns a cons cell. What's wrong with elt
?
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.
it should be cl-second
lsp-mode.el
Outdated
(json-parse-string str | ||
:object-type 'hash-table | ||
:null-object nil | ||
:false-object :json-false))) |
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.
Switching from nil
to :json-false
leads to conditionals with json values to suddenly succeed. For example, (gethash "resolveProvider" ...)
in lsp--sort-completions
now returns a truth-value (:json-false
) for ccls, leading to errors during completion. There may be other similar instances.
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 spotting this. We had to evaluate whether to keep the current(incorrect) behaviour of fix all places which do if over a lsp result.
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.
I'd vote for :false
/:null
, as in the defaults of the emacs27 json library, or even nil
instead of :false
, that way you preserve truth value.
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.
We already use :json-false
for false when doing serialization.
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.
But that doesn't affect us much as we don't reuse the objects we create during serialization. On the other hand, using a non-nil
value while working with values we get from the language server would inadvertently result in a lot of broken code. Every if
and conditional construct would have to be rewritten to check for the new "false", which would just result in inorganic and unidiomatic lisp code, prone to breaking.
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.
@vibhavp there are few places we reuse the object, e. g. - lenses, diagnostics, code actions.
which would just result in inorganic and unidiomatic lisp code, prone to breaking.
I agree that it will be ugly, error-prone, difficult to migrate and support. And I agree with you that it is better to keep it as it is at least for now...
A link to a code that deals with that issue - I am converting the nil to :json-false
to make it work.
https://github.com/emacs-lsp/lsp-java/blob/master/lsp-java-boot.el#L68
By the way, is |
Yes, we might not add it at all.
IMO using seq will make the code more robust. I am not sure whether there is vector-filter or similar functions or we should resort to smt like cl-loop. Edit: but it is still an option that we should evaluate. |
4419290
to
37c4770
Compare
Fixes #210
Fixes #395
** lsp-use-native-json
** lsp-json-use-lists - could be used to switch to the list serialization in case
there is a problem with the vector serialization.