Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Use fold to hide .line #3

Open
nemanjan00 opened this issue Oct 14, 2021 · 0 comments
Open

FR: Use fold to hide .line #3

nemanjan00 opened this issue Oct 14, 2021 · 0 comments

Comments

@nemanjan00
Copy link

Hello,
I hacked together a simple fold config for easier reading. It hides .line...

I was thinking you might have some use for it for this plugin

function! SkipLineFoldExpr(lnum)
	let nextline = trim(getline(a:lnum + 1))
	let curline = trim(getline(a:lnum))

	" fold begins at {$ or one line before }$
	if curline[0:4] == '.line' || (curline == '' && nextline[0:4] == '.line')
	"if curline[0:4] == '.line' || nextline[0:4] == '.line'
		return 1
	endif

	" fold ends one line after {$ or at }$
	if curline[0:4] != '.line'
		return 0
	endif

	return 0
endfunction

function! SkipLineFoldText()
	" fold text matches non-empty line
	"return getline(v:foldstart)
	return ''
endfunction

" customize how fold is defined
set foldexpr=SkipLineFoldExpr(v:lnum)

" customize how fold looks like
set foldtext=SkipLineFoldText()

" use 'foldexpr'
set foldmethod=expr

set foldenable
set foldclose=all
set foldopen=all
set foldlevel=0

set fillchars=fold:\ 

highlight clear Folded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant