feat: added config.ui.wrap and improved wrapping when wrap=true. Fixes #422

This commit is contained in:
Folke Lemaitre 2023-01-19 08:45:27 +01:00
parent c389ad552b
commit d6fc848067
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
4 changed files with 21 additions and 5 deletions

View file

@ -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], {