From 53a318048f2a294b7054d04ec2c8b9b32e0a8b99 Mon Sep 17 00:00:00 2001 From: Abao Zhang Date: Wed, 6 Aug 2025 00:30:56 +0800 Subject: [PATCH 1/2] feat: add option to suppress limit reched popup --- README.md | 1 + lua/copilot/client/handlers.lua | 14 ++++++++++++++ lua/copilot/config/init.lua | 1 + 3 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 0f9ed9e4..49c1969f 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ require('copilot').setup({ copilot_node_command = 'node', -- Node.js version must be > 20 workspace_folders = {}, copilot_model = "", + disable_limit_reached_message = false, -- Set to `true` to suppress completion limit reached popup root_dir = function() return vim.fs.dirname(vim.fs.find(".git", { upward = true })[1]) end, diff --git a/lua/copilot/client/handlers.lua b/lua/copilot/client/handlers.lua index b8b1c65f..0007a1af 100644 --- a/lua/copilot/client/handlers.lua +++ b/lua/copilot/client/handlers.lua @@ -13,6 +13,7 @@ function M.get_handlers() PanelSolutionsDone = panel.handlers.handlers.PanelSolutionsDone, statusNotification = status.handlers.statusNotification, ["window/showDocument"] = util.show_document, + } -- optional handlers @@ -35,6 +36,19 @@ function M.get_handlers() }) end + if config.disable_limit_reached_message then + handlers['window/showMessageRequest'] = (function(overridden) + return function(err, params, ctx) + if params.message:match([[^You've reached.*limit.*Upgrade.*$]]) then + -- ignore + logger.trace("API limited:", params.message) + return vim.NIL + end + return overridden(err, params, ctx) + end + end)(vim.lsp.handlers['window/showMessageRequest']) + end + return handlers end diff --git a/lua/copilot/config/init.lua b/lua/copilot/config/init.lua index 9e864205..35ae75b7 100644 --- a/lua/copilot/config/init.lua +++ b/lua/copilot/config/init.lua @@ -30,6 +30,7 @@ local M = { server_opts_overrides = {}, copilot_model = nil, copilot_node_command = "node", + disable_limit_reached_message = false, } ---@param user_configs CopilotConfig From cad58d42f14a257717f55fb0c1054a50a7b7446e Mon Sep 17 00:00:00 2001 From: Antoine Gaudreau Simard Date: Thu, 14 Aug 2025 20:57:53 -0400 Subject: [PATCH 2/2] add class info --- lua/copilot/client/handlers.lua | 11 +++++------ lua/copilot/config/init.lua | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/copilot/client/handlers.lua b/lua/copilot/client/handlers.lua index 0007a1af..65c42d3e 100644 --- a/lua/copilot/client/handlers.lua +++ b/lua/copilot/client/handlers.lua @@ -13,7 +13,6 @@ function M.get_handlers() PanelSolutionsDone = panel.handlers.handlers.PanelSolutionsDone, statusNotification = status.handlers.statusNotification, ["window/showDocument"] = util.show_document, - } -- optional handlers @@ -37,16 +36,16 @@ function M.get_handlers() end if config.disable_limit_reached_message then - handlers['window/showMessageRequest'] = (function(overridden) + handlers["window/showMessageRequest"] = (function(overridden) return function(err, params, ctx) if params.message:match([[^You've reached.*limit.*Upgrade.*$]]) then - -- ignore - logger.trace("API limited:", params.message) - return vim.NIL + -- ignore + logger.trace("API limited:", params.message) + return vim.NIL end return overridden(err, params, ctx) end - end)(vim.lsp.handlers['window/showMessageRequest']) + end)(vim.lsp.handlers["window/showMessageRequest"]) end return handlers diff --git a/lua/copilot/config/init.lua b/lua/copilot/config/init.lua index 35ae75b7..a15ecf61 100644 --- a/lua/copilot/config/init.lua +++ b/lua/copilot/config/init.lua @@ -13,6 +13,7 @@ local logger = require("copilot.logger") ---@field root_dir RootDirFuncOrString Root directory for the project, defaults to the nearest .git directory ---@field should_attach ShouldAttachFunc Function to determine if Copilot should attach to the buffer ---@field copilot_node_command string Path to the Node.js executable, defaults to "node" +---@field disable_limit_reached_message boolean Disable the limit reached message, defaults to false local initialized = false