Skip to content

Commit

Permalink
fix(filters): allow the user to clear builtin filters with `clear_fil…
Browse files Browse the repository at this point in the history
…ters`
  • Loading branch information
Sam-programs committed May 11, 2024
1 parent 09102ca commit f4fc9e8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions lua/noice/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,28 @@ function M.is_running()
return M._running
end

function M.setup_filters(config, new_config, key)
if type(config) ~= "table" or type(new_config) ~= "table" then
return
end
if key == "filter" then
if new_config.clear_filters then
new_config.clear_filters = nil
-- Can't use `config = {}` because that would create a new array (instead of modifying the caller's `config`)
for k, _ in pairs(config) do
config[k] = nil
end
for k, v in pairs(new_config) do
config[k] = v
end
end
return
end
for k, _ in pairs(new_config) do
M.setup_filters(config[k], new_config[k], k)
end
end

function M.setup(options)
options = options or {}

Expand All @@ -246,6 +268,7 @@ function M.setup(options)
local routes = M.options.routes
M.options = vim.tbl_deep_extend("force", M.options, options)
vim.list_extend(M.options.routes, routes)
M.setup_filters(M.options, options)

if M.options.popupmenu.kind_icons == false then
M.options.popupmenu.kind_icons = {}
Expand Down
2 changes: 1 addition & 1 deletion lua/noice/lsp/progress.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ M._running = false
---@param data {client_id: integer, params: lsp.ProgressParams}
function M.progress(data)
local client_id = data.client_id
local params = data.params or data.result -- TODO: Remove data.result after nvim 0.10 release
local params = data.params or data.result -- TODO: Remove data.result after nvim 0.10 release
local id = client_id .. "." .. params.token

local message = M._progress[id]
Expand Down

0 comments on commit f4fc9e8

Please sign in to comment.