Skip to content

fix deprecation warning for client.is_stopped() - #133

Open
fstp wants to merge 1 commit into
zbirenbaum:masterfrom
fstp:master
Open

fix deprecation warning for client.is_stopped()#133
fstp wants to merge 1 commit into
zbirenbaum:masterfrom
fstp:master

Conversation

@fstp

@fstp fstp commented Feb 24, 2026

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings February 24, 2026 10:40
@fstp fstp closed this Feb 24, 2026
@fstp fstp reopened this Feb 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a deprecation warning by converting the is_stopped() method call from dot notation to colon notation in Lua. The change ensures that the method is called with the proper syntax that automatically passes self as the first argument, which is the correct Lua convention for method calls.

Changes:

  • Updated self.client.is_stopped() to self.client:is_stopped() to use proper Lua method call syntax

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

source.is_available = function(self)
-- client is stopped.
if self.client.is_stopped() or not self.client.name == "copilot" then
if self.client:is_stopped() or not self.client.name == "copilot" then

Copilot AI Feb 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The operator precedence in this condition is incorrect. The expression not self.client.name == "copilot" is evaluated as (not self.client.name) == "copilot", which will always be false. It should be self.client.name ~= "copilot" or not (self.client.name == "copilot") to properly check if the client name is not "copilot".

Suggested change
if self.client:is_stopped() or not self.client.name == "copilot" then
if self.client:is_stopped() or self.client.name ~= "copilot" then

Copilot uses AI. Check for mistakes.
@cschindlbeck

Copy link
Copy Markdown

@zbirenbaum Any chance this is going to be merged? If not, what is the alternative to this plugin?

@cwagrant

cwagrant commented May 1, 2026

Copy link
Copy Markdown

@zbirenbaum Any chance this is going to be merged? If not, what is the alternative to this plugin?

In the event he doesn't merge it you can monkeypatch the command before requiring the plugin.

Here's what I did

local monkeypatch = require("copilot_cmp.source")
monkeypatch.is_available = function(self)
  -- client is stopped.
  if self.client:is_stopped() or not self.client.name == "copilot" then
    return false
  end

  local get_source_client = function()
    if vim.lsp.get_clients == nil then
      return vim.lsp.get_active_clients({
        bufnr = vim.api.nvim_get_current_buf(),
        id = self.client.id,
      })
    end
    return vim.lsp.get_clients({
      bufnr = vim.api.nvim_get_current_buf(),
      id = self.client.id,
    })
  end

  return next(get_source_client()) ~= nil
end

require("copilot_cmp").setup()

@tjex

tjex commented Jun 15, 2026

Copy link
Copy Markdown

Duplicate of #130 ...

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.

5 participants