1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 19:00:06 +08:00
SpaceVim/bundle/plenary.nvim/lua/plenary/lsp/override.lua

31 lines
709 B
Lua
Raw Normal View History

2022-05-16 22:20:10 +08:00
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