mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 19:30:01 +02:00
nvim: ui: install nvim-ufo and statuscol.nvim for better folds and status column.
This commit is contained in:
parent
112b646bd4
commit
17676d62b9
2 changed files with 75 additions and 0 deletions
|
|
@ -19,6 +19,50 @@ return {
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'kevinhwang91/nvim-ufo',
|
||||
dependencies = {
|
||||
'kevinhwang91/promise-async',
|
||||
},
|
||||
opts = {
|
||||
fold_virt_text_handler = require("user.utils.ufo").foldtext
|
||||
}
|
||||
},
|
||||
{
|
||||
"luukvbaal/statuscol.nvim",
|
||||
opts = function()
|
||||
local builtin = require("statuscol.builtin")
|
||||
return {
|
||||
-- Align current relative number to the right.
|
||||
relculright = true,
|
||||
segments = {
|
||||
{
|
||||
click = "v:lua.ScSa",
|
||||
sign = {
|
||||
namespace = { "gitsigns" },
|
||||
maxwidth = 1,
|
||||
colwidth = 1,
|
||||
}
|
||||
},
|
||||
{
|
||||
click = "v:lua.ScSa",
|
||||
sign = {
|
||||
namespace = { "diagnostic/signs" },
|
||||
maxwidth = 1,
|
||||
colwidth = 3,
|
||||
-- auto = true,
|
||||
}
|
||||
},
|
||||
{
|
||||
text = { builtin.lnumfunc, " " },
|
||||
click = "v:lua.ScLa",
|
||||
},
|
||||
{ text = { builtin.foldfunc, " " }, click = "v:lua.ScFa" },
|
||||
{ text = { "│ " } },
|
||||
}
|
||||
}
|
||||
end,
|
||||
},
|
||||
-- File explorer
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
|
|
|
|||
31
nvim/lua/user/utils/ufo.lua
Normal file
31
nvim/lua/user/utils/ufo.lua
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
local M={}
|
||||
|
||||
M.foldtext = function(virtText, lnum, endLnum, width, truncate)
|
||||
local newVirtText = {}
|
||||
local suffix = (' --- %d '):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)
|
||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||
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
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue