Skip to content

Commit a7ba7ef

Browse files
Merge pull request #60 from rahulsalvi/better-foldtext
2 parents 72989e1 + 8edd747 commit a7ba7ef

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

indent/org.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ function! OrgmodeIndentExpr()
66
return luaeval('require("orgmode.org.indent").indentexpr()')
77
endfunction
88

9+
function! OrgmodeFoldText()
10+
return luaeval('require("orgmode.org.indent").foldtext()')
11+
endfunction
12+
913
setlocal foldmethod=expr
1014
setlocal foldexpr=OrgmodeFoldExpr()
11-
setlocal foldtext=getline(v:foldstart)
15+
setlocal foldtext=OrgmodeFoldText()
1216
setlocal indentexpr=OrgmodeIndentExpr()
1317
setlocal foldlevel=0
1418
setlocal nolisp

lua/orgmode/org/indent.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@ local function indentexpr()
6363
return vim.fn.indent(prev_line)
6464
end
6565

66+
local function foldtext()
67+
local line = vim.fn.getline(vim.v.foldstart)
68+
if config.org_hide_leading_stars then
69+
return vim.fn.substitute(line, '\\(^\\**\\)', '\\=repeat(" ", len(submatch(0))-1) . "*"', '')
70+
end
71+
return line
72+
end
73+
6674
return {
6775
foldexpr = foldexpr,
6876
indentexpr = indentexpr,
77+
foldtext = foldtext,
6978
}

0 commit comments

Comments
 (0)