From 3cf38d9c957e95c397b66f91967758b31be4abe6 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Sat, 15 Oct 2022 15:43:56 -0400 Subject: [PATCH] vim.deprecate should not be used until neovim 0.9.0 (#40) vim.deprecate is not available yet as of neovim 0.8.0. The use of it (introduced in #35) will break stable versions of neovim. --- lua/cmp_nvim_lsp/init.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lua/cmp_nvim_lsp/init.lua b/lua/cmp_nvim_lsp/init.lua index 0ab072e..c207a2c 100644 --- a/lua/cmp_nvim_lsp/init.lua +++ b/lua/cmp_nvim_lsp/init.lua @@ -20,6 +20,20 @@ local if_nil = function(val, default) return val end +-- Backported from vim.deprecate (0.9.0+) +local function deprecate(name, alternative, version, plugin, backtrace) + local message = name .. ' is deprecated' + plugin = plugin or 'Nvim' + message = alternative and (message .. ', use ' .. alternative .. ' instead.') or message + message = message + .. ' See :h deprecated\nThis function will be removed in ' + .. plugin + .. ' version ' + .. version + if vim.notify_once(message, vim.log.levels.WARN) and backtrace ~= false then + vim.notify(debug.traceback('', 2):sub(2), vim.log.levels.WARN) + end +end M.default_capabilities = function(override) override = override or {} @@ -50,7 +64,8 @@ end ---Backwards compatibility M.update_capabilities = function(capabilities, override) - vim.deprecate('cmp_nvim_lsp.update_capabilities', 'cmp_nvim_lsp.default_capabilities', '1.0.0', 'cmp-nvim-lsp') + local _deprecate = vim.deprecate or deprecate + _deprecate('cmp_nvim_lsp.update_capabilities', 'cmp_nvim_lsp.default_capabilities', '1.0.0', 'cmp-nvim-lsp') return M.default_capabilities(override) end