feat: add "jump" options to vim.diagnostic.config() (#29067)

Problem: There is no easy way to configure the behavior of the default
diagnostic "jump" mappings. For example, some users way want to show the
floating window, and some may not (likewise, some way want to only move
between warnings/errors, or disable the "wrap" parameter).

Solution: Add a "jump" table to vim.diagnostic.config() that sets
default values for vim.diagnostic.jump().

Alternatives: Users can override the default mappings to use the exact
options to vim.diagnostic.jump() that they want, but this has a couple
issues:

  - While the default mappings are not complicated, they are also not
    trivial, so overriding them requires users to understand
    implementation details (specifically things like setting "count"
    properly).
  - If plugins want to change the default mappings, or configure the
    behavior in any way (e.g. floating window display), it becomes even
    harder for users to tweak specific behavior.

vim.diagnostic.config() already works quite well as the "entry point"
for tuning knobs with diagnostic UI elements, so this fits in nicely and
composes well with existing mental models and idioms.
This commit is contained in:
Gregory Anders
2024-05-28 14:54:50 -05:00
committed by GitHub
parent f09f5c45fa
commit efa45832ea
5 changed files with 60 additions and 14 deletions

View File

@ -379,7 +379,7 @@ local function tbl_extend(behavior, deep_extend, ...)
for i = 1, select('#', ...) do
local tbl = select(i, ...)
vim.validate({ ['after the second argument'] = { tbl, 't' } })
vim.validate('after the second argument', tbl, 'table')
--- @cast tbl table<any,any>
if tbl then
for k, v in pairs(tbl) do