Fix formatting via eslint on save in neovim

When I saved files in my eslint-formatted projects I was wondering about
slight differences between the results of running `eslint --fix` vs. the
autoamtic formatting when I save a file in neovim.

As it turned out I ran the wrong command indeed. This changes fixes that
by simply calling the correct command on save. Note that this looks
"bigger" but it's actually a copy of the built-in `LspEslintFixAll` of
neovim.

Reference: 1a6d692067/doc/configs.md (eslint)
Reference: 89fd0361b3/lsp/eslint.lua (L92-L104)
This commit is contained in:
2026-03-27 00:52:12 +01:00
parent 1445b6d519
commit 4a7e003ea1

View File

@@ -77,9 +77,15 @@ return {
group = augroup, group = augroup,
buffer = bufnr, buffer = bufnr,
callback = function() callback = function()
if vim.bo.filetype == "typescript" then client:request_sync("workspace/executeCommand", {
vim.lsp.buf.format() command = "eslint.applyAllFixes",
end arguments = {
{
uri = vim.uri_from_bufnr(bufnr),
version = vim.lsp.util.buf_versions[bufnr],
}
}
})
end, end,
}) })
end, end,