Shougo / dein.vim

:zap: Dark powered Vim/Neovim plugin manager
MIT License
3.43k stars 196 forks source link

Timing of execution of `s:LoadFTPlugin()` changes when a plugin is lazy loaded #460

Closed yuki-yano closed 2 years ago

yuki-yano commented 2 years ago

Problems summary

If a lazy loaded plugin( use on_ft ) contains ftplugin or after/ftplugin, the result of :verbose autocmd FileType for that ft will change so that s:LoadFTPlugin() ignores what I wrote in the vimrc and runs last.

Expected

When a plugin is lazy loaded, s:LoadFTPlugin() is executed first.

Environment Information

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-e4e0e8c_1/share/nvim"


## Provide a minimal init.vim/vimrc without plugin managers

```vim
set runtimepath^=~/path/to/dein.nvim/

if dein#load_state(path)
  call dein#begin(path)

  " OK
  call dein#add('Shougo/dein.vim', {'on_ft': ['vim']})

  " OK
  call dein#add('heavenshell/vim-jsdoc')
  call dein#add('lambdalisue/vim-backslash')

  " Bad
  " call dein#add('heavenshell/vim-jsdoc', {'on_ft': ['typescript', 'typescriptreact', 'javascript'], 'build': 'make install'})
  " call dein#add('lambdalisue/vim-backslash', {'on_ft': ['vim']})

  call dein#end()
  call dein#save_state()
endif

if dein#check_install()
  call dein#install()
endif

filetype plugin indent on
syntax enable

function s:set_format_options() abort
  set formatoptions-=c
  set formatoptions-=r
  set formatoptions-=o
  set formatoptions+=j
  set formatoptions+=B
  set formatoptions+=n
endfunction

autocmd FileType * call <SID>set_format_options()

How to reproduce the problem from neovim/Vim startup

Shougo commented 2 years ago

Reproduced. But it is intended behavior. I can change the implementation, but it has the side effects.

Shougo commented 2 years ago

If you want to overwrite ftplugin options, you should use after/ftplugin instead.

yuki-yano commented 2 years ago

I understand. I will try to handle this by using after/ftplugin or another event.

Shougo commented 2 years ago

I have removed ftplugin reset. But it is the test. I may revert the changes.

Shougo commented 2 years ago

I have reverted the changes. filetype plugin reset is needed to load ftplugins lazily!

Shougo commented 2 years ago

So this is your configuration problem. I cannot help.