lsp

pesterhazy 2024-09-13T07:44:27.689159Z

When I rename a symbol via eglot-rename in emacs, lsp dutifully renames the symbol in the current buffer as well as other files that use this symbol. However, it doesn't write the buffers back to the files! So when I write the current file, my tests fail because the other files haven't been written yet. I end up hunting in my *buffers* for unsaved buffers and save them to complete the refactoring. That doesn't seem efficient. What's the intended workflow here?

Felipe 2024-09-17T13:32:02.163719Z

I use projectile-save-project-buffers, but that seems like a useful hook!

djm 2024-09-17T14:27:36.149349Z

@ericdallo Are you sure you need the lambda? Why not just #'save-buffer? (With use-package, :hook (lsp-after-apply-edits . save-buffer seems to work).

ericdallo 2024-09-17T14:43:44.395549Z

yeah, probably will work, I added that code 5 years ago when my elisp-fu was quite bad ๐Ÿ˜…

djm 2024-09-13T08:51:07.354479Z

You could use save-some-buffers (`C-x s`).

๐Ÿ‘ 2
ericdallo 2024-09-14T14:11:24.905469Z

yes, this is a client responsibility, I use this hook with lsp-mode:

(add-hook 'lsp-after-apply-edits-hook (lambda (&rest _) (save-buffer)))

๐Ÿงก 1