clojure-lsp / lsp4clj

LSP base support for any LSP that is implemented in Clojure
MIT License
51 stars 5 forks source link

Code actions are no longer preferred #32

Open mainej opened 2 years ago

mainej commented 2 years ago

In the migration away from lsp4j and the associated refactoring of the coercer, I missed something. The coercer checks code actions for a key :preferred, which is put in the json as "preferred". This key used to be translated into "isPreferred" which is what the LSP spec defines.

This explains why clients no longer sort preferred code actions at the top.

Rather than fix the issue here in lsp4clj, I'd rather fix the problem in the language servers. I don't like using the coercer to create a slightly different format than the LSP spec. We do that some, but I don't want to do it any more. So, I propose that we find the usages of :preferred in each language server, and convert them to :is-preferred. When that's done, we can change lsp4clj to check for that key.

I have access to clojure-lsp and the language server that my company works on, so I can take care of this in both. I'm opening this issue so that anyone else who uses lsp4clj can make the same changes on their end.

mainej commented 2 years ago

I've applied this fix locally and unfortunately Emacs still doesn't sort the Add require commands first, so there may be something else wrong on the lsp-mode end.

ericdallo commented 2 years ago

It seems it's only checked on the modeling to show the icon differently @mainej: https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-modeline.el#L113 We should make lsp-code-actions.el consider it too If I'm not mistaken c/c @yyoncho