Closed TechIsCool closed 4 months ago
After a lot of trail and error I determined that the suggested command is returning async vim.cmd [[cabbrev wq execute "Format sync" <bar> wq]]
vim.cmd [[cabbrev wq execute "Format sync" <bar> wq]]
When this command is used it causes issues in a couple places
wq
To determine the async problem I built a quick and dirty mills time r
function epoch_ms() local s, ns = vim.loop.gettimeofday() return s * 1000 + math.floor(ns / 1000) end
Then ran a bunch of commands to understand what happened
:execute "lua print(epoch_ms())" | Format sync | execute "lua print(epoch_ms())" 1712103251379 1712103251383 :execute "lua print(epoch_ms())" | Format | execute "lua print(epoch_ms())" 1712103301293 1712103301295 :execute "lua print(epoch_ms())" | execute "lua print(vim.lsp.buf.format())" | execute "lua print(epoch_ms())" 1712103328159 1712103328221
Currently I have defined the following which does work but it feels very much like I am bypassing lsp-format and just using the built-ins.
lsp-format
vim.api.nvim_create_autocmd("BufWritePre", { callback = function() require("lsp-format").format({ sync = true }) -- vim.lsp.buf.format(). -- bypasses lsp-format end })
Any help would be wonderful as I do like using ZZ and wq to format before exit
ZZ
I need to write proper tests for this...
Obvious bug, should be fixed now.
After a lot of trail and error I determined that the suggested command is returning async
vim.cmd [[cabbrev wq execute "Format sync" <bar> wq]]
When this command is used it causes issues in a couple places
wq
on the last buffer nvim quits before the returned commandTo determine the async problem I built a quick and dirty mills time r
Then ran a bunch of commands to understand what happened
Currently I have defined the following which does work but it feels very much like I am bypassing
lsp-format
and just using the built-ins.Any help would be wonderful as I do like using
ZZ
andwq
to format before exit