Skip to content

Commit 1656a0a

Browse files
authored
feat: add filter for unfocusable windows (#90)
Fixes #67. Fixes #86.
1 parent 41cfaa4 commit 1656a0a

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ require 'window-picker'.setup({
123123
-- selection or not
124124
include_current_win = false,
125125

126+
-- whether to include windows marked as unfocusable
127+
include_unfocusable_windows = false,
128+
126129
-- filter using buffer options
127130
bo = {
128131
-- if the file type is one of following, the window will be ignored

lua/window-picker/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ local config = {
6767
-- selection or not
6868
include_current_win = false,
6969

70+
-- whether to include windows marked as unfocusable
71+
include_unfocusable_windows = false,
72+
7073
-- filter using buffer options
7174
bo = {
7275
-- if the file type is one of following, the window will be ignored

lua/window-picker/filters/default-window-filter.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function M:new()
2020
o._file_path_contains_filter,
2121
o._file_path_contains_filter,
2222
o._current_window_filter,
23+
o._unfocusable_windows_filter,
2324
}
2425

2526
return o
@@ -31,6 +32,7 @@ function M:set_config(config)
3132
self.file_name_contains = config.file_name_contains or {}
3233
self.file_path_contains = config.file_path_contains or {}
3334
self.include_current_win = config.include_current_win
35+
self.include_unfocusable_windows = config.include_unfocusable_windows
3436
end
3537

3638
function M:filter_windows(windows)
@@ -150,4 +152,15 @@ function M:_current_window_filter(windows)
150152
end)
151153
end
152154

155+
function M:_unfocusable_windows_filter(windows)
156+
if self.include_unfocusable_windows then
157+
return windows
158+
end
159+
160+
return util.tbl_filter(windows, function(winid)
161+
local cfg = vim.api.nvim_win_get_config(winid)
162+
return cfg.focusable
163+
end)
164+
end
165+
153166
return M

0 commit comments

Comments
 (0)