targets.vim
targets.vim copied to clipboard
Problem with modeline `vim: foldmethod=marker foldlevel=0`
What the problem is about
Start vim file with modeline vim: foldmethod=marker foldlevel=0
. First try of command like da<
or da[
delete a fold (precisely, it leaves a blank line).
Steps to re-produce the problem:
- vimrc
call plug#begin('~/.vim/plugged')
Plug 'wellle/targets.vim'
call plug#end()
-
$ vim textfile.html
(see below) - textfile.html with modeline
<!-- {{{ -->
<div>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<!-- }}} -->
<!--
vim: foldmethod=marker foldlevel=0
-->
- Type
da<
orda[
inside the fold - Problem occur
What I've tried
It won't happen if I remove modeline and manually set the options after I enter vim.
Proceeding commands like da<
works fine.
Can confirm that it doesn't work with folds. Thanks for the heads up 👍
Not quite sure yet how to fix that.
Cost me some time to get the same conclusion, seems targets.vim
is not compatible with folds. It just doesn't work the 1st time using targets mapping in a folded block. I could reproduce the bug with va"
and following content
#!/usr/bin/env bash
# vim: fdm=marker fdl=0
# test {{{
echo "111"
echo "222"
echo "333"
# }}}
Any idea to bypass the problem?
Sometimes, it even deletes the content accidentally.
Just found a way to bypass the problem.
" Put it into init.vim
call targets#sources#newFactories('')
I haven't digger it deeper why it works. My guess is some of the functions in targets.vim are lazy-loaded and the loading of these functions triggers this very fold related problem. The above call is just pre-loading some of the functions manually.
I'm sorry that I don't use vim for very long time. Can't help with this discussion further.
Should I close this? Or maybe it were already fix?