copnfigure folding
This commit is contained in:
parent
b9d9f7e264
commit
0685135ccf
3 changed files with 89 additions and 2 deletions
|
|
@ -41,14 +41,43 @@ return {
|
|||
jumpBot = ']',
|
||||
},
|
||||
},
|
||||
-- Custom fold text showing line count
|
||||
fold_virt_text_handler = function(virtText, lnum, endLnum, width, truncate)
|
||||
local newVirtText = {}
|
||||
local suffix = (' %d lines '):format(endLnum - lnum)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
local targetWidth = width - sufWidth
|
||||
local curWidth = 0
|
||||
|
||||
for _, chunk in ipairs(virtText) do
|
||||
local chunkText = chunk[1]
|
||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if targetWidth > curWidth + chunkWidth then
|
||||
table.insert(newVirtText, chunk)
|
||||
else
|
||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
local hlGroup = chunk[2]
|
||||
table.insert(newVirtText, {chunkText, hlGroup})
|
||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if curWidth + chunkWidth < targetWidth then
|
||||
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
|
||||
end
|
||||
break
|
||||
end
|
||||
curWidth = curWidth + chunkWidth
|
||||
end
|
||||
|
||||
table.insert(newVirtText, {suffix, 'MoreMsg'})
|
||||
return newVirtText
|
||||
end,
|
||||
},
|
||||
config = function(_, opts)
|
||||
-- Set fold settings for nvim-ufo
|
||||
vim.o.foldcolumn = '1' -- Show fold column
|
||||
vim.o.foldcolumn = '0' -- Hide fold column (we don't need it)
|
||||
vim.o.foldlevel = 99 -- Open all folds by default
|
||||
vim.o.foldlevelstart = 99 -- Open all folds when opening a file
|
||||
vim.o.foldenable = true -- Enable folding
|
||||
-- Use simple characters for fold indicators
|
||||
-- Use simple characters for fold indicators (though foldcolumn is hidden)
|
||||
vim.o.fillchars = [[eob: ,fold: ,foldopen:▼,foldsep: ,foldclose:▶]]
|
||||
|
||||
require('ufo').setup(opts)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue