diff options
| author | Dave Honneffer <pearofducks@gmail.com> | 2025-06-02 12:11:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-02 03:11:20 -0700 |
| commit | 3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95 (patch) | |
| tree | fb072e3afa5e6ead9fbcd78b5f5c55c4c6983ddf | |
| parent | ci: allows "workspace/executeCommand" in eslint config (diff) | |
| download | nvim-lspconfig-3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95.tar nvim-lspconfig-3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95.tar.gz nvim-lspconfig-3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95.tar.bz2 nvim-lspconfig-3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95.tar.lz nvim-lspconfig-3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95.tar.xz nvim-lspconfig-3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95.tar.zst nvim-lspconfig-3fe2f7f63fe2ab9733252d1e246dd4c7bf9e6b95.zip | |
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().
| -rw-r--r-- | lsp/eslint.lua | 9 |
1 files 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 |
