mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 20:05:38 +00:00
fix(diagnostic): make open_float respect global diagnostic options (#17879)
* make `open_float` respect `scope` option set in `vim.diagnostic.config` * Closes #17878
This commit is contained in:
@@ -1224,6 +1224,18 @@ function M.open_float(opts, ...)
|
|||||||
|
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
bufnr = get_bufnr(bufnr or opts.bufnr)
|
bufnr = get_bufnr(bufnr or opts.bufnr)
|
||||||
|
|
||||||
|
do
|
||||||
|
-- Resolve options with user settings from vim.diagnostic.config
|
||||||
|
-- Unlike the other decoration functions (e.g. set_virtual_text, set_signs, etc.) `open_float`
|
||||||
|
-- does not have a dedicated table for configuration options; instead, the options are mixed in
|
||||||
|
-- with its `opts` table which also includes "keyword" parameters. So we create a dedicated
|
||||||
|
-- options table that inherits missing keys from the global configuration before resolving.
|
||||||
|
local t = global_diagnostic_options.float
|
||||||
|
local float_opts = vim.tbl_extend("keep", opts, type(t) == "table" and t or {})
|
||||||
|
opts = get_resolved_options({ float = float_opts }, nil, bufnr).float
|
||||||
|
end
|
||||||
|
|
||||||
local scope = ({l = "line", c = "cursor", b = "buffer"})[opts.scope] or opts.scope or "line"
|
local scope = ({l = "line", c = "cursor", b = "buffer"})[opts.scope] or opts.scope or "line"
|
||||||
local lnum, col
|
local lnum, col
|
||||||
if scope == "line" or scope == "cursor" then
|
if scope == "line" or scope == "cursor" then
|
||||||
@@ -1242,17 +1254,6 @@ function M.open_float(opts, ...)
|
|||||||
error("Invalid value for option 'scope'")
|
error("Invalid value for option 'scope'")
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
|
||||||
-- Resolve options with user settings from vim.diagnostic.config
|
|
||||||
-- Unlike the other decoration functions (e.g. set_virtual_text, set_signs, etc.) `open_float`
|
|
||||||
-- does not have a dedicated table for configuration options; instead, the options are mixed in
|
|
||||||
-- with its `opts` table which also includes "keyword" parameters. So we create a dedicated
|
|
||||||
-- options table that inherits missing keys from the global configuration before resolving.
|
|
||||||
local t = global_diagnostic_options.float
|
|
||||||
local float_opts = vim.tbl_extend("keep", opts, type(t) == "table" and t or {})
|
|
||||||
opts = get_resolved_options({ float = float_opts }, nil, bufnr).float
|
|
||||||
end
|
|
||||||
|
|
||||||
local diagnostics = get_diagnostics(bufnr, opts, true)
|
local diagnostics = get_diagnostics(bufnr, opts, true)
|
||||||
|
|
||||||
if scope == "line" then
|
if scope == "line" then
|
||||||
|
|||||||
Reference in New Issue
Block a user