Fold TOC #117

Closed
petobens opened this Issue Sep 2, 2013 · 13 comments

Projects

None yet

2 participants

@petobens
petobens commented Sep 2, 2013

Is it possible to add a feature to fold table of contents. Thanks

@lervag lervag added a commit that referenced this issue Sep 9, 2013
@lervag lervag Added folding of TOC (#117)
The TOC can be folded by setting g:LatexBox_fold_toc = 1.
9218dd2
@lervag
lervag commented Sep 9, 2013

I added folding of TOC. Set g:LatexBox_fold_toc = 1 in your vimrc file, and it should work.

Note that I only added one level of folds. I think this should suffice, but let me know if you disagree. I also did not change the text of the folds, which could be of interest.

@lervag lervag closed this Sep 9, 2013
@petobens
petobens commented Sep 9, 2013

Brilliant, thanks! I think that showing the number of lines in the text of the fold doesn't look nice so I if you could change that it would be great :-) If you could add two more levels that would also be cool (so for instance one could fold chapter, sections and subsections but not subsubsections). One last improvement could also be to add variable that allows the user to control the foldlevel. Thanks for a great plugin!

@petobens
petobens commented Sep 9, 2013

Ahhh and one minor thing , maybe you could introduce variable that allows to hide (or show) the toc help (the close, jump, jump and close and hide numbering part). Thank you once again!

@lervag lervag added a commit that referenced this issue Sep 9, 2013
@lervag lervag Added option to hide TOC help text
Feature requested in #117

The option name is g:LatexBox_toc_hidehelp, and if this is
nonzero, the help text will be hidden.
ec4554c
@lervag lervag added a commit that referenced this issue Sep 9, 2013
@lervag lervag Some modifications of TOC folding
Addresses #117

Added option g:LatexBox_fold_toc_levels to set number of levels to fold (max
3). Also added foldtext function.
4bb3f37
@lervag
lervag commented Sep 9, 2013

Done. I think my latest updates addresses all of your ideas.

@petobens
petobens commented Sep 9, 2013

Wowww that was incredibly quick! Thanks! One last idea, the fold text could have a tree-like appearance similar to NerdTree/vimfiler/tagbar? This is probably hard to implement but maybe you could add the following icons depending whether the fold is open or closed (or some other icon showing the "fold level"):

let g:latex_box_toc_iconchars = ['▸', '▾']

and some indentation to each fold level? This would somehow mimic PDF bookmarks rendering of chapter,sections,etc.

Here is an image of vimfiler (similar to NerdTree):
vimfilerfolding

@lervag
lervag commented Sep 9, 2013

It is an interesting idea, but I think I will have to disappoint you. This is for two reasons, the first being the main one:

  1. This feature would change how the TOC would look like without folds. Personally, I don't find the folds necessary and I like the appearance with section numbers as they look now.
  2. I think this will be hard to implement.

However, I am very happy to contribute with updates, and if you have other good ideas and suggestions, please open new issues! :)

@petobens
petobens commented Sep 9, 2013

Thank you! I''ll open a new issue if I have any other idea. However, Latex-Box is excellent the way it already is :)

@petobens
petobens commented Sep 9, 2013

I'm sorry to disturb you again but I found a behavior that is probably a feature but I was wondering whether it could change. If I have a folded section (in the text) and I click the corresponding section in the TOC it will not open the fold containing it, and one has to manually open each fold. I think that if Line 98 in latexbox/ftplugin/latextoc.vim is changed from

normal zt

to

normal zv

my desired behavior is obtained.

@petobens
petobens commented Sep 9, 2013

I promise that this will be last comment. I think that the syntax highlighting pattern of SecLine doesn't take into account spaces. The following image shows the problem (the buffer on the right is my colorscheme with the corresponding changes done to the syntax highlight groups). If you want I can open a new issue but since all my comments are TOC-related I thought that I could comment in this thread.
tocsyntax

@lervag
lervag commented Sep 10, 2013

I'd prefer if you opened a new issue, actually. I'll have a look at the fold comment later today, but I might not have time to look at the SecLine issue today. I'm on holidays from tomorrow and until the end of the week, and I will not be near a computer at that time.

@lervag
lervag commented Sep 10, 2013

I agree that normal zv makes more sense than normal zt, and I have committed the change. As I said, please open a new issue for the other thing. :)

@lervag
lervag commented Sep 10, 2013

Ah, what the heck: The bug was easy to fix, so no need to open a new issue. But please do open new issues when you have them - it makes it better for future reference and similar.

@petobens

Thank you so much! I'm terribly sorry for not opening a new issue. I'll do it in the future. Thanks once again.

@petobens petobens referenced this issue in lervag/vimtex Aug 3, 2014
Closed

Open folds from TOC #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment