mirror of https://github.com/folke/lazy.nvim.git
fix(ui): properly wrap ui elements on small screens. Fixes #92
This commit is contained in:
parent
c0c2e1bd68
commit
3415a61789
|
@ -122,7 +122,7 @@ function M.show(mode)
|
||||||
callback = close,
|
callback = close,
|
||||||
})
|
})
|
||||||
|
|
||||||
local render = Render.new(buf, win, 2)
|
local render = Render.new(buf, win, 2, opts.width)
|
||||||
local update = Util.throttle(Config.options.ui.throttle, function()
|
local update = Util.throttle(Config.options.ui.throttle, function()
|
||||||
if buf and vim.api.nvim_buf_is_valid(buf) then
|
if buf and vim.api.nvim_buf_is_valid(buf) then
|
||||||
vim.bo[buf].modifiable = true
|
vim.bo[buf].modifiable = true
|
||||||
|
|
|
@ -19,11 +19,12 @@ local Text = require("lazy.view.text")
|
||||||
---@field _details? string
|
---@field _details? string
|
||||||
local M = setmetatable({}, { __index = Text })
|
local M = setmetatable({}, { __index = Text })
|
||||||
|
|
||||||
function M.new(buf, win, padding)
|
function M.new(buf, win, padding, wrap)
|
||||||
local self = setmetatable({}, { __index = M })
|
local self = setmetatable({}, { __index = M })
|
||||||
self.buf = buf
|
self.buf = buf
|
||||||
self.win = win
|
self.win = win
|
||||||
self.padding = padding or 0
|
self.padding = padding or 0
|
||||||
|
self.wrap = wrap
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ local Config = require("lazy.core.config")
|
||||||
---@class Text
|
---@class Text
|
||||||
---@field _lines TextSegment[][]
|
---@field _lines TextSegment[][]
|
||||||
---@field padding number
|
---@field padding number
|
||||||
|
---@field wrap number
|
||||||
local Text = {}
|
local Text = {}
|
||||||
|
|
||||||
function Text.new()
|
function Text.new()
|
||||||
|
@ -37,6 +38,9 @@ function Text:append(str, hl, opts)
|
||||||
if l > 1 then
|
if l > 1 then
|
||||||
self:nl()
|
self:nl()
|
||||||
end
|
end
|
||||||
|
if self:col() > 0 and self:col() + vim.fn.strwidth(line) + self.padding > self.wrap then
|
||||||
|
self:nl()
|
||||||
|
end
|
||||||
table.insert(self._lines[#self._lines], {
|
table.insert(self._lines[#self._lines], {
|
||||||
str = line,
|
str = line,
|
||||||
hl = hl,
|
hl = hl,
|
||||||
|
|
Loading…
Reference in New Issue