Skip to content

Commit

Permalink
fix(views): don't override winbar and foldenable for every view
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 12, 2023
1 parent dad4d61 commit a7d60f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lua/noice/config/views.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ M.defaults = {
-- min_width = 10,
},
win_options = {
winbar = "",
foldenable = false,
cursorline = true,
cursorlineopt = "line",
winhighlight = {
Expand Down Expand Up @@ -111,6 +113,8 @@ M.defaults = {
},
win_options = {
winhighlight = { Normal = "NoicePopup", FloatBorder = "NoicePopupBorder" },
winbar = "",
foldenable = false,
},
},
hover = {
Expand Down Expand Up @@ -176,6 +180,8 @@ M.defaults = {
},
zindex = 60,
win_options = {
winbar = "",
foldenable = false,
winblend = 30,
winhighlight = {
Normal = "NoiceMini",
Expand Down Expand Up @@ -213,6 +219,8 @@ M.defaults = {
CurSearch = "",
Search = "",
},
winbar = "",
foldenable = false,
cursorline = false,
},
},
Expand Down Expand Up @@ -241,6 +249,8 @@ M.defaults = {
Normal = "NoiceConfirm",
FloatBorder = "NoiceConfirmBorder",
},
winbar = "",
foldenable = false,
},
},
}
Expand Down
12 changes: 12 additions & 0 deletions lua/noice/util/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ function M.tag(buf, tag)
end
end

---@param win window
---@param options table<string, any>
function M.wo(win, options)
for k, v in pairs(options) do
if vim.api.nvim_set_option_value then
vim.api.nvim_set_option_value(k, v, { scope = "local", win = win })
else
vim.wo[win][k] = v
end
end
end

function M.debounce(ms, fn)
local timer = vim.loop.new_timer()
return function(...)
Expand Down
4 changes: 1 addition & 3 deletions lua/noice/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ function View:content()
end

function View:set_win_options(win)
vim.wo[win].winbar = ""
vim.wo[win].foldenable = false
if self._opts.win_options then
require("nui.utils")._.set_win_options(win, self._opts.win_options)
Util.wo(win, self._opts.win_options)
end
-- reset cursor on show
vim.api.nvim_win_set_cursor(win, { 1, 0 })
Expand Down

0 comments on commit a7d60f7

Please sign in to comment.