fix deprecation warning for client.is_stopped() - #133
Conversation
There was a problem hiding this comment.
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()toself.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 |
There was a problem hiding this comment.
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".
| if self.client:is_stopped() or not self.client.name == "copilot" then | |
| if self.client:is_stopped() or self.client.name ~= "copilot" then |
|
@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() |
|
Duplicate of #130 ... |
- ~/.markdownlintrc を追加(MD013 line-length 無効、MD024 は siblings_only)。 日本語のMarkdownはPrettierで整形しており80桁制限は意味がないため - copilot-cmp が client.is_stopped() をドット呼びしており Nvim 0.11+ で 起動毎に deprecated 警告が出るため、is_available をメソッド呼びで差し替え (upstream zbirenbaum/copilot-cmp#133 未マージ) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
No description provided.