how to have foldtext() for each filetype, because each filetype has a different kind of fold so multiple foldtext() in
vimrcand enable for each filetype.
I'm thinking about multiple foldtext() functions in
vimrcand enable that
customfunc()to foldtext() via
thatfiletype. Is it possible and how would be an elegant way to achieve this?
EDIT: from @D.BenKnobl comment, I make it more visual, I'm not good with VimL and still the examples are pretty clear, I still need some clarification, so I'll add what I think and do here:
vim files in
/after/ftplugin will alter the default behavior of vim filetype or append function. Because I don't see the calling of function in
folding.vim, I understand that
vim will automatically recognize that
folding.vim contains all things for foldtext() or the whole file is foldtext() function and will be overwritten or alter the default foldtext() function for that filetype.
vim/after/ftplugin/markdown/folding.vim I see
MarkdownFoldText function that make firm about above conclusion. Basically
setlocal foldtext(), define
let b:undo_ftplugin once leave that filetype with set local foldtext to
<. Do I understand that correct?
So as my understanding, I should put foldtext() in
vim/after/ftplugin/rust.vim like below:
if exists('b:undo_ftplugin') let b:undo_ftplugin .= ' | ' else let b:undo_ftplugin = '' endif " This is where my local foldtext() function for rust.vim foldtext() <...> if !exists("*MyRustFtpluginUndo") function MyCFtpluginUndo() setlocal tags< setlocal path< silent! nunmap <buffer> <LocalLeader>tr endfunction endif let b:undo_ftplugin .= 'call MyRustFtpluginUndo()'