Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support post update hook for UnicodeDownload #16

Closed
razor-x opened this issue Jun 15, 2016 · 12 comments
Closed

Support post update hook for UnicodeDownload #16

razor-x opened this issue Jun 15, 2016 · 12 comments

Comments

@razor-x
Copy link

razor-x commented Jun 15, 2016

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.

@chrisbra
Copy link
Owner

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.

@razor-x
Copy link
Author

razor-x commented Jun 15, 2016

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], ' ')}

@chrisbra
Copy link
Owner

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

@junegunn
Copy link

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.

@chrisbra
Copy link
Owner

Thanks @junegunn for the info. I am closing this then.

@junegunn
Copy link

@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).

@razor-x
Copy link
Author

razor-x commented Jun 16, 2016

@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.

@chrisbra
Copy link
Owner

I'll fix that. The second bug you mentioned, I haven't seen, can you check, if this happens with Vim as well please?

@razor-x
Copy link
Author

razor-x commented Jun 17, 2016

Yes, the popup bug happens in vim and gvim as well. The popup is unfocused as well as stuck open.

@chrisbra
Copy link
Owner

The popup bug is a Vim bug. I have posted a patch. Let's hope it will get fixed soon.

@junegunn
Copy link

@razor-x With the latest vim-plug, you can now do this (note the : prefix):

Plug 'chrisbra/unicode.vim', { 'do': ':silent! UnicodeDownload' }

@chrisbra
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants