Vimwiki: Weird <CR> behavior with markdown files

Created on 9 May 2017  Â·  5Comments  Â·  Source: vimwiki/vimwiki

Sorry, I'm not sure about how to name this issue, but the shortest way to describe could be: Vimwiki's <cr> behavior is being applied to all markdown files, not only those on the Wiki's path.

Now, in any markdown file, pressing <cr> will surround the word under the cursor with brackets. Pressing <cr> one more time on the word (which now is a link) will create the file on the current working directory, regardless it is the wiki's path or not.

Just did a PlugUpdate, and I believe I'm running the most recent version of Vimwiki (on Neovim).
And these are the lines of my init.vim related to Vimwiki:

Plug 'vimwiki/vimwiki'
let g:vimwiki_list = [{'path': '~/vimwiki/markdown/',
           \ 'syntax': 'markdown', 'ext': '.md'},
                   \ {'path': '~/vimwiki/wiki', 'ext': '.wiki'}]
let g:vimwiki_folding='list'
let g:vimwiki_use_calendar= 1

Background
I really like Vimwiki's markup, but quite often I need to convert a wiki file to markdown to be used as README on github or as post in Jekyll.

When I first applied the vimwiki_list to init.vim the first weird issue was that <cr> was not working at all. After some tests (and a couple of hours) I found out that if I comment out my own markdown ftplugin from init.vim, Vimwiki's <cr> works, and it is able to create and follow links. But then, it does the same for every single markdown file...

Markdumb is my first plugin, and it is totally understandable that I might have done something stupid out there. But since markdumb doesn't even touch <cr>, I don't know what could be wrong. I also remember that when I first started using Vimwiki, I needed to reimplement my mappings, since anything that Vimwiki wanted to use wouldn't work. No problem at all, I reeeeally like Vimwiki. And that's why I wanted to start to make a better use of it; by using two different wikis...

Sorry for the long text, I'm still not sure what is this issue about. But summarizing:

1) <cr> in markdown files if there is another markdown plugin active.
2) if there is no other markdown plugin, then <cr> creates and follows links where (AFAIK) it shouldn't
3) <cr> seems (to me) to have some incompatibility with something else, but I'm sure I have no other custom map for <cr>.

Anyway, thanks for the great job! :D

Most helpful comment

Short answer: use let g:vimwiki_global_ext = 0 to prevent this behavior.

vimwiki's default behavior is that if you open a file which

  • has an extension that is used in g:vimwiki_list, and
  • is not in the paths specified in g:vimwiki_list

then vimwiki creates a new wiki at the file's directory, and that file is treated as a wiki page (vimwiki's key-mapping gets applied). This behavior in controlled by the variable g:vimwiki_global_ext which is 1 (enabled) by default. Personally I think this should be disabled by default.

More details can be found at :h vimwiki-temporary-wiki and :h g:vimwiki_global_set .

p/s: only tested with .wiki extension but I'm pretty sure it's the same for all extensions.

All 5 comments

Same issue here. Vimwiki affects all markdown files on my system, too.
let g:vimwiki_list = [{'path': '~/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}]. Using Vim 8 and no other vimwiki settings set.

Yeah… I hadn't noticed this before, but sure enough.

If you open a markdown file, the filetype is markdown.

However, I am noticing that if I set the filetype to markdown rather than vimwiki, the enter still behaves the same. Interesting.

Imgur

I just had a hard time understanding what I have written on the first comment. But my doubts are:

  1. Why is <cr> not working with markdumb?
  2. Why does Vimwiki's default <cr> behavior does not work with markdown if there is another markdown filetype plugin?
  3. If there isn't another markdown filetype plugin, why would Vimwiki's default ` behavior be applied to every single markdown file?

I should probably mention that this is happening (in Neovim) even if Vimwiki is the only plugin available and without any further configuration...

Short answer: use let g:vimwiki_global_ext = 0 to prevent this behavior.

vimwiki's default behavior is that if you open a file which

  • has an extension that is used in g:vimwiki_list, and
  • is not in the paths specified in g:vimwiki_list

then vimwiki creates a new wiki at the file's directory, and that file is treated as a wiki page (vimwiki's key-mapping gets applied). This behavior in controlled by the variable g:vimwiki_global_ext which is 1 (enabled) by default. Personally I think this should be disabled by default.

More details can be found at :h vimwiki-temporary-wiki and :h g:vimwiki_global_set .

p/s: only tested with .wiki extension but I'm pretty sure it's the same for all extensions.

Heym @i-give-up ! Thanks!
Just tested it here and it does work.

I'm not using Vimwiki anymore (it is awesome, but I've found out that I don't need 1/4 of its features, and it was a deal breaker to not be able to use my own settings in most of the cases...). I'm closing the issue now since a local and _quick_ test did work, but I won't be using it and don't know how it would behave on the long run.

Thanks @i-give-up !
And thanks again to the Vimwiki Team, it is amazing to see such a great plugin rocking!

Was this page helpful?
0 / 5 - 0 ratings