Skip to content

[audit] replace deprecated vim.lsp.stop_client() with client:stop()#144

Merged
stanfish06 merged 2 commits into
masterfrom
audit/lsp-stop-client
Jun 4, 2026
Merged

[audit] replace deprecated vim.lsp.stop_client() with client:stop()#144
stanfish06 merged 2 commits into
masterfrom
audit/lsp-stop-client

Conversation

@stanfish06
Copy link
Copy Markdown
Owner

What

lua/config/plugin_config.lua — the LspToggle command — calls the deprecated vim.lsp.stop_client(client.id). The code already has a -- TODO comment flagging this.

Where

lua/config/plugin_config.lua lines 121–124:

for _, client in ipairs(vim.lsp.get_clients({ bufnr = 0, name = name })) do
    -- TODO: replace with Client:stop() after current api deprecate
    vim.lsp.stop_client(client.id)
    return
end

Why it matters

vim.lsp.stop_client() was deprecated in Neovim 0.12 in favour of calling stop() directly on the client object. Keeping the old form will emit deprecation warnings on every :LspToggle invocation once Neovim completes the transition.

Change

 for _, client in ipairs(vim.lsp.get_clients({ bufnr = 0, name = name })) do
-    -- TODO: replace with Client:stop() after current api deprecate
-    vim.lsp.stop_client(client.id)
+    client:stop()
     return
 end

Drops the resolved TODO comment as well.


Generated by Claude Code

vim.lsp.stop_client(id) is deprecated in Neovim 0.12; the new API is
the client:stop() method directly on the client object. Removes the
TODO comment that tracked this work.

https://claude.ai/code/session_014eiycWG5KeoanDfLHDC825
@stanfish06
Copy link
Copy Markdown
Owner Author

make it backward compatible i have v11 nvim on some of my machines and v12 on others, so make both api available @claude

@claude
Copy link
Copy Markdown

claude Bot commented Jun 4, 2026

Claude finished @stanfish06's task in 55s —— View job


Backward compatibility for LspToggle

  • Read file and gather context
  • Add version-gated fallback (vim.fn.has('nvim-0.12'))
  • Commit and push

Done. The LspToggle command now branches on the Neovim version — same pattern already used on line 115 of the same file:

for _, client in ipairs(vim.lsp.get_clients({ bufnr = 0, name = name })) do
    if vim.fn.has('nvim-0.12') == 1 then
        client:stop()
    else
        vim.lsp.stop_client(client.id)
    end
    return
end
  • Neovim 0.12+: calls client:stop() (new API, no deprecation warning)
  • Neovim 0.11 and below: calls vim.lsp.stop_client(client.id) (original API)
    |

Use vim.fn.has('nvim-0.12') to branch between client:stop() (0.12+)
and vim.lsp.stop_client(client.id) (0.11 and below).

Co-authored-by: Zhiyuan <stanfish06@users.noreply.github.com>
@stanfish06 stanfish06 merged commit 2c9c8ed into master Jun 4, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants