forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlers.lua
More file actions
54 lines (46 loc) · 1.54 KB
/
handlers.lua
File metadata and controls
54 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
local config = require("copilot.config")
local util = require("copilot.util")
local logger = require("copilot.logger")
local status = require("copilot.status")
local panel = require("copilot.panel")
local M = {}
function M.get_handlers()
local handlers = {
-- TODO: I don't like the handlers.handlers
PanelSolution = panel.handlers.handlers.PanelSolution,
PanelSolutionsDone = panel.handlers.handlers.PanelSolutionsDone,
statusNotification = status.handlers.statusNotification,
["window/showDocument"] = util.show_document,
}
-- optional handlers
local logger_conf = config.logger
if logger_conf.trace_lsp ~= "off" then
handlers = vim.tbl_extend("force", handlers, {
["$/logTrace"] = logger.handle_lsp_trace,
})
end
if logger_conf.trace_lsp_progress then
handlers = vim.tbl_extend("force", handlers, {
["$/progress"] = logger.handle_lsp_progress,
})
end
if logger_conf.log_lsp_messages then
handlers = vim.tbl_extend("force", handlers, {
["window/logMessage"] = logger.handle_log_lsp_messages,
})
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
return M