These are chat archives for Shougo/dein.vim

18th
Apr 2016
Gontran Baerts
@gbcreation
Apr 18 2016 12:31
I use the blueyed/vim-diminactive plugin. I would like to lazy load it only the first time I split the window. What kind of event should I use ?
Wang Shidong
@wsdjeg
Apr 18 2016 12:39
@gbcreation if you are using neovim.I think build from source is a good choice,before you open any issues,just run git pull ,make,sudo make install ,if you still get error,you can open issues
Gontran Baerts
@gbcreation
Apr 18 2016 12:46
@wsdjeg ok. Actually the problem was not related to my version of neovim, but probably to my initialization scripts
Now it just works
Maybe I had problems because I change the script in which I add plugins to Dein. The first one was plugin-list.vim, then I change to plugin-list-dein.vim without deleing the first one. So Dein cache didn't detect the change. Do you see what I mean ?
This is the filename passed as second argument to dein#begin()
Gontran Baerts
@gbcreation
Apr 18 2016 13:09
Do I have to call dein#clear_state() manually when I change vimrcs passed to dein#begin() ?
Shougo
@Shougo
Apr 18 2016 13:14
@gbcreation Please read the dein#begin() doc.
Dein supports the detection.
But you must specify the 2nd argument.
Gontran Baerts
@gbcreation
Apr 18 2016 13:20

This is my configuration:

let s:plugins_dir = expand('~/.cache/nvim/dein')
if !dein#load_state(s:plugins_dir)
    finish
endif
let s:pluginList=fnamemodify(expand('<sfile>'), ':h').'/dein-plugin-list.vim'
call dein#begin(s:plugins_dir, [s:pluginList])
execute 'source' s:pluginList
call dein#end()
call dein#save_state()
if !has('vim_starting') && dein#check_install()
    call dein#install()
 endif

Is it right ?

The file pointed by the s:pluginList variable contains dein#add(...) calls
Shougo
@Shougo
Apr 18 2016 13:24
It is right if s:pluginList file path is valid.
You should check it.
Gontran Baerts
@gbcreation
Apr 18 2016 13:25
ok, I see
Now, if I change line 5 to let s:pluginList=fnamemodify(expand('<sfile>'), ':h').'/another-file.vim', is this change detected by Dein ?
Wang Shidong
@wsdjeg
Apr 18 2016 13:26
@gbcreation yes,I know,so it has been fixed,nice to hear
Gontran Baerts
@gbcreation
Apr 18 2016 13:26
Or does the script finish at line 3 ?
Shougo
@Shougo
Apr 18 2016 13:26
OK.
I get it.
You must specify the .vimrc file in dein#begin() 2nd argument.
call dein#begin(s:plugins_dir, [s:pluginList]) just detect plugin list changes.
Please read it.
Gontran Baerts
@gbcreation
Apr 18 2016 13:28
ok, i anderstand
Shougo
@Shougo
Apr 18 2016 13:28
call dein#begin(s:path, [expand('<sfile>')]
      \ + split(glob('~/.vim/rc/*.toml'), '\n'))
This is my config. You should use expand('<sfile>')
Gontran Baerts
@gbcreation
Apr 18 2016 13:28
Yes, I see
Thank you very much :)
So I have to call dein#clear_state() manually after doing this change ?
Shougo
@Shougo
Apr 18 2016 13:32
You need call this one time.
Gontran Baerts
@gbcreation
Apr 18 2016 13:37
I use the blueyed/vim-diminactive plugin. I would like to lazy load it only the first time I split the window. What kind of event should I use ?
Shougo
@Shougo
Apr 18 2016 13:42
It seems enabled by DimInactive commands
call dein#add('blueyed/vim-diminactive', {'lazy': 1})
works.
It is enabled by DimInactive... commands. But you cannot complete the command names.
If you want to complete them, you need to specify the commands by on_cmd.
Gontran Baerts
@gbcreation
Apr 18 2016 13:46
Actually, I don't use DimInactive... commands. The plugin is enabled as soon as it is loaded.
s:setup() is called at the end of the plugin script
Shougo
@Shougo
Apr 18 2016 13:47
I think you should use 'path': '.*'
The plugin is loaded after you opened a file.
Gontran Baerts
@gbcreation
Apr 18 2016 13:48
This is not exactly what I would like to have. I don't need this plugin when I open a file, but only if I have more than one window.
Shougo
@Shougo
Apr 18 2016 13:49
Dein has not the loading feature.
Gontran Baerts
@gbcreation
Apr 18 2016 13:49
ok
Shougo
@Shougo
Apr 18 2016 13:49
It is really special case. So, you should use manual loading.
dein#source(name)
You can define the autocmd checks the winnr('$') and load it.
Gontran Baerts
@gbcreation
Apr 18 2016 13:51
ok, I will try that, thank you.
I would like to lazy load the vim-signify plugin only if I open a file which is in VCS. Is it possible to detect for example a .git folder in the ancestor directories ?
Shougo
@Shougo
Apr 18 2016 13:55
Of course no.
You should check it manually.
:help finddir()
Gontran Baerts
@gbcreation
Apr 18 2016 13:58
Wouldn't it be interesting to add an event on_file_open to Dein which executes code returning true/false to indicate if the plugin should be loaded ?
Shougo
@Shougo
Apr 18 2016 13:59
Hm
Gontran Baerts
@gbcreation
Apr 18 2016 14:00
This event name is just an example, but you got the idea :)
It would be helpful for the two last cases I talked about
Gontran Baerts
@gbcreation
Apr 18 2016 14:09
or maybe something more generic to eval some code returning true/false for given events like BufEnter, WinEnter, etc
it would be like the existing on_idle but would allow to use other events
Gontran Baerts
@gbcreation
Apr 18 2016 14:18
for example:
dein#add('blueyed/vim-diminactive', {
\    'on_event': { 'WinEnter': 'winnr("$") > 1' }
\ })
Gontran Baerts
@gbcreation
Apr 18 2016 14:54
What do you think about this feature ?
Shougo
@Shougo
Apr 18 2016 20:41
on_thinking
Gontran Baerts
@gbcreation
Apr 18 2016 21:30
Some other examples that could be useful (not sure they would work)
# Load Projectionist if a .projections.json file is found in ancestor directories of the edited file
dein#add('tpope/vim-projectionist', {
\    'on_event': { 'VimEnter': 'findfile(".projections.json", ".;") != ""' }
\ })
# Load Signify if a .git directory is found in ancestor directories of the edited file
dein#add('mhinz/vim-signify', {
\    'on_event': { 'BufRead': 'finddir(".git", ".;") != ""' }
\ })
# Load DelimitMate when typing a matchpairs character
dein#add('Raimondi/delimitMate', {
\    'on_event': { 'InsertCharPre': 'index(split(&matchpairs, "[:,]"), v:char) != -1' }
\ })
Shougo
@Shougo
Apr 18 2016 21:38
For delimitMate, you should use on_i instead.
Wang Shidong
@wsdjeg
Apr 18 2016 23:26
@gbcreation nice feature!
Shougo
@Shougo
Apr 18 2016 23:30
I will add the feature.
Wang Shidong
@wsdjeg
Apr 18 2016 23:31
thanks