Synchronous formatting
- Dominant language
- Vim Script
- Stars
- 220
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
I've found myself being caught out by the asynchronous nature of the formatting. I sometimes save and then continue editing and the formatting job will come back and overwrite my edits. It is a little confusing and I find myself wishing the editor would just wait until the formatting was done. I realise this might not be a common request but it seems to suit me well.
I've ended up adding the following minor change directly to my vim-mix-format plugin folder but I thought I'd share it here in case it is of use to others:
```diff
diff --git a/ftplugin/elixir.vim b/ftplugin/elixir.vim
index 8a6ac57..4801727 100644
--- a/ftplugin/elixir.vim
+++ b/ftplugin/elixir.vim
@@ -226,6 +226,7 @@ function! s:mix_format(diffmode) abort
\ 'on_exit': function('s:on_exit'),
\ 'detach': !has('nvim-0.3.6'),
\ }))
+ call jobwait([s:id], -1)
else
silent! call job_stop(s:id)
let s:id = job_start(cmd, extend({
```
Thank you for the project!
Edit: I should note this is explicitly for the nvim branch of the logic.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in ftplugin/elixir.vim, especially s:mix_format in the Neovim branch of the logic. Review how the formatting job is started and verify the requested synchronous behavior there. Done means saving waits for formatting to finish so later edits are not overwritten.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir, vim
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100