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)
|
||||
|
|
|
|||
|
|
@ -41,3 +41,32 @@ vim.opt.tabstop = 4 -- Display tabs as 4 spaces
|
|||
vim.opt.shiftwidth = 4 -- Indent by 4
|
||||
vim.opt.softtabstop = 4 -- Backspace removes 4 spaces
|
||||
vim.opt.expandtab = true -- Use spaces by default (overridden per-filetype)
|
||||
|
||||
-- LSP diagnostics configuration
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
spacing = 4,
|
||||
prefix = '●',
|
||||
-- Show severity (ERROR, WARN, INFO, HINT)
|
||||
format = function(diagnostic)
|
||||
return string.format("%s: %s", diagnostic.source or "", diagnostic.message)
|
||||
end,
|
||||
},
|
||||
signs = true, -- Keep signs in signcolumn
|
||||
underline = true, -- Underline problematic text
|
||||
update_in_insert = false, -- Don't update diagnostics while typing
|
||||
severity_sort = true, -- Sort by severity (errors first)
|
||||
float = {
|
||||
border = 'rounded',
|
||||
source = 'always', -- Show diagnostic source
|
||||
header = '',
|
||||
prefix = '',
|
||||
},
|
||||
})
|
||||
|
||||
-- Diagnostic signs in signcolumn
|
||||
local signs = { Error = "E", Warn = "W", Hint = "H", Info = "I" }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue