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

Vimwiki Markdown Blockquote Syntax issue #915

Closed
4 tasks done
mas-4 opened this issue Jun 16, 2020 · 9 comments
Closed
4 tasks done

Vimwiki Markdown Blockquote Syntax issue #915

mas-4 opened this issue Jun 16, 2020 · 9 comments

Comments

@mas-4
Copy link

mas-4 commented Jun 16, 2020

Prior to submitting a new issue make sure to complete these steps:

  • Checkout the dev branch and confirm the issue is present there as well.
    The dev branch contains fixes that may not have been merged to master yet.
  • Post the syntax you are using (default/mediawiki/markdown) and your vimwiki settings from your .vimrc
  • Provide a detailed description of the problem including steps to reproduce the issue.
  • Include the output of :VimwikiShowVersion.

Using markdown

" The vimwiki plugin tries to rewrite coc's tab auto-complete
let g:vimwiki_table_mappings = 0

" Make vimwiki markdown again
let g:vimwiki_list = [{'path': '~/vimwiki/',
                      \ 'syntax': 'markdown', 'ext': '.md'}]
let g:vimwiki_global_ext = 0

Output of :VimwikiShowVersion: Stable version: 2.5

Hi,
There's a functionality with Vim's native markdown syntax involving blockquotes whereby a blockquote of the form

> This is a quote and
> this is a continuation of the same quote.

can be joined and the result will be

> This is a quote and this is a continuation of the same quote.

Continuing to type and hard wrapping to the next line will automatically insert a new > for continuation, just like a comment in, say, Python.

Vimwiki does not abide by this syntax rule. To join the first line to the second (with a J command) results in:

> This is a quote and > this is a continuation of the same quote.

To be fair, I'm not sure how vimwiki interprets markdown blockquote syntax. It seems like they continue to use the 4 spaces for quotes syntax, as with vimwiki syntax, which I'd argue is specifically not markdown syntax.

I added let g:vimwiki_global_ext = 0 to my vimrc because I rely on markdown quotes in a variety of places, even outside vimwiki, and the vimwiki markdown syntax is demonstrably worse than the standard vimwiki syntax for this very reason. I would love to be able to use vimwiki's linking outside of vimwiki, and it's syntax support, but unless there is a way to fix this blockquote issue I cannot.

Thank you,
M.

@tinmarino
Copy link
Member

So you would like for markdown:

  1. Blockquote containuation when pressing i<Cr>
  2. Blockquote prefix removal when pressing J

You declare that it is vim default behavior for markdown. So you shoudl have this when remove packadd vimwiki from your vimrc. Idon't experience this. If you do: can you tell in which file the feature is implemented ? So that:

  1. we can copy that
  2. you can source this file and get the behavior you desire (say merge vimwiki.vim and syntax/markdown.vim behaviors).

@mas-4
Copy link
Author

mas-4 commented Jun 16, 2020

I apologize @tinmarino ! 99 times out of 100 neovim and vim operate identically, but apparently this is one instance where they do not.

Neovim does this by default. Not Vim. Wow, I had no idea Neovim had superior syntax behavior.

Unfortunately I do not know vimscript, in the least. I can link to the files that I think are a jumping off point, but I really don't know.

https://github.com/neovim/neovim/blob/master/runtime/syntax/markdown.vim
https://github.com/neovim/neovim/blob/master/runtime/ftplugin/markdown.vim

There are no other files specifically on markdown. I imagine that there's something that defines the > precursor to follow some kind of folding larger folding mechanism but it will take me a good long time to figure out how that works, not knowing the codebase or the language.

Apologies for the confusion!

@kejadlen
Copy link

kejadlen commented Jul 4, 2020

I have a related issue (let me know if I should open up a separate issue for this?) - when formatting blockquotes (gq{motion}), the behavior for a markdown filetype on my install (8.2) will prepend each line in the quoted paragraph with > , while vimwiki omits the leading > marker.

> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam faucibus rhoncus est sed facilisis. Sed imperdiet massa tellus, eu fermentum felis fringilla vel.

# vim markdown
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam faucibus rhoncus
> est sed facilisis. Sed imperdiet massa tellus, eu fermentum felis fringilla
> vel.

# vimwiki
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam faucibus rhoncus
est sed facilisis. Sed imperdiet massa tellus, eu fermentum felis fringilla
vel.

Interestingly enough, it looks like the markdown files in vim are more recent than the ones in neovim?

https://github.com/vim/vim/blob/master/runtime/syntax/markdown.vim
https://github.com/vim/vim/blob/master/runtime/ftplugin/markdown.vim

tinmarino added a commit to tinmarino/vimwiki that referenced this issue Jul 26, 2020
…sue vimwiki#915)

Wrap: autoadd a new `> ` on new create lines with `setlocal comments+=n:>`
Join: autoremove the inter `> ` with  `setlocal formatoptions+=j`
@tinmarino
Copy link
Member

Thank you very much for the details, both @kejadlen and @malan88. They were very helpfull : you did 90% of the analisys.

1 gqq

The solution for gqq to prepend new lines with > is in ftplugin/markdown (see :h format-comments)

# The line
setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=<!--%s-->
# What we want:
setlocal comments=n:>

Which should be copied in ftplugin/vimwiki

2 J

Just add j to formatoptions. I foudn the anszer in a vim issue (searching: comment join J) but it was in the doc I should learn to navigate (see :h fo-table /join)

Fixed

See the PR referencing this issue (the last non closed one)

@tinmarino
Copy link
Member

Note: formatoptions setting j was added in vim 7.3.541 see elexir issue

tinmarino added a commit to tinmarino/vimwiki that referenced this issue Jul 26, 2020
…sue vimwiki#915)

Wrap: autoadd a new `> ` on new create lines with `setlocal comments+=n:>`
Join: autoremove the inter `> ` with  `setlocal formatoptions+=j`
tinmarino added a commit to tinmarino/vimwiki that referenced this issue Jul 26, 2020
…sue vimwiki#915)

Wrap: autoadd a new `> ` on new create lines with `setlocal comments+=n:>`
Join: autoremove the inter `> ` with  `setlocal formatoptions+=j`
@tinmarino
Copy link
Member

Also next time, if you do not want to wait for a fix, add this to .vim/ftplugin/vimwiki or better .vim/after/ftplugin/vimwiki : to load markdown default conf

unlet b:did_ftplugin
source $VIMRUNTIME/ftplugin/markdown.vim

unlet b:current_syntax
source $VIMRUNTIME/ftplugin/markdown.vim

tinmarino added a commit to tinmarino/vimwiki that referenced this issue Jul 26, 2020
…sue vimwiki#915)

Wrap: autoadd a new `> ` on new create lines with `setlocal comments+=n:>`
Join: autoremove the inter `> ` with  `setlocal formatoptions+=j`
tinmarino added a commit to tinmarino/vimwiki that referenced this issue Jul 27, 2020
…sue vimwiki#915)

Wrap: autoadd a new `> ` on new create lines with `setlocal comments+=n:>`
Join: autoremove the inter `> ` with  `setlocal formatoptions+=j`
@kejadlen
Copy link

Thanks for the fix! I've switched to the dev branch to pick up the changes. 😉

deepredsky pushed a commit to deepredsky/vimwiki that referenced this issue Jan 16, 2021
…sue vimwiki#915)

Wrap: autoadd a new `> ` on new create lines with `setlocal comments+=n:>`
Join: autoremove the inter `> ` with  `setlocal formatoptions+=j`
@newptcai
Copy link

newptcai commented Jul 9, 2021

Has this been merged? I don't see any PR for it.

@tinmarino
Copy link
Member

Hi @newptcai, I think I pushed directly to dev branch

jls83 pushed a commit to jls83/vimwiki that referenced this issue Jan 17, 2023
…sue vimwiki#915)

Wrap: autoadd a new `> ` on new create lines with `setlocal comments+=n:>`
Join: autoremove the inter `> ` with  `setlocal formatoptions+=j`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants