feat(ui): fancy fold text

This commit is contained in:
Folke Lemaitre
2023-10-03 14:56:28 +02:00
parent 364bcf325d
commit f1ce07510d
3 changed files with 24 additions and 1 deletions

View File

@ -19,6 +19,9 @@ local defaults = {
},
-- icons used by other plugins
icons = {
misc = {
dots = "󰇘",
},
dap = {
Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" },
Breakpoint = "",

View File

@ -46,6 +46,15 @@ opt.updatetime = 200 -- Save swap file and trigger CursorHold
opt.wildmode = "longest:full,full" -- Command-line completion mode
opt.winminwidth = 5 -- Minimum window width
opt.wrap = false -- Disable line wrap
opt.fillchars = {
foldopen = "",
foldclose = "",
-- fold = "⸱",
fold = " ",
foldsep = " ",
diff = "",
eob = " ",
}
if vim.fn.has("nvim-0.10") == 1 then
opt.smoothscroll = true
@ -60,7 +69,9 @@ else
vim.opt.foldmethod = "indent"
end
if vim.treesitter.foldtext then
vim.opt.foldtext = "v:lua.vim.treesitter.foldtext()"
vim.opt.foldtext = "v:lua.require'lazyvim.util.ui'.foldtext()"
end
if vim.fn.has("nvim-0.9.0") == 1 then
vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util.ui'.statuscolumn()]]
end

View File

@ -21,6 +21,15 @@ function M.icon(sign, len)
return sign.texthl and ("%#" .. sign.texthl .. "#" .. text .. "%*") or text
end
function M.foldtext()
local ret = vim.treesitter.foldtext and vim.treesitter.foldtext()
if not ret then
ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } }
end
table.insert(ret, { " " .. require("lazyvim.config").icons.misc.dots })
return ret
end
function M.statuscolumn()
local win = vim.g.statusline_winid
if vim.wo[win].signcolumn == "no" then