Replies: 3 comments 5 replies
-
OK. There's a lot missing here. If this is a regression, I presume you can pinpoint an eglot version where this worked. And the "this" must be impeccably specified: use an Pay close attention to step 6. |
Beta Was this translation helpful? Give feedback.
-
@joaotavora Thanks for the heads up. I've figured out, it has to do with error handling of Now I worked around this with explicitly ignoring errors like (add-hook 'before-save-hook
(lambda ()
(ignore-errors (eglot-code-action-organize-imports 1))
(eglot-format-buffer))
-10 t) |
Beta Was this translation helpful? Give feedback.
-
In this issue #1409, @stapelberg is requesting something fairly related, which is the ability to more easily add this import organization to the save hook (and other hooks). I'm not fully onboard with Michael's idea over there, but I see that this code action is very important to Go people, and I'm receptive to the idea of making an argless, non-interactive call to code action functions like And of course, we should make it so that it swallow the error if the code action isn't available is this issue. If someone wants to work on this, this must all be done in (defmacro eglot--code-action (name kind)
"Define NAME to execute KIND code action."
`(defun ,name (beg &optional end)
,(format "Execute `%s' code actions between BEG and END." kind)
(interactive (eglot--code-action-bounds))
(eglot-code-actions beg end ,kind t))) ;; <--- this last t assumes the function is always called interactive, not true.
(eglot--code-action eglot-code-action-organize-imports "source.organizeImports")
(eglot--code-action eglot-code-action-extract "refactor.extract")
(eglot--code-action eglot-code-action-inline "refactor.inline")
(eglot--code-action eglot-code-action-rewrite "refactor.rewrite")
(eglot--code-action eglot-code-action-quickfix "quickfix") |
Beta Was this translation helpful? Give feedback.
-
Used to call
eglot-code-action-organize-imports
for my Go(lang)gopls
sessions in a hook at buffer save. Now it fails withIt did worked before, like invoking
gopls imports
on file manually.I've tried revert
gopls
to older version 0.16.0 but getting the same error.It looks like a regression in
eglot
or even emacs to me.Package eglot is built-in.
Status: Built-In.
Version: 1.12.29
Beta Was this translation helpful? Give feedback.
All reactions