diff --git a/README.md b/README.md index 802df8e..4f32a7d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Requires Neovim >= 0.10. ![image](https://user-images.githubusercontent.com/31730729/230627808-de0b1e97-116d-4016-b4ba-cb709dfcd980.png) -_Status column containing a fold column without fold depth digits, a custom sign segment that will only show diagnostic signs, a number column with right aligned relative numbers and a sign segment that is only 1 cell wide that shows all other signs._ +_Status column containing a fold column without fold depth digits, a custom sign segment that will only show diagnostic signs, a number column with right aligned relative numbers and a sign segment that is only 1 cell wide that shows all other signs. ## Install @@ -124,6 +124,7 @@ Each segment can contain the following elements: -- virtual or wrapped part of a line (when v:virtnum != 0). fillchar = " ", -- character used to fill a segment with less signs than maxwidth fillcharhl = nil, -- highlight group used for fillchar (SignColumn/CursorLineSign if omitted) + foldclosed = false, -- when true, show signs from lines in a closed fold on the first line } } ``` diff --git a/lua/statuscol.lua b/lua/statuscol.lua index ceb5cc8..42ded9d 100644 --- a/lua/statuscol.lua +++ b/lua/statuscol.lua @@ -141,19 +141,31 @@ end --- Place signs with sign text in sign segments. local function place_signs(win, signs) + local lines = {} for i = 1, #signs do local s = signs[i][4] if not s.sign_text then goto nextsign end + local name = s.sign_name or s.sign_text if not s.sign_hl_group then s.sign_hl_group = "NoTexthl" end if not s.sign_name then name = name..s.sign_hl_group end if not sign_cache[name] then sign_cache_add(win, s, name) end local sign = sign_cache[name] if not sign.segment then goto nextsign end + local ss = signsegments[sign.segment] local wss = ss.wins[win] local sss = wss.signs local lnum = signs[i][2] + 1 + + if ss.foldclosed then + if not lines[lnum] then lines[lnum] = f.foldclosed(lnum) end + if lines[lnum] > 0 then + lnum = lines[lnum] + for j = lnum, f.foldclosedend(lnum) do lines[j] = lnum end + end + end + if not sss[lnum] then sss[lnum] = {} end -- Insert by priority. Potentially remove when nvim_buf_get_extmarks() can return sorted list. for j = 1, ss.maxwidth do @@ -323,6 +335,7 @@ function M.setup(user) ss.maxwidth = ss.maxwidth or 1 ss.colwidth = ss.colwidth or 2 ss.fillchar = ss.fillchar or " " + ss.foldclosed = ss.foldclosed or false if ss.fillcharhl then ss.fillcharhl = "%#"..ss.fillcharhl.."#" end if setscl ~= false then setscl = true end if not segment.text then segment.text = {builtin.signfunc} end