preservim / vim-pencil

Rethinking Vim as a tool for writing
Other
1.57k stars 38 forks source link

How disable line wrap in front matter (for Hugo or Jekyll) #92

Closed apoutchika closed 1 year ago

apoutchika commented 4 years ago

Hi,

When use front matter in markdown file :

---
Author: Test
Description: Test
---

# Test

If i try to update or add parameters in front matter, Pencil remove all new line :

Try to add Title Between Autor and Description :

--- Author: Test Title Description: Test ---

# Test

How to disable this only for this part ?

antgel commented 3 years ago

Thanks for opening this. I too would love to know. Currently I'm manually disabling Pencil, and it's quite annoying.

alerque commented 3 years ago

I don't think VIM supports region based wrap settings at all. If anybody knows of any language or plugin that supports this please mention it here and we can look into how they did it, but off the top of y head this may not be possible.

reedes commented 1 year ago

I've recently started using Jekyll and see that it's using "yaml" prefixed highlight groups in the markdown headers.

These highlight groups can be identified (from the syntax files) and added to the pencil blacklist, to ensure that autoformat won't be enabled if entering insert mode in hard line break mode.

If I get a chance, I'll dig into this further.

antgel commented 1 year ago

@reedes Looking forward to hearing what you find; I just found this issue and I didn't know what I had been doing wrong! By the way, why is Pencil doing this at all? What's the intention? Is it that it thinks the lines should be wrapped into one paragraph because there is no blank line between them?

reedes commented 1 year ago

A minor error in my regex. I'll look at getting it fixed in the next few days and will generate a fresh pull request.

(The recent merged request shouldn't break anything, so no need to revert it.)

antgel commented 1 year ago

@reedes Thanks so much for this, amazing how such a small code change can have such a big impact!