zhimsel / vim-stay

Make Vim persist editing state without fuss
MIT License
161 stars 7 forks source link

Slight incompatibility with Vimwiki plugin #35

Closed Flurrywinde closed 7 years ago

Flurrywinde commented 7 years ago

Vimwiki maps <cr>, backspace, etc to its own functions, but it allows you to override this behavior by using hasmapto. (EDIT: What I mean is the vimwiki.vim script uses hasmapto, not that the user himself uses it, in case that wasn't clear.) If hasmapto sees that a mapping already exists (like if you mapped <cr> to something else in your .vimrc), then it won't commandeer it.

However, for some reason, this stops happening when vim-stay is installed. Now, vimwiki maps <cr> (and everything else it maps) regardless of whether I have my own mapping.

Any idea as to why this is happening? I'd like to fix this, as I like both plugins a lot.

kopischke commented 7 years ago

That sounds both very annoying and somewhat puzzling, as ~the only mapping vim-stay ever comes near to is gf~vim-stay never maps anything. Could you point me to the Vimviki repo so I can take a peek at its code?

Flurrywinde commented 7 years ago

https://github.com/vimwiki/vimwiki

And here's the link to my issue about this over there: https://github.com/vimwiki/vimwiki/issues/341

Note: In my original post, I didn't put put <cr> in backticks, so it wasn't showing up. Going to fix this now.

kopischke commented 7 years ago

This is most unlikely to be due to mapping conflicts as vim-stay doesn’t touch mappings (I was thinking of vim-fetch when I stated otherwise above). I’ll have a look at the vimviki source and see if I can find anything…

kopischke commented 7 years ago

@Flurrywinde could you tell me what your viewoptions are set to (echo &viewoptions)?

Flurrywinde commented 7 years ago

folds,options,cursor

kopischke commented 7 years ago

Tentatively, I would say the inclusion of options is the culprit. To test this, please

  1. Set viewoptions to the recommended default in your vimrc: set viewoptions=cursor,folds,slash,unix.
  2. Nuke your view state with :CleanViewdir!.
  3. Restart Vim and check a Vimviki file for mapping behaviour.
Flurrywinde commented 7 years ago

This worked. I guess I must have somehow missed the viewoptions recommended default when I installed vim-stay. Sorry about that! Thanks so much for the help.

kopischke commented 7 years ago

Storing options in the file state causes no end of hurt, and yeah, you are not the first user not to mind the defaults ;). I have an update for vim-stay on the back burner that will mandatorily remove options when saving views, but I have no idea when I will get around to finalize that (life has found ways to keep me from coding for quite a while).