mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 16:10:05 +08:00
31 lines
709 B
Lua
Vendored
31 lines
709 B
Lua
Vendored
local vim = vim
|
|
|
|
local M = {}
|
|
|
|
M._original_functions = {}
|
|
|
|
--- Override an lsp method default callback
|
|
--- @param method string
|
|
--- @param new_function function
|
|
function M.override(method, new_function)
|
|
if M._original_functions[method] == nil then
|
|
M._original_functions[method] = vim.lsp.callbacks[method]
|
|
end
|
|
|
|
vim.lsp.callbacks[method] = new_function
|
|
end
|
|
|
|
--- Get the original method callback
|
|
--- useful if you only want to override in some circumstances
|
|
---
|
|
--- @param method string
|
|
function M.get_original_function(method)
|
|
if M._original_functions[method] == nil then
|
|
M._original_functions[method] = vim.lsp.callbacks[method]
|
|
end
|
|
|
|
return M._original_functions[method]
|
|
end
|
|
|
|
return M
|