Skip to content

Commit

Permalink
feat(config): allow custom window filters. Added non-focusable window…
Browse files Browse the repository at this point in the history
…s by default
  • Loading branch information
folke committed Jun 23, 2023
1 parent 010026f commit e6ee00d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ Install the plugin with your preferred package manager:
mode = "exact",
-- behave like `incsearch`
incremental = false,
filetype_exclude = { "notify", "noice" },
-- Excluded filetypes and custom window filters
---@type (string|fun(win:window))[]
exclude = {
"notify",
"cmp_menu",
function(win)
-- exclude non-focusable windows
return not vim.api.nvim_win_get_config(win).focusable
end,
},
-- Optional trigger character that needs to be typed before
-- a jump label can be used. It's NOT recommended to set this,
-- unless you know what you're doing
Expand Down
9 changes: 7 additions & 2 deletions lua/flash/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ function M:_update_wins()
wins = vim.tbl_filter(function(w)
local buf = vim.api.nvim_win_get_buf(w)
local ft = vim.bo[buf].filetype
if ft and vim.tbl_contains(self.state.opts.search.filetype_exclude, ft) then
return false

for _, exclude in ipairs(self.state.opts.search.exclude) do
if type(exclude) == "string" and exclude == ft then
return false
elseif type(exclude) == "function" and exclude(w) then
return false
end
end
return w ~= self.state.win
end, wins)
Expand Down
11 changes: 10 additions & 1 deletion lua/flash/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ local defaults = {
mode = "exact",
-- behave like `incsearch`
incremental = false,
filetype_exclude = { "notify", "noice", "cmp_menu" },
-- Excluded filetypes and custom window filters
---@type (string|fun(win:window))[]
exclude = {
"notify",
"cmp_menu",
function(win)
-- exclude non-focusable windows
return not vim.api.nvim_win_get_config(win).focusable
end,
},
-- Optional trigger character that needs to be typed before
-- a jump label can be used. It's NOT recommended to set this,
-- unless you know what you're doing
Expand Down

0 comments on commit e6ee00d

Please sign in to comment.