diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2026-09-09 13:04:46 +0100 |
|---|---|---|
| committer | Lewis Russell <me@lewisr.dev> | 2026-09-09 22:31:58 +0100 |
| commit | d039f19af54e73e1f076c29f1cb412c14612da07 (patch) | |
| tree | 7d5f04c1810d063dda4389af4bd2532511bb8787 /runtime/lua/vim/diagnostic/_float.lua | |
| parent | 08dd3adffb60ae6c031f9b8310febd65bb14604e (diff) | |
| download | rneovim-d039f19af54e73e1f076c29f1cb412c14612da07.tar.gz rneovim-d039f19af54e73e1f076c29f1cb412c14612da07.tar.bz2 rneovim-d039f19af54e73e1f076c29f1cb412c14612da07.zip | |
build: enable more EmmyLua checks
Enable checks for unused code, deprecated calls, return types, and
annotations.
Fix the warnings and replace the deprecated highlight function. Keep
exceptions where old APIs are still needed or the checker gets it wrong.
AI-assisted
Diffstat (limited to 'runtime/lua/vim/diagnostic/_float.lua')
| -rw-r--r-- | runtime/lua/vim/diagnostic/_float.lua | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/runtime/lua/vim/diagnostic/_float.lua b/runtime/lua/vim/diagnostic/_float.lua index aa41cdd38e..f7331b3c56 100644 --- a/runtime/lua/vim/diagnostic/_float.lua +++ b/runtime/lua/vim/diagnostic/_float.lua @@ -5,6 +5,8 @@ local store = require('vim.diagnostic._store') --- @class (private) vim.diagnostic._float local M = {} +local float_ns = api.nvim_create_namespace('nvim.diagnostic.float') + local severity = vim.diagnostic.severity --- @type table<vim.diagnostic.Severity, string> @@ -263,19 +265,31 @@ function M.open(opts, ...) end end, { buf = float_bufnr, remap = false }) - --- @diagnostic disable-next-line: deprecated - local add_highlight = api.nvim_buf_add_highlight - + -- The preview may trim empty lines or reuse an older buffer, so highlight ranges + -- can extend past its contents. Use strict = false to tolerate this. for i, hl in ipairs(highlights) do local line = lines[i] local prefix_len = hl.prefix and hl.prefix.length or 0 local suffix_len = hl.suffix and hl.suffix.length or 0 if prefix_len > 0 then - add_highlight(float_bufnr, -1, hl.prefix.hlname, i - 1, 0, prefix_len) + api.nvim_buf_set_extmark(float_bufnr, float_ns, i - 1, 0, { + hl_group = hl.prefix.hlname, + end_col = prefix_len, + strict = false, + }) end - add_highlight(float_bufnr, -1, hl.hlname, i - 1, prefix_len, #line - suffix_len) + api.nvim_buf_set_extmark(float_bufnr, float_ns, i - 1, prefix_len, { + hl_group = hl.hlname, + end_col = #line - suffix_len, + strict = false, + }) if suffix_len > 0 then - add_highlight(float_bufnr, -1, hl.suffix.hlname, i - 1, #line - suffix_len, -1) + api.nvim_buf_set_extmark(float_bufnr, float_ns, i - 1, #line - suffix_len, { + hl_group = hl.suffix.hlname, + end_row = i, + end_col = 0, + strict = false, + }) end end |