Improving on the biome fixAll + organizeImports on-save solution for Neovim — fixing remaining race conditions. #9307
ridwanyinus
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I came across discussion #7931 by @HendrikPetertje which pointed me in the right direction, but I ran into a few issues with the approach that I had to dig into further. Sharing my fixes here in case others hit the same wall.
What still didn't work from the original post
Even after switching to
buf_request_sync, I was still seeing:position_encodingwarning spam in the console when multiple LSPs were attachedThe problem
Using
vim.lsp.buf.code_action { apply = true }insideBufWritePrelooks synchronous but isn't. The file write completes before the code actions finish, causing:The solution
Use
vim.lsp.buf_request_syncwhich actually blocks until the LSP responds, then apply edits manually before the write happens:A few things worth noting
client.offset_encodingexplicitly to bothmake_range_paramsandapply_workspace_editto avoid theposition_encodingwarning when multiple LSPs (e.g.ts_ls) are attached to the same bufferclient:exec_cmd()is the Neovim 0.10+ idiomatic way —vim.lsp.buf.execute_commandis deprecatedts_lsso Biome owns it: setclient.server_capabilities.documentFormattingProvider = falsein yourts_lson_initHope this helps someone who already tried #7931 and is still stuck!
Beta Was this translation helpful? Give feedback.
All reactions