Closed lacygoill closed 6 years ago
this PR tries to fix the issue by moving the
<plug>
mappings in theplugin/
directory.
Maybe we can instead force autoload , e.g. by calling dirvish#open()
at the end of ftplugin/dirvish.vim
:
" Force autoload if `ft=dirvish`
:if !exists('*dirvish#open')|try|call dirvish#open()|catch|endtry|endif
By the way, usually dirvish sets 'buftype' to nofile, ... There may be other settings which are not properly set in the previous example; namely 'swapfile' and 'conceallevel'.
For buffers that dirvish does not own, set filetype=dirvish
is only meant to provide a subset of useful functionality. Setting buftype=nofile
is potentially destructive. Also the conceal stuff won't make sense because the buffer could contain arbitrary content.
Ok, I followed your recommendation, revert the old change, and forced the autoload at the end of ftplugin/
.
But now, when I execute:
$ git ls-files | vim -Nu /tmp/vimrc +'setf dirvish' -
It raises the E37
error (No write since last change
).
I'm going to try to understand the reason, and fix it if I can.
E37 goes away if you :set nohidden
. I don't know exactly what causes it, but it's harmless.
q
won't work still, because Dirvish refuses to delete a buffer it doesn't own (b:dirvish
is not defined). That's a safety feature.
x
works now.
Here's a neat example given in the README of the project:
It works well, except for the
q
andx
buffer-local mappings. They don't work immediately because theirrhs
are<plug>
mappings, which are are not defined in aplugin/
directory, but in anautoload/
one.Consider this minimal
vimrc
written in/tmp/vimrc
:From the directory of
vim-dirvish
, if I start Vim like this:Vim opens a dirvish buffer listing the contents of the directory. But if I press
x
on a filepath to add it to the arglist, nothing happens.This PR tries to fix the issue by moving the
<plug>
mappings in theplugin/
directory.I think you moved the
<plug>
mappings inautoload/
on purpose, because doing so allows you to make theset_args()
andbuf_close()
functions local to the script. Thus, you avoid polluting the function namespace with two additional public functions which are not intended to be invoked directly by the user.I value the reliability more than the reduced noise, but I understand your choice, because the mappings work correctly once you press another mapping whose
rhs
is defined inplugin/
and which triggers the sourcing of theautoload/
directory. Still, pressing a key which sometimes work, but sometimes don't, is a little distracting because when it doesn't and you forgot the issue, you may lose time in a useless debugging or wondering whether you did something wrong.Feel free to close the PR if you disagree.
Edit:
By the way, usually
dirvish
sets'buftype'
tonofile
, but not in the previous example. So, when you pressEnter
on a file to edit it, you may get the error:Maybe it could be slightly improved by setting the option explicitly from the shell command-line:
Edit2:
There may be other settings which are not properly set in the previous example; namely
'swapfile'
and'conceallevel'
.It seems that usually, they are set by
s:buf_init()
, which is called by a chain of functions calls such as:Maybe
dirvish#open()
should be manually invoked from the shell (with a+
argument) to handle the settings, but I don't know exactly how.Edit3:
This shell command seems to fix all the issues:
So, I close the PR.