Skip to content

Commit 3fe2f7f

Browse files
authored
fix(eslint): LspEslintFixAll is async, writes file without applied fixes #3876
Problem: :LspEslintFixAll command is no longer synchronous with the new `vim.lsp.config` config, so the file is written without the applied fixes. Solution: Use request_sync('workspace/executeCommand') instead of client:exec_cmd().
1 parent 8475898 commit 3fe2f7f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lsp/eslint.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,17 @@ return {
4848
'astro',
4949
},
5050
workspace_required = true,
51-
on_attach = function(client)
51+
on_attach = function(client, bufnr)
5252
vim.api.nvim_buf_create_user_command(0, 'LspEslintFixAll', function()
53-
local bufnr = vim.api.nvim_get_current_buf()
54-
55-
client:exec_cmd({
56-
title = 'Fix all Eslint errors for current buffer',
53+
client:request_sync('workspace/executeCommand', {
5754
command = 'eslint.applyAllFixes',
5855
arguments = {
5956
{
6057
uri = vim.uri_from_bufnr(bufnr),
6158
version = lsp.util.buf_versions[bufnr],
6259
},
6360
},
64-
}, { bufnr = bufnr })
61+
}, nil, bufnr)
6562
end, {})
6663
end,
6764
-- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats

0 commit comments

Comments
 (0)