Closed yongrenjie closed 3 years ago
I mainly opened this issue as I was curious as to whether this would be something you might be interested in including in vimtex. I'm happy to modify the output slightly if desired!
I don't quite see why not to add this. I think improving the fold text for bib files should generally be a good thing for most people, and it seems relevant to VimTeX. If it would be opinionated, then we could easily make it optional.
Do you want to open a PR for this? I could add this based on your implementation myself, but if you feel adventurous and want to keep your name on the contribution, then I wouldn't mind helping you with a PR.
I don't mind trying to put a PR together! Before I start, let me consult you about the strategy...
autoload/vimtex/fold/bib.vim
.vimtex#fold#init
function to check for &filetype
. (and remove 'fold'
from the disabled modules for bib files).g:vimtex_fold_bib_enabled
, defaulting to 1?I don't mind trying to put a PR together! Before I start, let me consult you about the strategy...
Ah, yes, I can see how it is somewhat confusing how to integrate this in the current init flow. The code did not really consider bib files, so bib file support is sort of "hackish".
My suggestion would be to make it simple, something like this:
Add minimal init code here:
Something like this:
if g:vimtex_fold_bib_enabled
setlocal foldmethod=syntax
setlocal foldtext=vimtex#fold#bib#text()
endif
Add the bibtex foldtext function as vimtex#fold#bib#text()
in autoload/vimtex/fold/bib.vim
.
Add some related words in the docs (under :help vimtex-folding
and document the option).
This would keep the main new code separated from other unrelated code, which I think is good. Then I might do some code maintenance and restructuring afterwards.
Does this make sense to you?
Closed by #2066!
I forgot about this issue; thanks for remembering and closing it! :)
Is your feature request related to a problem? Please describe it.
Setting
foldmethod=syntax
in bib files (provided by vim8.2's built in syntax file) gives nice folding, but the default fold text is a bit dull. For example (stealing a paper from my supervisor :-))produces the following foldtext
IMO, it's not useful to know how many lines an entry is; also, the remainder of the space could be more usefully utilised to show some information about the bib entry.
Describe the solution you'd like
For most bib entries I think the most useful piece of extra information would be the title (?) or for
@set{...}
, it would be useful to see which entries are contained within the set.I actually have an implementation of the foldtext function here: https://github.com/yongrenjie/abbotsbury.vim/blob/master/ftplugin/bib.vim which I use personally. For the same bib entry above it produces the following foldtext:
Describe alternatives you've considered
I mainly opened this issue as I was curious as to whether this would be something you might be interested in including in vimtex. I'm happy to modify the output slightly if desired!
The main alternative would be sticking with the default, I guess. There might be an argument that long fold texts lead to visual clutter.