fix(statusline): better window picker highlight (#1139)
This commit is contained in:
@@ -58,17 +58,23 @@ local function pick_window()
|
|||||||
local laststatus = vim.o.laststatus
|
local laststatus = vim.o.laststatus
|
||||||
vim.o.laststatus = 2
|
vim.o.laststatus = 2
|
||||||
|
|
||||||
if laststatus == 3 then
|
local not_selectable = vim.tbl_filter(function(id)
|
||||||
local ok_status, statusline = pcall(api.nvim_win_get_option, tree_winid, "statusline")
|
return not vim.tbl_contains(selectable, id)
|
||||||
local ok_hl, winhl = pcall(api.nvim_win_get_option, tree_winid, "winhl")
|
end, win_ids)
|
||||||
|
|
||||||
win_opts[tree_winid] = {
|
if laststatus == 3 then
|
||||||
|
for _, win_id in ipairs(not_selectable) do
|
||||||
|
local ok_status, statusline = pcall(api.nvim_win_get_option, win_id, "statusline")
|
||||||
|
local ok_hl, winhl = pcall(api.nvim_win_get_option, win_id, "winhl")
|
||||||
|
|
||||||
|
win_opts[win_id] = {
|
||||||
statusline = ok_status and statusline or "",
|
statusline = ok_status and statusline or "",
|
||||||
winhl = ok_hl and winhl or "",
|
winhl = ok_hl and winhl or "",
|
||||||
}
|
}
|
||||||
|
|
||||||
api.nvim_win_set_option(tree_winid, "statusline", " ")
|
-- Clear statusline for windows not selectable
|
||||||
api.nvim_win_set_option(tree_winid, "winhl", "StatusLine:NvimTreeWindowPicker")
|
api.nvim_win_set_option(win_id, "statusline", " ")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup UI
|
-- Setup UI
|
||||||
@@ -106,13 +112,19 @@ local function pick_window()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if laststatus == 3 then
|
if laststatus == 3 then
|
||||||
for opt, value in pairs(win_opts[tree_winid]) do
|
for _, id in ipairs(not_selectable) do
|
||||||
api.nvim_win_set_option(tree_winid, opt, value)
|
for opt, value in pairs(win_opts[id]) do
|
||||||
|
api.nvim_win_set_option(id, opt, value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.o.laststatus = laststatus
|
vim.o.laststatus = laststatus
|
||||||
|
|
||||||
|
if not vim.tbl_contains(vim.split(M.window_picker.chars, ""), resp) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
return win_map[resp]
|
return win_map[resp]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -168,7 +180,11 @@ function M.fn(mode, filename)
|
|||||||
if not M.window_picker.enable or mode == "edit_no_picker" then
|
if not M.window_picker.enable or mode == "edit_no_picker" then
|
||||||
target_winid = lib.target_winid
|
target_winid = lib.target_winid
|
||||||
else
|
else
|
||||||
target_winid = pick_window()
|
local pick_window_id = pick_window()
|
||||||
|
if pick_window_id == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
target_winid = pick_window_id
|
||||||
end
|
end
|
||||||
|
|
||||||
if target_winid == -1 then
|
if target_winid == -1 then
|
||||||
|
|||||||
Reference in New Issue
Block a user