diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua index 11b8182..c5c64a1 100644 --- a/lua/lazy/util.lua +++ b/lua/lazy/util.lua @@ -10,6 +10,14 @@ function M.float(opts) return require("lazy.view.float")(opts) end +function M.wo(win, k, v) + 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 + function M.open(uri) if M.file_exists(uri) then return M.float({ style = "", file = uri }) @@ -180,9 +188,9 @@ function M.markdown(msg, opts) vim.tbl_deep_extend("force", { title = "lazy.nvim", on_open = function(win) - vim.wo[win].conceallevel = 3 - vim.wo[win].concealcursor = "n" - vim.wo[win].spell = false + M.wo(win, "conceallevel", 3) + M.wo(win, "concealcursor", "n") + M.wo(win, "spell", false) vim.treesitter.start(vim.api.nvim_win_get_buf(win), "markdown") end, diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua index cddcfa6..a879640 100644 --- a/lua/lazy/view/float.lua +++ b/lua/lazy/view/float.lua @@ -1,5 +1,6 @@ local Config = require("lazy.core.config") local ViewConfig = require("lazy.view.config") +local Util = require("lazy.util") ---@class LazyFloatOptions ---@field buf? number @@ -124,12 +125,12 @@ function M:mount() local function opts() vim.bo[self.buf].bufhidden = self.opts.persistent and "hide" or "wipe" - vim.wo[self.win].conceallevel = 3 - vim.wo[self.win].foldenable = false - vim.wo[self.win].spell = false - vim.wo[self.win].wrap = true - vim.wo[self.win].winhighlight = "Normal:LazyNormal" - vim.wo[self.win].colorcolumn = "" + Util.wo(self.win, "conceallevel", 3) + Util.wo(self.win, "foldenable", false) + Util.wo(self.win, "spell", false) + Util.wo(self.win, "wrap", true) + Util.wo(self.win, "winhighlight", "Normal:LazyNormal") + Util.wo(self.win, "colorcolumn", "") end opts() diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index b7e7a84..93611e2 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -57,12 +57,11 @@ function M.create() }) if Config.options.ui.wrap then - vim.wo[self.win].wrap = true - vim.wo[self.win].linebreak = true - vim.wo[self.win].breakindent = true - -- vim.wo[self.win].breakindentopt = "shift:8" + Util.wo(self.win, "wrap", true) + Util.wo(self.win, "linebreak", true) + Util.wo(self.win, "breakindent", true) else - vim.wo[self.win].wrap = false + Util.wo(self.win, "wrap", false) end self.state = vim.deepcopy(default_state)