Support post update hook for UnicodeDownload
razor-x opened this issue · 12 comments
I'd like the download of UnicodeData.txt
to happen on plugin install / update. I'm trying this with vim-plug:
function! DoUnicode(arg)
UnicodeDownload
endfunction
Plug 'chrisbra/unicode.vim', { 'do': function('DoUnicode') }
which fails with
x Post-update hook for unicode.vim ... Vim:E492: Not an editor command: UnicodeDownload
I also tried
function! DoUnicode(arg)
call unicode#Download(1)
endfunction
Plug 'chrisbra/unicode.vim', { 'do': function('DoUnicode') }
which seems to run, but not actually download anything and breaks the vim-plug install process.
Hi Evan!
On Mi, 15 Jun 2016, Evan Sosenko wrote:
I'd like the download of
UnicodeData.txt
to happen on plugin install / update. I'm trying this with vim-plug:function! DoUnicode(arg) UnicodeDownload endfunction Plug 'chrisbra/unicode.vim', { 'do': function('DoUnicode') }which fails with
x Post-update hook for unicode.vim ... Vim:E492: Not an editor command: UnicodeDownload
I also tried
function! DoUnicode(arg) call unicode#Download(1) endfunction Plug 'chrisbra/unicode.vim', { 'do': function('DoUnicode') }which seems to run, but not actually download anything and breaks the vim-plug install process.
I don't know vim-plug very well. I would either force sourcing the
plugin/unicode.vim file or postpone the call until the VimEnter event.
Best,
Christian
Glück ist Selbstgenügsamkeit.
-- Aristoteles, 384-322 v. Chr.
IMO, force sourcing the file goes against the grain of using a plugin manager (path resolution is non-trivial). Trying that does run the command, however it has the same issue as just calling unicode#Download(1)
as in the second example.
It would be nice if the Download function could work with this, but a workaround is
let unicode_src = 'http://unicode.org/Public/UNIDATA/UnicodeData.txt'
let unicode_dest = './autoload/unicode/UnicodeData.txt'
Plug 'chrisbra/unicode.vim',
\ { 'do': join(['curl --create-dirs -o', unicode_dest, unicode_src], ' ')}
downloading depends on netrw. Perhaps that is not initialized, when vim-plug runs? Anyhow, I think this is more a question for @junegunn and how to use vim-plug
Anyhow, I think this is more a question for @junegunn and how to use vim-plug
Yeah, it is. After the initial clone, vim-plug executes do
block before loading the plugin, so the command is not yet available at the point. There's no good explanation for the decision. I would say it was not an issue as the option was mainly added to run shell commands such as make
. Unfortunately it's not easy to change the order of the operations at this stage, as it concerns me that it might break some (hypothetical) user's configuration.
Anyway, in this case you can load the plugin in advance using plug#load
function.
function! DoUnicode(arg)
call plug#load('unicode.vim')
UnicodeDownload
endfunction
Plug 'chrisbra/unicode.vim', { 'do': function('DoUnicode') }
But as you have noted, the way the command works is not compatible with the subsequent buffer manipulation of vim-plug. The part of the installer was written with the assumption that the cursor stays in its window. It'll be an easy fix, I'll look into it later in the day.
@razor-x Should be fixed now.
function! DoUnicode(...)
call plug#load('unicode.vim')
silent! UnicodeDownload
endfunction
I found that silent!
is necessary due to an error in UnicodeDownload
(lcd
to a non-existing directory).
@junegunn Right, silent!
fixes the issue where UnicodeDownload
breaks PlugInstall
, now the issue is with the UnicodeDownload
function itself.
@chrisbra Perhaps I should open a new issue for this, but basically UnicodeDownload
fails (with or without netrw) with the non-existing directory error. What's weird is that if you try to insert a character for the first time (<C-X><C-Z>
) then it will trigger the initial download, succeed, and then open the popup. (There is actually another bug where once the popup has opened in this way, the only way to close it is to restart vim).
For reference, I'm using Neovim.
I'll fix that. The second bug you mentioned, I haven't seen, can you check, if this happens with Vim as well please?
Yes, the popup bug happens in vim and gvim as well. The popup is unfocused as well as stuck open.
The popup bug is a Vim bug. I have posted a patch. Let's hope it will get fixed soon.
@razor-x With the latest vim-plug, you can now do this (note the :
prefix):
Plug 'chrisbra/unicode.vim', { 'do': ':silent! UnicodeDownload' }
Am 2016-07-13 16:10, schrieb Junegunn Choi:
@razor-x [1] With the latest vim-plug, you can now do this (note the :
prefix):Plug 'chrisbra/unicode.vim', { 'do': ':silent! UnicodeDownload' }
Great, thanks!
Note: the sil! shouldn't be necessary anymore with the latest version of
unicode.vim
Best,
Christian