diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index c2d4cda..0140c53 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -37,6 +37,7 @@ M.defaults = { ui = { -- a number <1 is a percentage., >1 is a fixed size size = { width = 0.8, height = 0.8 }, + wrap = true, -- wrap the lines in the ui -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|. border = "none", icons = { diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index ac64e74..efdb75e 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -52,6 +52,15 @@ function M.create() ---@cast self LazyView Float.init(self) + 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" + else + vim.wo[self.win].wrap = false + end + require("lazy.view.colors").setup() self.state = vim.deepcopy(default_state) diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index d0cf458..e4f4529 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -127,13 +127,13 @@ function M:title() if self.view.state.mode == mode.name then if mode.name == "home" then - self:append(title, "LazyH1") + self:append(title, "LazyH1", { wrap = true }) else - self:append(title, "LazyButtonActive") + self:append(title, "LazyButtonActive", { wrap = true }) self:highlight({ ["%(.%)"] = "LazySpecial" }) end else - self:append(title, "LazyButton") + self:append(title, "LazyButton", { wrap = true }) self:highlight({ ["%(.%)"] = "LazySpecial" }) end self:append(" ") diff --git a/lua/lazy/view/text.lua b/lua/lazy/view/text.lua index 00c081a..5351db4 100644 --- a/lua/lazy/view/text.lua +++ b/lua/lazy/view/text.lua @@ -21,7 +21,7 @@ end ---@param str string ---@param hl? string|Extmark ----@param opts? {indent?: number, prefix?: string} +---@param opts? {indent?: number, prefix?: string, wrap?: boolean} function Text:append(str, hl, opts) opts = opts or {} if #self._lines == 0 then @@ -39,7 +39,13 @@ function Text:append(str, hl, opts) if l > 1 then self:nl() end - if str ~= "" and self:col() > 0 and self:col() + vim.fn.strwidth(line) + self.padding > self.wrap then + if + Config.options.ui.wrap + and opts.wrap + and str ~= "" + and self:col() > 0 + and self:col() + vim.fn.strwidth(line) + self.padding > self.wrap + then self:nl() end table.insert(self._lines[#self._lines], {