lsp/lsp-signature: prevent error spam

This commit is contained in:
Ching Pei Yang 2026-05-20 16:20:48 +02:00
commit 4dfed34c10
No known key found for this signature in database
GPG key ID: B3841364253DC4C8

View file

@ -1,11 +1,40 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.generators) mkLuaInline;
in {
options.vim.lsp = {
lspSignature = {
enable = mkEnableOption "lsp signature viewer";
setupOpts = mkPluginSetupOption "lsp-signature" {};
setupOpts = mkPluginSetupOption "lsp-signature" {
ignore_error = mkOption {
type = luaInline;
description = "Custom error filter.";
# https://github.com/NotAShelf/nvf/pull/1545#discussion_r3253920092
defaultText = "Filters out errors that occur more than once, per client";
default = mkLuaInline ''
function(err, ctx, config)
if ctx and ctx.client_id then
-- upstream default
local client = vim.lsp.get_client_by_id(ctx.client_id)
if client and vim.tbl_contains({"rust-analyzer", "clangd"}, client.name) then
return true
end
-- prevents error spam
_LSP_SIG_IGNORE_ERR = _LSP_SIG_IGNORE_ERR or {}
_LSP_SIG_IGNORE_ERR[ctx.client_id] = _LSP_SIG_IGNORE_ERR[ctx.client_id]
or {}
if _LSP_SIG_IGNORE_ERR[ctx.client_id][err.code] then
return true
end
_LSP_SIG_IGNORE_ERR[ctx.client_id][err.code] = true
end
end
'';
};
};
};
};
}