From 3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95 Mon Sep 17 00:00:00 2001 From: Dave Honneffer Date: Mon, 2 Jun 2025 12:11:20 +0200 Subject: 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(). --- lsp/eslint.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lsp/eslint.lua b/lsp/eslint.lua index 104b8d4a..61c00e0a 100644 --- a/lsp/eslint.lua +++ b/lsp/eslint.lua @@ -48,12 +48,9 @@ return { 'astro', }, workspace_required = true, - on_attach = function(client) + on_attach = function(client, bufnr) vim.api.nvim_buf_create_user_command(0, 'LspEslintFixAll', function() - local bufnr = vim.api.nvim_get_current_buf() - - client:exec_cmd({ - title = 'Fix all Eslint errors for current buffer', + client:request_sync('workspace/executeCommand', { command = 'eslint.applyAllFixes', arguments = { { @@ -61,7 +58,7 @@ return { version = lsp.util.buf_versions[bufnr], }, }, - }, { bufnr = bufnr }) + }, nil, bufnr) end, {}) end, -- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats -- cgit v1.2.3-70-g09d2