preservim / vim-pencil

Rethinking Vim as a tool for writing
Other
1.59k stars 40 forks source link

View list of things concealed (or change) #101

Open folofjc opened 2 years ago

folofjc commented 2 years ago

I have read through the vim-pencil doc on concealing, as well as the help files in vim. I don't mind the concealing, but I would like to see what vim-pencil is concealing. For instance, before I used vim-pencil, vim-wiki would conceal some markup in my markdown files, but just things like bold, italic, links, etc.

Using vim-pencil with latex files also conceals these things, but also more. For instance, for some reason, vim-pencil is concealing both en dashes and em dashes. With the value of g:pencil#conceallevel at a default of 3, this means that it is concealed with nothing. Which is really odd for an en dash that separates two words.

Is there a way to turn off the concealing of certain things or to see what is concealed (and then change it?) I could not find such a list in the docs. I can of course turn off concealing, but I like it for bold and italic, etc, so I would prefer to keep it on.

alerque commented 2 years ago

Interesting question and we'd love to help you resolve this, but I am unable to replicate the issue. To my knowledge vim-pencil has no rules that would conceal en or em-dashes.

Are you sure you don't have another plugin that is doing that and causing some weird interference?

folofjc commented 2 years ago

Huh. Good point. The reason that I say that, is because if I turn off vim-pencil (:NoPencil), then en and em dashes are not concealed. If I turn vim pencil on (:Pencil), then they are.

It could very well be a conflict. But for tex files, things like vimwiki are not turned on. I don't have any other plugins that do any concealing as far as I know. If they are, they didn't tell me ;)

alerque commented 2 years ago

I take back what I said above, this plugin doesn't define it's own items to conceal but it does mess with how highlight groups (as defined by syntax plugins) interact with conceal.

What color scheme / syntax plugin(s) are you using? And what is your ft set to for when en/em dashes are getting concealed to nothing?

folofjc commented 2 years ago

I am using slate for the color scheme. I am using vim-latex, but as far as I am aware, it doesn't do syntax highlighting. I do have some personal syntax stuff in my ~/.vim/after/syntax/tex.vim to highlight some of my LaTeX aliases as LaTeX commands:

syn keyword footnote_h footnote containedin=texStatement
highlight link footnote_h Pmenu

syn keyword cite_h fc fcs Cite Cites footcite containedin=texStatement
highlight link cite_h DiffAdd

syn keyword hebgrk_h heb grk containedin=texStatement
highlight link hebgrk_h MoreMsg

syn keyword sect_h sect ssect sssect containedin=texStatement
highlight link sect_h texSection

syn keyword tq_h tq containedin=texStatement
highlight link tq_h Question

" Don't spell check these things
syntax match texStatement '\\heb' nextgroup=texMyCommand
syntax match texStatement '\\grk' nextgroup=texMyCommand
syntax match texStatement '\\fc' nextgroup=texMyCommandOpt
syntax region texMyCommand matchgroup=Delimiter start='{' end='}' contained contains=@NoSpell
syntax region texMyCommandOpt matchgroup=Delimiter start='\[' end='}' contained contains=@NoSpell

As far as I know, that is all I have for syntax.

What is ft? Filetype? They are .tex files. Also, when I say en dash and em dash, in LaTeX those look like -- and ---.

folofjc commented 2 years ago

Hi @alerque. So the en and em dash (-- and ---) are both being set as a syntax group of texLigature and the highlight group Special. I guess vim-pencil does something to the Special highlight group?

Okay, I found it. It is actually in vim. Here is the code

So vim sets this as a texLigature, and then vim-pencil just turns on the conceal I guess?

alerque commented 2 years ago

Yes, that makes sense as to why this is happening. I think we need to adjust something though because your example case is clearly an undesirable outcome. We make need to look into whether we can use finer grained control over what groups get concealed normally and which ones get concealed to nothing.

Thanks for tracking this down. I can't promise we can fix it, but we can look into whether it's possible to fix.

A temporary hack would be to add an au command to your rc file that removes those syntax groups for tex files after the default vim syntax loads.

folofjc commented 2 years ago

Yes, I agree that it is an undesirable behaviour. The other texLitagures (lines 1210-1218 in that code) also get concealed to nothing, and these are character accents. For instance, the German stra\ss e, which would be typset as straße, shows up as stra e with vim-pencil.