mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
feat(statuscol): statuscolumn options for open fold indicator and fold hl (#2923)
* feat(statuscol): fold open indicator * fix: make it configurable --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
parent
d64d761539
commit
fa706b320b
2 changed files with 21 additions and 2 deletions
|
@ -19,6 +19,12 @@ vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" }
|
||||||
-- Set to false to disable.
|
-- Set to false to disable.
|
||||||
vim.g.lazygit_config = true
|
vim.g.lazygit_config = true
|
||||||
|
|
||||||
|
-- Options for the LazyVim statuscolumn
|
||||||
|
vim.g.lazyvim_statuscolumn = {
|
||||||
|
folds_open = false, -- show fold sign when fold is open
|
||||||
|
folds_githl = false, -- highlight fold sign with git sign color
|
||||||
|
}
|
||||||
|
|
||||||
-- Optionally setup the terminal to use
|
-- Optionally setup the terminal to use
|
||||||
-- This sets `vim.o.shell` and does some additional configuration for:
|
-- This sets `vim.o.shell` and does some additional configuration for:
|
||||||
-- * pwsh
|
-- * pwsh
|
||||||
|
|
|
@ -99,12 +99,18 @@ function M.statuscolumn()
|
||||||
|
|
||||||
local components = { "", "", "" } -- left, middle, right
|
local components = { "", "", "" } -- left, middle, right
|
||||||
|
|
||||||
|
local show_open_folds = vim.g.lazyvim_statuscolumn and vim.g.lazyvim_statuscolumn.folds_open
|
||||||
|
local use_githl = vim.g.lazyvim_statuscolumn and vim.g.lazyvim_statuscolumn.folds_githl
|
||||||
|
|
||||||
if show_signs then
|
if show_signs then
|
||||||
---@type Sign?,Sign?,Sign?
|
---@type Sign?,Sign?,Sign?
|
||||||
local left, right, fold
|
local left, right, fold, githl
|
||||||
for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do
|
for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do
|
||||||
if s.name and (s.name:find("GitSign") or s.name:find("MiniDiffSign")) then
|
if s.name and (s.name:find("GitSign") or s.name:find("MiniDiffSign")) then
|
||||||
right = s
|
right = s
|
||||||
|
if use_githl then
|
||||||
|
githl = s["texthl"]
|
||||||
|
end
|
||||||
else
|
else
|
||||||
left = s
|
left = s
|
||||||
end
|
end
|
||||||
|
@ -112,9 +118,16 @@ function M.statuscolumn()
|
||||||
if vim.v.virtnum ~= 0 then
|
if vim.v.virtnum ~= 0 then
|
||||||
left = nil
|
left = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_win_call(win, function()
|
vim.api.nvim_win_call(win, function()
|
||||||
if vim.fn.foldclosed(vim.v.lnum) >= 0 then
|
if vim.fn.foldclosed(vim.v.lnum) >= 0 then
|
||||||
fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" }
|
fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = githl or "Folded" }
|
||||||
|
elseif
|
||||||
|
show_open_folds
|
||||||
|
and not LazyVim.ui.skip_foldexpr[buf]
|
||||||
|
and vim.treesitter.foldexpr(vim.v.lnum):sub(1, 1) == ">"
|
||||||
|
then -- fold start
|
||||||
|
fold = { text = vim.opt.fillchars:get().foldopen or "", texthl = githl }
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
-- Left: mark or non-git sign
|
-- Left: mark or non-git sign
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue