aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/news.txt7
-rw-r--r--runtime/lua/vim/diagnostic.lua81
-rw-r--r--test/functional/lua/diagnostic_spec.lua142
3 files changed, 16 insertions, 214 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 24af07a34b..c0f3b31cf7 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -49,7 +49,12 @@ BUILD
DIAGNOSTICS
-• todo
+• |diagnostic-signs| can no longer be configured with |:sign-define| or
+ |sign_define()| (deprecated in Nvim 0.10 |deprecated-0.10|).
+• |vim.diagnostic.disable()| and |vim.diagnostic.is_disabled()| (deprecated in
+ Nvim 0.10 |deprecated-0.10|) are removed.
+• The legacy signature of |vim.diagnostic.enable()| (deprecated in Nvim 0.10
+ |deprecated-0.10|) is no longer supported.
EDITOR
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 1464d0c013..c52b42b382 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -1456,47 +1456,6 @@ M.handlers.signs = {
api.nvim_create_namespace(string.format('nvim.%s.diagnostic.signs', ns.name))
end
- -- Handle legacy diagnostic sign definitions
- -- These were deprecated in 0.10 and will be removed in 0.12
- if opts.signs and not opts.signs.text and not opts.signs.numhl then
- for _, v in ipairs({ 'Error', 'Warn', 'Info', 'Hint' }) do
- local name = string.format('DiagnosticSign%s', v)
- local sign = vim.fn.sign_getdefined(name)[1]
- if sign then
- local severity = M.severity[v:upper()]
- vim.deprecate(
- 'Defining diagnostic signs with :sign-define or sign_define()',
- 'vim.diagnostic.config()',
- '0.12'
- )
-
- if not opts.signs.text then
- opts.signs.text = {}
- end
-
- if not opts.signs.numhl then
- opts.signs.numhl = {}
- end
-
- if not opts.signs.linehl then
- opts.signs.linehl = {}
- end
-
- if opts.signs.text[severity] == nil then
- opts.signs.text[severity] = sign.text or ''
- end
-
- if opts.signs.numhl[severity] == nil then
- opts.signs.numhl[severity] = sign.numhl
- end
-
- if opts.signs.linehl[severity] == nil then
- opts.signs.linehl[severity] = sign.linehl
- end
- end
- end
- end
-
local text = {} ---@type table<vim.diagnostic.Severity|string, string>
for k in pairs(M.severity) do
if opts.signs.text and opts.signs.text[k] then
@@ -2058,12 +2017,6 @@ function M.is_enabled(filter)
return diagnostic_disabled[bufnr] == nil
end
---- @deprecated use `vim.diagnostic.is_enabled()`
-function M.is_disabled(bufnr, namespace)
- vim.deprecate('vim.diagnostic.is_disabled()', 'vim.diagnostic.is_enabled()', '0.12')
- return not M.is_enabled { bufnr = bufnr or 0, ns_id = namespace }
-end
-
--- Display diagnostics for the given namespace and buffer.
---
---@param namespace integer? Diagnostic namespace. When omitted, show
@@ -2441,12 +2394,6 @@ function M.setloclist(opts)
set_list(true, opts)
end
---- @deprecated use `vim.diagnostic.enable(false, …)`
-function M.disable(bufnr, namespace)
- vim.deprecate('vim.diagnostic.disable()', 'vim.diagnostic.enable(false, …)', '0.12')
- M.enable(false, { bufnr = bufnr, ns_id = namespace })
-end
-
--- Enables or disables diagnostics.
---
--- To "toggle", pass the inverse of `is_enabled()`:
@@ -2458,31 +2405,9 @@ end
--- @param enable (boolean|nil) true/nil to enable, false to disable
--- @param filter vim.diagnostic.Filter?
function M.enable(enable, filter)
- -- Deprecated signature. Drop this in 0.12
- local legacy = (enable or filter)
- and vim.tbl_contains({ 'number', 'nil' }, type(enable))
- and vim.tbl_contains({ 'number', 'nil' }, type(filter))
-
- if legacy then
- vim.deprecate(
- 'vim.diagnostic.enable(buf:number, namespace:number)',
- 'vim.diagnostic.enable(enable:boolean, filter:table)',
- '0.12'
- )
-
- vim.validate('enable', enable, 'number', true) -- Legacy `bufnr` arg.
- vim.validate('filter', filter, 'number', true) -- Legacy `namespace` arg.
-
- local ns_id = type(filter) == 'number' and filter or nil
- filter = {}
- filter.ns_id = ns_id
- filter.bufnr = type(enable) == 'number' and enable or nil
- enable = true
- else
- filter = filter or {}
- vim.validate('enable', enable, 'boolean', true)
- vim.validate('filter', filter, 'table', true)
- end
+ filter = filter or {}
+ vim.validate('enable', enable, 'boolean', true)
+ vim.validate('filter', filter, 'table', true)
enable = enable == nil and true or enable
local bufnr = filter.bufnr
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 0b77291379..2dba5c2805 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -625,14 +625,6 @@ describe('vim.diagnostic', function()
pcall_err(exec_lua, [[vim.diagnostic.enable(42, {})]])
)
matches('expected boolean, got table', pcall_err(exec_lua, [[vim.diagnostic.enable({}, 42)]]))
-
- -- Deprecated signature.
- matches('Invalid buffer id: 42', pcall_err(exec_lua, [[vim.diagnostic.enable(42)]]))
- -- Deprecated signature.
- matches(
- 'namespace does not exist or is anonymous',
- pcall_err(exec_lua, [[vim.diagnostic.enable(nil, 42)]])
- )
end)
it('without arguments', function()
@@ -828,7 +820,7 @@ describe('vim.diagnostic', function()
end)
--- @return table
- local function test_enable(legacy)
+ local function test_enable()
return exec_lua(function()
local other_bufnr = vim.api.nvim_create_buf(true, false)
@@ -860,11 +852,7 @@ describe('vim.diagnostic', function()
+ _G.count_extmarks(other_bufnr, _G.diagnostic_ns)
)
- if legacy then
- vim.diagnostic.disable(_G.diagnostic_bufnr, _G.diagnostic_ns)
- else
- vim.diagnostic.enable(false, { bufnr = _G.diagnostic_bufnr, ns_id = _G.diagnostic_ns })
- end
+ vim.diagnostic.enable(false, { bufnr = _G.diagnostic_bufnr, ns_id = _G.diagnostic_ns })
table.insert(
result,
@@ -873,11 +861,7 @@ describe('vim.diagnostic', function()
+ _G.count_extmarks(other_bufnr, _G.diagnostic_ns)
)
- if legacy then
- vim.diagnostic.disable(_G.diagnostic_bufnr, _G.other_ns)
- else
- vim.diagnostic.enable(false, { bufnr = _G.diagnostic_bufnr, ns_id = _G.other_ns })
- end
+ vim.diagnostic.enable(false, { bufnr = _G.diagnostic_bufnr, ns_id = _G.other_ns })
table.insert(
result,
@@ -886,11 +870,7 @@ describe('vim.diagnostic', function()
+ _G.count_extmarks(other_bufnr, _G.diagnostic_ns)
)
- if legacy then
- vim.diagnostic.enable(_G.diagnostic_bufnr, _G.diagnostic_ns)
- else
- vim.diagnostic.enable(true, { bufnr = _G.diagnostic_bufnr, ns_id = _G.diagnostic_ns })
- end
+ vim.diagnostic.enable(true, { bufnr = _G.diagnostic_bufnr, ns_id = _G.diagnostic_ns })
table.insert(
result,
@@ -899,13 +879,8 @@ describe('vim.diagnostic', function()
+ _G.count_extmarks(other_bufnr, _G.diagnostic_ns)
)
- if legacy then
- -- Should have no effect
- vim.diagnostic.disable(other_bufnr, _G.other_ns)
- else
- -- Should have no effect
- vim.diagnostic.enable(false, { bufnr = other_bufnr, ns_id = _G.other_ns })
- end
+ -- Should have no effect
+ vim.diagnostic.enable(false, { bufnr = other_bufnr, ns_id = _G.other_ns })
table.insert(
result,
@@ -919,17 +894,7 @@ describe('vim.diagnostic', function()
end
it('with both buffer and namespace arguments', function()
- local result = test_enable(false)
- eq(4, result[1])
- eq(2, result[2])
- eq(1, result[3])
- eq(3, result[4])
- eq(3, result[5])
- end)
-
- it('with both buffer and namespace arguments (deprecated signature)', function()
- -- Exercise the legacy/deprecated signature.
- local result = test_enable(true)
+ local result = test_enable()
eq(4, result[1])
eq(2, result[2])
eq(1, result[3])
@@ -2664,67 +2629,6 @@ describe('vim.diagnostic', function()
eq({}, result)
end
end)
-
- it('respects legacy signs placed with :sign define or sign_define #26618', function()
- -- Legacy signs for diagnostics were deprecated in 0.10 and will be removed in 0.12
- -- eq(0, n.fn.has('nvim-0.12'))
-
- n.command('sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg')
- n.command('sign define DiagnosticSignWarn text= texthl= linehl=WarningMsg numhl=WarningMsg')
- n.command('sign define DiagnosticSignInfo text= texthl= linehl=Underlined numhl=Underlined')
- n.command('sign define DiagnosticSignHint text= texthl= linehl=Underlined numhl=Underlined')
-
- local result = exec_lua(function()
- vim.diagnostic.config({
- signs = true,
- })
-
- local diagnostics = {
- _G.make_error('Error', 1, 1, 1, 2),
- _G.make_warning('Warning', 3, 3, 3, 3),
- }
-
- vim.diagnostic.set(_G.diagnostic_ns, _G.diagnostic_bufnr, diagnostics)
-
- local ns = vim.diagnostic.get_namespace(_G.diagnostic_ns)
- local sign_ns = ns.user_data.sign_ns
-
- local signs = vim.api.nvim_buf_get_extmarks(
- _G.diagnostic_bufnr,
- sign_ns,
- 0,
- -1,
- { type = 'sign', details = true }
- )
- local result = {}
- for _, s in ipairs(signs) do
- result[#result + 1] = {
- lnum = s[2] + 1,
- name = s[4].sign_hl_group,
- text = s[4].sign_text or '',
- numhl = s[4].number_hl_group,
- linehl = s[4].line_hl_group,
- }
- end
- return result
- end)
-
- eq({
- lnum = 2,
- name = 'DiagnosticSignError',
- text = '',
- numhl = 'ErrorMsg',
- linehl = 'ErrorMsg',
- }, result[1])
-
- eq({
- lnum = 4,
- name = 'DiagnosticSignWarn',
- text = '',
- numhl = 'WarningMsg',
- linehl = 'WarningMsg',
- }, result[2])
- end)
end)
describe('open_float()', function()
@@ -3824,37 +3728,5 @@ describe('vim.diagnostic', function()
end)
)
end)
-
- it('is_disabled (deprecated)', function()
- eq(
- { true, true, true, true },
- exec_lua(function()
- vim.diagnostic.set(_G.diagnostic_ns, _G.diagnostic_bufnr, {
- _G.make_error('Diagnostic #1', 1, 1, 1, 1),
- })
- vim.api.nvim_set_current_buf(_G.diagnostic_bufnr)
- vim.diagnostic.disable()
- return {
- vim.diagnostic.is_disabled(),
- vim.diagnostic.is_disabled(_G.diagnostic_bufnr),
- vim.diagnostic.is_disabled(_G.diagnostic_bufnr, _G.diagnostic_ns),
- vim.diagnostic.is_disabled(0, _G.diagnostic_ns),
- }
- end)
- )
-
- eq(
- { false, false, false, false },
- exec_lua(function()
- vim.diagnostic.enable()
- return {
- vim.diagnostic.is_disabled(),
- vim.diagnostic.is_disabled(_G.diagnostic_bufnr),
- vim.diagnostic.is_disabled(_G.diagnostic_bufnr, _G.diagnostic_ns),
- vim.diagnostic.is_disabled(0, _G.diagnostic_ns),
- }
- end)
- )
- end)
end)
end)