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

Add conceal support for \(sub)*sections #2022

Closed
wants to merge 6 commits into from

Conversation

lervag
Copy link
Owner

@lervag lervag commented Apr 6, 2021

See #1978 for context.

Some things to discuss before merging:

  • This direction of conceals is full of edge cases. For instance, how should we treat \chapter? I would perhaps claim we should only allow this particular type of concealment to the specific family \(sub)*section.

  • I suspect this conceal feature will be much more opinionated. Perhaps it should be off by default? If so, then the g:vimtex_syntax_conceal_default becomes "obsolete", but it might have been a bad way to customize things anyways. Perhaps it is better to show the defaults explicitly, allow some defaults to be off, and instead add g:vimtex_syntax_conceal_disable to make it easy to disable all conceal features for whomever wants that.

  • And, of course: is the current implementation satisfactory?

@mawkler
Copy link

mawkler commented Apr 7, 2021

Looks good! Your conceal implementation looks way cleaner than my proof of concept hehe.

how should we treat \chapter?

I personally don't use \chapter{} so perhaps I shouldn't be the one answering this, but perhaps it simply shouldn't be concealed like you suggest, or it could be concealed like \section{} but with another symbol than #, for instance §. I.e. \chapter{Test} would be concealed into § Test.

Perhaps it should be off by default?

I agree.

If so, then the g:vimtex_syntax_conceal_default becomes "obsolete"

Yeah I think g:vimtex_syntax_conceal is a perfectly fine way to control the conceals. You could write out its default values in the docs, for instance:

g:vimtex_syntax_conceal = {
  \ 'styles': 1,
  \ 'accents': 1,
  \ 'greek': 1,
  \ 'math_fracs': 1,
  \ 'math_symbols': 1,
  \ 'math_super_sub': 1,
  \ 'cites': 1,
  \ 'fancy': 1,
  \ 'sections': 0,
  \ 'math_delimiters': 1,
  \ 'math_bounds': 1
  \ }

Adding g:vimtex_syntax_conceal_disable makes sense to me too.

@lervag lervag force-pushed the feat/syntax-section-conceal branch from 948f04b to 3c514ed Compare April 7, 2021 20:40
@lervag
Copy link
Owner Author

lervag commented Apr 7, 2021

Thanks for your thoughts. I've pushed corresponding updates now. I propose to merge this, but I would be happy to hear a second opinion. Not sure if there may be "lurkers" reading this that would be interested in commenting? :)

@Schmiddiii
Copy link

Hi, random "lurker" here.
This seems pretty good, but I still have some ideas for minor improvements.

First consider \section*{Title}. This is currently concealed as # * Title.
Would it be possible to leave out the * as I think this information is not neccessary.
In my experience, either all sections are section or section*, not a mix.
This of course also applies for all (sub)*sections.

My next request is a conceal for label, as many (sub)*sections have a label beneath.
This is for example the case in the snippets for Ultisnips here.
This could either be integrated into the (sub)*section conceal (if possible), e.g. # Title (label), or be a new conceal, e.g.

# Title
↪ label

My last request would be the (sub)*paragraph.
The current conceal of \paragraph{Text} is \paragraph Text (just left out the {}).
This probably might be improved, but I have no idea how to conceal it.
To my information, makrdown does not have any character for a paragraph.
Also consider paragraph*. This is currently not concealed at all.
This is inconsistent and should probably be changed.

@lervag
Copy link
Owner Author

lervag commented Apr 15, 2021

Hi, random "lurker" here.

Great, happy to "meet" you :)

First consider \section*{Title}. ...
In my experience, either all sections are section or section*, not a mix.

I've mixed things several times. Typically with things like adding a \section*{Acknowledgement}. However, I also tend to agree that the # * does not look so good, so I can agree on simply hiding the star as well.

My next request is a conceal for label, as many (sub)*sections have a label beneath.
This is for example the case in the snippets for Ultisnips here.
This could either be integrated into the (sub)*section conceal (if possible), e.g. # Title (label), or be a new conceal, e.g.

Unfortunately, this may be more tricky: 1) I don't think we can conceal multiple lines, and 2) conceals generally only allow to conceal a single "matched part/region" with a single character. More complex conceals are all "hacks" that combine syntax rules in more or less twisted ways. :\

My last request would be the (sub)*paragraph.
The current conceal of \paragraph{Text} is \paragraph Text (just left out the {}).

Ah, that was actually an unintended side effect; a bug. Thanks for reporting. I'll revert this immediately.

lervag added a commit that referenced this pull request Apr 15, 2021
@lervag lervag force-pushed the feat/syntax-section-conceal branch from 54caebe to d8a1e54 Compare October 9, 2021 14:39
lervag added a commit that referenced this pull request Oct 9, 2021
@lervag
Copy link
Owner Author

lervag commented Oct 9, 2021

I'm sorry about the delay here; I've merged this now.

@lervag lervag closed this Oct 9, 2021
@lervag lervag deleted the feat/syntax-section-conceal branch October 9, 2021 14:52
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

Successfully merging this pull request may close these issues.

4 participants