mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
fix(lsp)!: deprecate trim_empty_lines
This commit is contained in:
parent
cfd4a9dfaf
commit
5a363ccac8
@ -141,6 +141,7 @@ LSP FUNCTIONS
|
||||
`progress` of |vim.lsp.client|
|
||||
- *vim.lsp.get_active_clients()* Use |vim.lsp.get_clients()|
|
||||
- *vim.lsp.for_each_buffer_client()* Use |vim.lsp.get_clients()|
|
||||
- *vim.lsp.util.trim_empty_lines()* Use |vim.split()| with `trimempty` instead.
|
||||
|
||||
TREESITTER FUNCTIONS
|
||||
- *vim.treesitter.language.require_language()* Use |vim.treesitter.language.add()|
|
||||
|
@ -2033,15 +2033,6 @@ text_document_completion_list_to_complete_items({result}, {prefix})
|
||||
See also: ~
|
||||
• complete-items
|
||||
|
||||
trim_empty_lines({lines}) *vim.lsp.util.trim_empty_lines()*
|
||||
Removes empty lines from the beginning and end.
|
||||
|
||||
Parameters: ~
|
||||
• {lines} (table) list of lines to trim
|
||||
|
||||
Return: ~
|
||||
(table) trimmed list of lines
|
||||
|
||||
*vim.lsp.util.try_trim_markdown_code_blocks()*
|
||||
try_trim_markdown_code_blocks({lines})
|
||||
Accepts markdown lines and tries to reduce them to a filetype if they
|
||||
|
@ -272,6 +272,7 @@ release.
|
||||
- |vim.lsp.util.get_progress_messages()| Use |vim.lsp.status()| instead.
|
||||
- |vim.lsp.get_active_clients()| Use |vim.lsp.get_clients()| instead.
|
||||
- |vim.lsp.for_each_buffer_client()| Use |vim.lsp.get_clients()| instead.
|
||||
- |vim.lsp.util.trim_empty_lines()| Use |vim.split()| with `trimempty` instead.
|
||||
|
||||
• `vim.loop` has been renamed to `vim.uv`.
|
||||
|
||||
|
@ -375,11 +375,10 @@ function M.hover(_, result, ctx, config)
|
||||
local contents ---@type string[]
|
||||
if type(result.contents) == 'table' and result.contents.kind == 'plaintext' then
|
||||
format = 'plaintext'
|
||||
contents = { result.contents.value or '' }
|
||||
contents = vim.split(result.contents.value or '', '\n', { trimempty = true })
|
||||
else
|
||||
contents = util.convert_input_to_markdown_lines(result.contents)
|
||||
end
|
||||
contents = util.trim_empty_lines(contents)
|
||||
if vim.tbl_isempty(contents) then
|
||||
if config.silent ~= true then
|
||||
vim.notify('No information available')
|
||||
@ -477,7 +476,6 @@ function M.signature_help(_, result, ctx, config)
|
||||
vim.tbl_get(client.server_capabilities, 'signatureHelpProvider', 'triggerCharacters')
|
||||
local ft = vim.bo[ctx.bufnr].filetype
|
||||
local lines, hl = util.convert_signature_help_to_markdown_lines(result, ft, triggers)
|
||||
lines = util.trim_empty_lines(lines)
|
||||
if vim.tbl_isempty(lines) then
|
||||
if config.silent ~= true then
|
||||
print('No signature help available')
|
||||
|
@ -102,7 +102,7 @@ end
|
||||
|
||||
local function split_lines(value)
|
||||
value = string.gsub(value, '\r\n?', '\n')
|
||||
return split(value, '\n', { plain = true })
|
||||
return split(value, '\n', { plain = true, trimempty = true })
|
||||
end
|
||||
|
||||
local function create_window_without_focus()
|
||||
@ -947,7 +947,7 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft, triggers
|
||||
-- wrap inside a code block for proper rendering
|
||||
label = ('```%s\n%s\n```'):format(ft, label)
|
||||
end
|
||||
list_extend(contents, split(label, '\n', { plain = true }))
|
||||
list_extend(contents, split(label, '\n', { plain = true, trimempty = true }))
|
||||
if signature.documentation then
|
||||
-- if LSP returns plain string, we treat it as plaintext. This avoids
|
||||
-- special characters like underscore or similar from being interpreted
|
||||
@ -1351,7 +1351,7 @@ function M.stylize_markdown(bufnr, contents, opts)
|
||||
end
|
||||
|
||||
-- Clean up
|
||||
contents = M.trim_empty_lines(contents)
|
||||
contents = vim.split(table.concat(contents, '\n'), '\n', { trimempty = true })
|
||||
|
||||
local stripped = {}
|
||||
local highlights = {}
|
||||
@ -1510,10 +1510,9 @@ end
|
||||
---
|
||||
--- The following transformations are made:
|
||||
---
|
||||
--- 1. Empty lines at the beginning or end of the content are removed
|
||||
--- 2. Carriage returns ('\r') are removed
|
||||
--- 3. Successive empty lines are collapsed into a single empty line
|
||||
--- 4. Thematic breaks are expanded to the given width
|
||||
--- 1. Carriage returns ('\r') and empty lines at the beginning and end are removed
|
||||
--- 2. Successive empty lines are collapsed into a single empty line
|
||||
--- 3. Thematic breaks are expanded to the given width
|
||||
---
|
||||
---@private
|
||||
---@param contents string[]
|
||||
@ -1527,16 +1526,13 @@ function M._normalize_markdown(contents, opts)
|
||||
})
|
||||
opts = opts or {}
|
||||
|
||||
-- 1. Empty lines at the beginning or end of the content are removed
|
||||
contents = M.trim_empty_lines(contents)
|
||||
-- 1. Carriage returns are removed
|
||||
contents = vim.split(table.concat(contents, '\n'):gsub('\r', ''), '\n', { trimempty = true })
|
||||
|
||||
-- 2. Carriage returns are removed
|
||||
contents = vim.split(table.concat(contents, '\n'):gsub('\r', ''), '\n')
|
||||
|
||||
-- 3. Successive empty lines are collapsed into a single empty line
|
||||
-- 2. Successive empty lines are collapsed into a single empty line
|
||||
contents = collapse_blank_lines(contents)
|
||||
|
||||
-- 4. Thematic breaks are expanded to the given width
|
||||
-- 3. Thematic breaks are expanded to the given width
|
||||
local divider = string.rep('─', opts.width or 80)
|
||||
contents = replace_separators(contents, divider)
|
||||
|
||||
@ -1738,8 +1734,8 @@ function M.open_floating_preview(contents, syntax, opts)
|
||||
vim.treesitter.start(floating_bufnr)
|
||||
api.nvim_buf_set_lines(floating_bufnr, 0, -1, false, contents)
|
||||
else
|
||||
-- Clean up input: trim empty lines from the end, pad
|
||||
contents = M.trim_empty_lines(contents)
|
||||
-- Clean up input: trim empty lines
|
||||
contents = vim.split(table.concat(contents, '\n'), '\n', { trimempty = true })
|
||||
|
||||
if syntax then
|
||||
vim.bo[floating_bufnr].syntax = syntax
|
||||
@ -1969,6 +1965,7 @@ function M.symbols_to_items(symbols, bufnr)
|
||||
end
|
||||
|
||||
--- Removes empty lines from the beginning and end.
|
||||
---@deprecated use `vim.split()` with `trimempty` instead
|
||||
---@param lines table list of lines to trim
|
||||
---@return table trimmed list of lines
|
||||
function M.trim_empty_lines(lines)
|
||||
|
Loading…
Reference in New Issue
Block a user