Stream: t-compiler/wg-rls-2.0

Topic: Emacs LSP - problem with layout


apiraino (May 20 2020 at 12:36, on Zulip):

Hi, I have been afflicted by some strange layout problem with Emacs and LSP. I cant explain with words, so I'll post two animation files. I'm am using Sway under Wayland (in case it is relevant)

apiraino (May 20 2020 at 12:37, on Zulip):

Basically when LSP is trying to open the rustfmt error log window, the Emacs buffer is swapped under my nose and the rustfmt buffer log is put in foreground

apiraino (May 20 2020 at 12:37, on Zulip):

Example where is does not happen

apiraino (May 20 2020 at 12:37, on Zulip):

recording1.webm

apiraino (May 20 2020 at 12:38, on Zulip):

(The source buffer is not completely covered and on the right we see the rustfmt buffer)

apiraino (May 20 2020 at 12:38, on Zulip):

recording2.webm

apiraino (May 20 2020 at 12:39, on Zulip):

(Here I shrink slightly the CLI window and the rustfmt emacs buffer with the source code is put in background, I have to switch back to fix the code)

apiraino (May 20 2020 at 12:40, on Zulip):

I can't even search on github what I can do to avoid this behaviour, I'd like to disable all the accessory buffers that popup and are distracting

apiraino (May 20 2020 at 12:40, on Zulip):

Sorry for being vague :sweat_smile: and thanks for any suggestion

Florian Diebold (May 20 2020 at 12:59, on Zulip):

I don't think that error buffer comes from LSP, rather from the separate rustfmt integration

Florian Diebold (May 20 2020 at 12:59, on Zulip):

LSP can format the file for you, but it won't open an error buffer if it fails

Florian Diebold (May 20 2020 at 13:00, on Zulip):

so I would recommend using the LSP formatter instead (that's lsp-format-buffer)

apiraino (May 20 2020 at 13:03, on Zulip):

ahh thanks, I will definitively try that and locate the offending package

apiraino (May 22 2020 at 15:42, on Zulip):

@Florian Diebold ok fixed that issue and got rid of some redundant configs. Now, I have another question about rustfmt. Does lsp-rust currently have a rustfmt-on-save hook? I think I only see a rust-build-on-save but nothing else configurable on save

Florian Diebold (May 22 2020 at 15:45, on Zulip):

I don't think it has built-in support, but I guess something like

(add-hook 'before-save-hook (lambda () (when (eq 'rust-mode major-mode)
                                           (lsp-format-buffer))))

should work

apiraino (May 22 2020 at 15:52, on Zulip):

nice, I will try it - thanks!

apiraino (May 23 2020 at 09:42, on Zulip):

works great! I would like to submit for evaluation a small PR to the documentation, if you don't mind. I think that snippet is of great value :-)

Last update: Sep 30 2020 at 16:30UTC