mirror of
https://github.com/neovim/neovim
synced 2025-07-20 13:22:26 +00:00
feat(diagnostic): use scope = 'line'
by default for open_float()
(#16456)
Closes #16453 Co-authored-by: Cédric Barreteau <cbarrete@users.noreply.github.com>
This commit is contained in:
@ -239,7 +239,7 @@ DiagnosticUnderlineHint
|
|||||||
*hl-DiagnosticFloatingError*
|
*hl-DiagnosticFloatingError*
|
||||||
DiagnosticFloatingError
|
DiagnosticFloatingError
|
||||||
Used to color "Error" diagnostic messages in diagnostics float.
|
Used to color "Error" diagnostic messages in diagnostics float.
|
||||||
See |vim.diagnostic.show_line_diagnostics()|
|
See |vim.diagnostic.open_float()|
|
||||||
|
|
||||||
*hl-DiagnosticFloatingWarn*
|
*hl-DiagnosticFloatingWarn*
|
||||||
DiagnosticFloatingWarn
|
DiagnosticFloatingWarn
|
||||||
|
@ -1131,7 +1131,7 @@ end
|
|||||||
---@param opts table|nil Configuration table with the same keys as
|
---@param opts table|nil Configuration table with the same keys as
|
||||||
--- |vim.lsp.util.open_floating_preview()| in addition to the following:
|
--- |vim.lsp.util.open_floating_preview()| in addition to the following:
|
||||||
--- - namespace: (number) Limit diagnostics to the given namespace
|
--- - namespace: (number) Limit diagnostics to the given namespace
|
||||||
--- - scope: (string, default "buffer") Show diagnostics from the whole buffer ("buffer"),
|
--- - scope: (string, default "line") Show diagnostics from the whole buffer ("buffer"),
|
||||||
--- the current cursor line ("line"), or the current cursor position ("cursor").
|
--- the current cursor line ("line"), or the current cursor position ("cursor").
|
||||||
--- - pos: (number or table) If {scope} is "line" or "cursor", use this position rather
|
--- - pos: (number or table) If {scope} is "line" or "cursor", use this position rather
|
||||||
--- than the cursor position. If a number, interpreted as a line number;
|
--- than the cursor position. If a number, interpreted as a line number;
|
||||||
@ -1169,7 +1169,7 @@ function M.open_float(bufnr, opts)
|
|||||||
|
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
bufnr = get_bufnr(bufnr)
|
bufnr = get_bufnr(bufnr)
|
||||||
local scope = opts.scope or "buffer"
|
local scope = opts.scope or "line"
|
||||||
local lnum, col
|
local lnum, col
|
||||||
if scope == "line" or scope == "cursor" then
|
if scope == "line" or scope == "cursor" then
|
||||||
if not opts.pos then
|
if not opts.pos then
|
||||||
|
@ -431,24 +431,6 @@ end
|
|||||||
--- Move to the next diagnostic
|
--- Move to the next diagnostic
|
||||||
---
|
---
|
||||||
---@deprecated Prefer |vim.diagnostic.goto_next()|
|
---@deprecated Prefer |vim.diagnostic.goto_next()|
|
||||||
---
|
|
||||||
---@param opts table|nil Configuration table. Keys:
|
|
||||||
--- - {client_id}: (number)
|
|
||||||
--- - If nil, will consider all clients attached to buffer.
|
|
||||||
--- - {cursor_position}: (Position, default current position)
|
|
||||||
--- - See |nvim_win_get_cursor()|
|
|
||||||
--- - {wrap}: (boolean, default true)
|
|
||||||
--- - Whether to loop around file or not. Similar to 'wrapscan'
|
|
||||||
--- - {severity}: (DiagnosticSeverity)
|
|
||||||
--- - Exclusive severity to consider. Overrides {severity_limit}
|
|
||||||
--- - {severity_limit}: (DiagnosticSeverity)
|
|
||||||
--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
|
|
||||||
--- - {enable_popup}: (boolean, default true)
|
|
||||||
--- - Call |vim.lsp.diagnostic.show_line_diagnostics()| on jump
|
|
||||||
--- - {popup_opts}: (table)
|
|
||||||
--- - Table to pass as {opts} parameter to |vim.lsp.diagnostic.show_line_diagnostics()|
|
|
||||||
--- - {win_id}: (number, default 0)
|
|
||||||
--- - Window ID
|
|
||||||
function M.goto_next(opts)
|
function M.goto_next(opts)
|
||||||
if opts then
|
if opts then
|
||||||
if opts.severity then
|
if opts.severity then
|
||||||
@ -562,7 +544,7 @@ end
|
|||||||
|
|
||||||
--- Open a floating window with the diagnostics from {line_nr}
|
--- Open a floating window with the diagnostics from {line_nr}
|
||||||
---
|
---
|
||||||
---@deprecated Prefer |vim.diagnostic.show_line_diagnostics()|
|
---@deprecated Prefer |vim.diagnostic.open_float()|
|
||||||
---
|
---
|
||||||
---@param opts table Configuration table
|
---@param opts table Configuration table
|
||||||
--- - all opts for |vim.lsp.diagnostic.get_line_diagnostics()| and
|
--- - all opts for |vim.lsp.diagnostic.get_line_diagnostics()| and
|
||||||
|
@ -1370,7 +1370,7 @@ describe('vim.diagnostic', function()
|
|||||||
}
|
}
|
||||||
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false})
|
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false, scope="buffer"})
|
||||||
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
||||||
vim.api.nvim_win_close(winnr, true)
|
vim.api.nvim_win_close(winnr, true)
|
||||||
return lines
|
return lines
|
||||||
@ -1387,7 +1387,7 @@ describe('vim.diagnostic', function()
|
|||||||
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
vim.api.nvim_win_set_cursor(0, {2, 1})
|
vim.api.nvim_win_set_cursor(0, {2, 1})
|
||||||
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header=false, scope="line"})
|
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header=false})
|
||||||
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
||||||
vim.api.nvim_win_close(winnr, true)
|
vim.api.nvim_win_close(winnr, true)
|
||||||
return lines
|
return lines
|
||||||
@ -1402,7 +1402,7 @@ describe('vim.diagnostic', function()
|
|||||||
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
vim.api.nvim_win_set_cursor(0, {1, 1})
|
vim.api.nvim_win_set_cursor(0, {1, 1})
|
||||||
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header=false, scope="line", pos=1})
|
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header=false, pos=1})
|
||||||
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
||||||
vim.api.nvim_win_close(winnr, true)
|
vim.api.nvim_win_close(winnr, true)
|
||||||
return lines
|
return lines
|
||||||
@ -1466,7 +1466,7 @@ describe('vim.diagnostic', function()
|
|||||||
}
|
}
|
||||||
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr, {scope="line"})
|
local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr)
|
||||||
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
||||||
vim.api.nvim_win_close(winnr, true)
|
vim.api.nvim_win_close(winnr, true)
|
||||||
return #lines
|
return #lines
|
||||||
@ -1533,7 +1533,7 @@ describe('vim.diagnostic', function()
|
|||||||
}
|
}
|
||||||
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr, {header = false, scope = "line", pos = 5})
|
local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr, {header = false, pos = 5})
|
||||||
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
||||||
vim.api.nvim_win_close(winnr, true)
|
vim.api.nvim_win_close(winnr, true)
|
||||||
return #lines
|
return #lines
|
||||||
@ -1665,7 +1665,7 @@ describe('vim.diagnostic', function()
|
|||||||
}
|
}
|
||||||
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false})
|
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false, scope = "buffer"})
|
||||||
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
||||||
vim.api.nvim_win_close(winnr, true)
|
vim.api.nvim_win_close(winnr, true)
|
||||||
return lines
|
return lines
|
||||||
@ -1678,7 +1678,7 @@ describe('vim.diagnostic', function()
|
|||||||
}
|
}
|
||||||
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false, prefix = ""})
|
local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false, scope = "buffer", prefix = ""})
|
||||||
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
|
||||||
vim.api.nvim_win_close(winnr, true)
|
vim.api.nvim_win_close(winnr, true)
|
||||||
return lines
|
return lines
|
||||||
@ -1687,7 +1687,7 @@ describe('vim.diagnostic', function()
|
|||||||
eq({'1. Syntax error', '2. Some warning'}, exec_lua [[
|
eq({'1. Syntax error', '2. Some warning'}, exec_lua [[
|
||||||
local diagnostics = {
|
local diagnostics = {
|
||||||
make_error("Syntax error", 0, 1, 0, 3),
|
make_error("Syntax error", 0, 1, 0, 3),
|
||||||
make_warning("Some warning", 1, 1, 1, 3),
|
make_warning("Some warning", 0, 1, 0, 3),
|
||||||
}
|
}
|
||||||
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
|
Reference in New Issue
Block a user