mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: use vim.deprecate on all deprecated functions
This commit is contained in:
parent
0f22ea400c
commit
5f9d4d8afe
12
MAINTAIN.md
12
MAINTAIN.md
@ -75,11 +75,15 @@ When a (non-experimental) feature is slated to be removed it should:
|
|||||||
- Use of the deprecated feature will still work.
|
- Use of the deprecated feature will still work.
|
||||||
- This means deprecating via documentation and annotation (`@deprecated`) only.
|
- This means deprecating via documentation and annotation (`@deprecated`) only.
|
||||||
- Include a note in `news.txt` under `DEPRECATIONS`.
|
- Include a note in `news.txt` under `DEPRECATIONS`.
|
||||||
|
- For Lua features, use `vim.deprecate()`. The specified version is the
|
||||||
|
current minor version + 2. For example, if the current version is
|
||||||
|
`v0.10.0-dev-1957+gd676746c33` then use `0.12`.
|
||||||
|
- For Vimscript features, use `v:lua.vim.deprecate()`. Use the same version
|
||||||
|
as described for Lua features.
|
||||||
2. Be _hard_ deprecated in a following a release in which it was soft deprecated.
|
2. Be _hard_ deprecated in a following a release in which it was soft deprecated.
|
||||||
- Use of the deprecated feature will still work but should issue a warning
|
- Use of the deprecated feature will still work but should issue a warning.
|
||||||
(typically via `vim.deprecate()` for Lua features).
|
- Features implemented in C will need bespoke implementations to communicate
|
||||||
- Features implemented in Vimscript or in C will need bespoke implementations
|
to users that the feature is deprecated.
|
||||||
to communicate to users that the feature is deprecated
|
|
||||||
3. Be removed in a release following the release in which it was hard deprecated
|
3. Be removed in a release following the release in which it was hard deprecated
|
||||||
- Usually this will be the next release, but it may be a later release if a
|
- Usually this will be the next release, but it may be a later release if a
|
||||||
longer deprecation cycle is desired
|
longer deprecation cycle is desired
|
||||||
|
@ -888,7 +888,7 @@ end
|
|||||||
|
|
||||||
---@private
|
---@private
|
||||||
function vim.pretty_print(...)
|
function vim.pretty_print(...)
|
||||||
vim.deprecate('vim.pretty_print', 'vim.print', '0.10')
|
vim.deprecate('vim.pretty_print()', 'vim.print()', '0.10')
|
||||||
return vim.print(...)
|
return vim.print(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -891,15 +891,13 @@ M.handlers.signs = {
|
|||||||
local sign = vim.fn.sign_getdefined(name)[1]
|
local sign = vim.fn.sign_getdefined(name)[1]
|
||||||
if sign then
|
if sign then
|
||||||
local severity = M.severity[v:upper()]
|
local severity = M.severity[v:upper()]
|
||||||
if vim.fn.has('nvim-0.11') == 1 then
|
vim.deprecate(
|
||||||
vim.deprecate(
|
'Defining diagnostic signs with :sign-define or sign_define()',
|
||||||
'Defining diagnostic signs with :sign-define or sign_define()',
|
'vim.diagnostic.config()',
|
||||||
'vim.diagnostic.config()',
|
'0.12',
|
||||||
'0.12',
|
nil,
|
||||||
nil,
|
false
|
||||||
false
|
)
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
if not opts.signs.text then
|
if not opts.signs.text then
|
||||||
opts.signs.text = {}
|
opts.signs.text = {}
|
||||||
|
@ -1740,7 +1740,7 @@ end
|
|||||||
---@private
|
---@private
|
||||||
---@deprecated
|
---@deprecated
|
||||||
function lsp.get_active_clients(filter)
|
function lsp.get_active_clients(filter)
|
||||||
-- TODO: add vim.deprecate call after 0.10 is out for removal in 0.12
|
vim.deprecate('vim.lsp.get_active_clients()', 'vim.lsp.get_clients()', '0.12')
|
||||||
return lsp.get_clients(filter)
|
return lsp.get_clients(filter)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2051,6 +2051,7 @@ end
|
|||||||
---@return table result is table of (client_id, client) pairs
|
---@return table result is table of (client_id, client) pairs
|
||||||
---@deprecated Use |vim.lsp.get_clients()| instead.
|
---@deprecated Use |vim.lsp.get_clients()| instead.
|
||||||
function lsp.buf_get_clients(bufnr)
|
function lsp.buf_get_clients(bufnr)
|
||||||
|
vim.deprecate('vim.lsp.buf_get_clients()', 'vim.lsp.get_clients()', '0.12')
|
||||||
local result = {} --- @type table<integer,lsp.Client>
|
local result = {} --- @type table<integer,lsp.Client>
|
||||||
for _, client in ipairs(lsp.get_clients({ bufnr = resolve_bufnr(bufnr) })) do
|
for _, client in ipairs(lsp.get_clients({ bufnr = resolve_bufnr(bufnr) })) do
|
||||||
result[client.id] = client
|
result[client.id] = client
|
||||||
@ -2101,6 +2102,11 @@ end
|
|||||||
--- buffer number as arguments.
|
--- buffer number as arguments.
|
||||||
---@deprecated use lsp.get_clients({ bufnr = bufnr }) with regular loop
|
---@deprecated use lsp.get_clients({ bufnr = bufnr }) with regular loop
|
||||||
function lsp.for_each_buffer_client(bufnr, fn)
|
function lsp.for_each_buffer_client(bufnr, fn)
|
||||||
|
vim.deprecate(
|
||||||
|
'vim.lsp.for_each_buffer_client()',
|
||||||
|
'lsp.get_clients({ bufnr = bufnr }) with regular loop',
|
||||||
|
'0.12'
|
||||||
|
)
|
||||||
return for_each_buffer_client(bufnr, fn)
|
return for_each_buffer_client(bufnr, fn)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ end
|
|||||||
---@return boolean if server responds.
|
---@return boolean if server responds.
|
||||||
---@deprecated
|
---@deprecated
|
||||||
function M.server_ready()
|
function M.server_ready()
|
||||||
vim.deprecate('vim.lsp.buf.server_ready', nil, '0.10.0')
|
vim.deprecate('vim.lsp.buf.server_ready()', nil, '0.10')
|
||||||
return not not vim.lsp.buf_notify(0, 'window/progress', {})
|
return not not vim.lsp.buf_notify(0, 'window/progress', {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -180,6 +180,7 @@ local _str_byteindex_enc = M._str_byteindex_enc
|
|||||||
---@param new_lines (table) list of strings to replace the original
|
---@param new_lines (table) list of strings to replace the original
|
||||||
---@return table The modified {lines} object
|
---@return table The modified {lines} object
|
||||||
function M.set_lines(lines, A, B, new_lines)
|
function M.set_lines(lines, A, B, new_lines)
|
||||||
|
vim.deprecate('vim.lsp.util.set_lines()', 'nil', '0.12')
|
||||||
-- 0-indexing to 1-indexing
|
-- 0-indexing to 1-indexing
|
||||||
local i_0 = A[1] + 1
|
local i_0 = A[1] + 1
|
||||||
-- If it extends past the end, truncate it to the end. This is because the
|
-- If it extends past the end, truncate it to the end. This is because the
|
||||||
@ -346,7 +347,7 @@ end
|
|||||||
---@private
|
---@private
|
||||||
---@deprecated Use vim.lsp.status() or access client.progress directly
|
---@deprecated Use vim.lsp.status() or access client.progress directly
|
||||||
function M.get_progress_messages()
|
function M.get_progress_messages()
|
||||||
vim.deprecate('vim.lsp.util.get_progress_messages', 'vim.lsp.status', '0.11.0')
|
vim.deprecate('vim.lsp.util.get_progress_messages()', 'vim.lsp.status()', '0.11')
|
||||||
local new_messages = {}
|
local new_messages = {}
|
||||||
local progress_remove = {}
|
local progress_remove = {}
|
||||||
|
|
||||||
@ -552,7 +553,7 @@ end
|
|||||||
---@return lsp.CompletionItem[] List of completion items
|
---@return lsp.CompletionItem[] List of completion items
|
||||||
---@see https://microsoft.github.io/language-server-protocol/specification#textDocument_completion
|
---@see https://microsoft.github.io/language-server-protocol/specification#textDocument_completion
|
||||||
function M.extract_completion_items(result)
|
function M.extract_completion_items(result)
|
||||||
vim.deprecate('vim.lsp.util.extract_completion_items', nil, '0.11')
|
vim.deprecate('vim.lsp.util.extract_completion_items()', nil, '0.11')
|
||||||
if type(result) == 'table' and result.items then
|
if type(result) == 'table' and result.items then
|
||||||
-- result is a `CompletionList`
|
-- result is a `CompletionList`
|
||||||
return result.items
|
return result.items
|
||||||
@ -612,7 +613,7 @@ end
|
|||||||
---@param input string unparsed snippet
|
---@param input string unparsed snippet
|
||||||
---@return string parsed snippet
|
---@return string parsed snippet
|
||||||
function M.parse_snippet(input)
|
function M.parse_snippet(input)
|
||||||
vim.deprecate('vim.lsp.util.parse_snippet', nil, '0.11')
|
vim.deprecate('vim.lsp.util.parse_snippet()', nil, '0.11')
|
||||||
local ok, parsed = pcall(function()
|
local ok, parsed = pcall(function()
|
||||||
return snippet.parse(input)
|
return snippet.parse(input)
|
||||||
end)
|
end)
|
||||||
@ -634,7 +635,7 @@ end
|
|||||||
---@return table[] items
|
---@return table[] items
|
||||||
---@see complete-items
|
---@see complete-items
|
||||||
function M.text_document_completion_list_to_complete_items(result, prefix)
|
function M.text_document_completion_list_to_complete_items(result, prefix)
|
||||||
vim.deprecate('vim.lsp.util.text_document_completion_list_to_complete_items', nil, '0.11')
|
vim.deprecate('vim.lsp.util.text_document_completion_list_to_complete_items()', nil, '0.11')
|
||||||
return require('vim.lsp._completion')._lsp_to_complete_items(result, prefix)
|
return require('vim.lsp._completion')._lsp_to_complete_items(result, prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1885,6 +1886,7 @@ end
|
|||||||
---@param lines table list of lines to trim
|
---@param lines table list of lines to trim
|
||||||
---@return table trimmed list of lines
|
---@return table trimmed list of lines
|
||||||
function M.trim_empty_lines(lines)
|
function M.trim_empty_lines(lines)
|
||||||
|
vim.deprecate('vim.lsp.util.trim_empty_lines()', 'vim.split() with `trimempty`', '0.12')
|
||||||
local start = 1
|
local start = 1
|
||||||
for i = 1, #lines do
|
for i = 1, #lines do
|
||||||
if lines[i] ~= nil and #lines[i] > 0 then
|
if lines[i] ~= nil and #lines[i] > 0 then
|
||||||
@ -1911,6 +1913,7 @@ end
|
|||||||
---@param lines table list of lines
|
---@param lines table list of lines
|
||||||
---@return string filetype or "markdown" if it was unchanged.
|
---@return string filetype or "markdown" if it was unchanged.
|
||||||
function M.try_trim_markdown_code_blocks(lines)
|
function M.try_trim_markdown_code_blocks(lines)
|
||||||
|
vim.deprecate('vim.lsp.util.try_trim_markdown_code_blocks()', 'nil', '0.12')
|
||||||
local language_id = lines[1]:match('^```(.*)')
|
local language_id = lines[1]:match('^```(.*)')
|
||||||
if language_id then
|
if language_id then
|
||||||
local has_inner_code_fence = false
|
local has_inner_code_fence = false
|
||||||
|
@ -37,6 +37,11 @@ end
|
|||||||
|
|
||||||
---@deprecated
|
---@deprecated
|
||||||
function M.require_language(lang, path, silent, symbol_name)
|
function M.require_language(lang, path, silent, symbol_name)
|
||||||
|
vim.deprecate(
|
||||||
|
'vim.treesitter.language.require_language()',
|
||||||
|
'vim.treesitter.language.add()',
|
||||||
|
'0.12'
|
||||||
|
)
|
||||||
local opts = {
|
local opts = {
|
||||||
silent = silent,
|
silent = silent,
|
||||||
path = path,
|
path = path,
|
||||||
|
Loading…
Reference in New Issue
Block a user