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

Can't detect the new plugin, if the plugin is put inside if branch #181

Closed
dlintw opened this issue Jan 20, 2017 · 9 comments
Closed

Can't detect the new plugin, if the plugin is put inside if branch #181

dlintw opened this issue Jan 20, 2017 · 9 comments

Comments

@dlintw
Copy link

dlintw commented Jan 20, 2017

Warning: I will close the issue without the minimal init.vim and the reproduce ways.

Problems summary

Expected

If I install /usr/bin/ag then 'dein' will install plugin ack.vim.
If there is no /usr/bin/ag then 'dein' will skip install plugin ack.vim.

Environment Information

  • OS: Arch Linux
  • Vim version: 8.0

Provide a minimal .vimrc with less than 50 lines (Required!)

" Your minimal .vimrc
set runtimepath^=~/path/to/dein.nvim/
call dein#begin(path)
call dein#begin('~/.vim/dein')                                                
call dein#add('~/.vim/dein/repos/github.com/Shougo/dein.vim') 
if executable('ag')                                                         
    call dein#add('mileszs/ack.vim') " :Ack <key> % search local                
endif                       
call dein#end()
call dein#save_state()                                                        
                                                                                
filetype plugin indent on                                                       
syntax enable                                                                   
                                                                                
if dein#check_install()                                                         
  call dein#save_state()                                                        
endif                                                                           
                                                                                
filetype plugin indent on                                                       
syntax enable                                                                   
                                                                                
if dein#check_install()                                                         
  call dein#install()                                                           
endif                                                                       

The reproduce ways from Vim starting (Required!)

  1. vim

Screen shot (if possible)

Upload the log messages by :redir and :message

@Mephistophiles
Copy link

It's not possible.

@Shougo
Copy link
Owner

Shougo commented Jan 20, 2017

What is the problem?

Can't detect the new plugin, if the plugin is put inside if branch

This is the Vim feature.
The block is not executed.

@dlintw
Copy link
Author

dlintw commented Jan 22, 2017

Is there any method to install plugin 'ack.vim' only when executable 'ag' exist?
What's the proper .vimrc should I rewrite?

@Shougo
Copy link
Owner

Shougo commented Jan 22, 2017

I think it works.

But the below is better.

    call dein#add('mileszs/ack.vim', {'if': executable('ag')}) " :Ack <key> % search local                

@Shougo
Copy link
Owner

Shougo commented Jan 22, 2017

You use dein cache feature.
The plugin data is already cached. So, the condition check executable('ag') is ignored.

@dlintw
Copy link
Author

dlintw commented Jan 23, 2017

Thanks for your tip for simple one 'if' logic, but, could you explain a rewrite vimrc for the following logic?

if has("lua")
  call dein#add('Shougo/neocomplete.vim')
elseif has('python')
  call dein#add('Valloric/YouCompleteMe')
endif

@Shougo
Copy link
Owner

Shougo commented Jan 23, 2017

call dein#add('Shougo/neocomplete.vim', {'if': has('lua')})

if !dein#tap('neocomplete.vim')
  call dein#add('Valloric/YouCompleteMe', {'if': has('python')})
endif

@dlintw
Copy link
Author

dlintw commented Jan 25, 2017

In your previous comment, you said:

You use dein cache feature.
The plugin data is already cached. So, the condition check executable('ag') is ignored.

Does the if !dein#tap should set outside the cache? I mean the .vimrc should be

" minimal .vimrc
set runtimepath^=~/path/to/dein.nvim/
call dein#begin(path)
call dein#begin('~/.vim/dein')                                                
  call dein#add('~/.vim/dein/repos/github.com/Shougo/dein.vim') 
  call dein#add('Shougo/neocomplete.vim', {'if':has('python')})
call dein#end()
call dein#save_state()
if !dein#tap('neocomplete.vim')
  call dein#add('Valloric/YouCompleteMe', {'if': has('python')})
endif
filetype plugin indent on                                                       
syntax enable                                                                   
if dein#check_install()                                                         
  call dein#save_state()                                                        
endif                                                                                                                                     
filetype plugin indent on                                                       
syntax enable                                                          
if dein#check_install()                                                         
  call dein#install()                                                           
endif     

@Shougo
Copy link
Owner

Shougo commented Jan 25, 2017

" minimal .vimrc
set runtimepath^=~/path/to/dein.nvim/
call dein#begin('~/.vim/dein')                                                
call dein#add('~/.vim/dein/repos/github.com/Shougo/dein.vim') 
call dein#add('Shougo/neocomplete.vim', {'if':has('python')})
if !dein#tap('neocomplete.vim')
  call dein#add('Valloric/YouCompleteMe', {'if': has('python')})
endif
call dein#end()
filetype plugin indent on                                                       
syntax enable                                                                   
                                                                                                                               
filetype plugin indent on                                                       
syntax enable                                                          
if dein#check_install()                                                         
  call dein#install()                                                           
endif

dein#tap() is OK after dein#end(), but dein#add() must be before dein#end().

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

No branches or pull requests

3 participants