Skip to content

Commit 4869bff

Browse files
feat: add option to suppress limit reched popup (#528)
Fixes #349 Co-authored-by: Antoine Gaudreau Simard <[email protected]>
1 parent f122741 commit 4869bff

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ require('copilot').setup({
159159
copilot_node_command = 'node', -- Node.js version must be > 20
160160
workspace_folders = {},
161161
copilot_model = "",
162+
disable_limit_reached_message = false, -- Set to `true` to suppress completion limit reached popup
162163
root_dir = function()
163164
return vim.fs.dirname(vim.fs.find(".git", { upward = true })[1])
164165
end,

lua/copilot/client/handlers.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ function M.get_handlers()
3535
})
3636
end
3737

38+
if config.disable_limit_reached_message then
39+
handlers["window/showMessageRequest"] = (function(overridden)
40+
return function(err, params, ctx)
41+
if params.message:match([[^You've reached.*limit.*Upgrade.*$]]) then
42+
-- ignore
43+
logger.trace("API limited:", params.message)
44+
return vim.NIL
45+
end
46+
return overridden(err, params, ctx)
47+
end
48+
end)(vim.lsp.handlers["window/showMessageRequest"])
49+
end
50+
3851
return handlers
3952
end
4053

lua/copilot/config/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local logger = require("copilot.logger")
1313
---@field root_dir RootDirFuncOrString Root directory for the project, defaults to the nearest .git directory
1414
---@field should_attach ShouldAttachFunc Function to determine if Copilot should attach to the buffer
1515
---@field copilot_node_command string Path to the Node.js executable, defaults to "node"
16+
---@field disable_limit_reached_message boolean Disable the limit reached message, defaults to false
1617

1718
local initialized = false
1819

@@ -30,6 +31,7 @@ local M = {
3031
server_opts_overrides = {},
3132
copilot_model = nil,
3233
copilot_node_command = "node",
34+
disable_limit_reached_message = false,
3335
}
3436

3537
---@param user_configs CopilotConfig

0 commit comments

Comments
 (0)