0

This works:

execute pathogen#infect('bundle/ruby/{}')

But this doesn't:

autocmd FileType * execute pathogen#infect('bundle/ruby/{}')

Nor this:

autocmd FileType * :execute pathogen#infect('bundle/ruby/{}')

Nor about 3 other things I tried.

UPDATE: This works:

autocmd BufWinEnter * execute '!ls'

But not this:

autocmd FileType * execute '!ls'

UPDATE 2:

Possibly related: FileType autocommand not working in Neovim

StevieD
  • 1,492
  • 1
  • 16
  • 24

1 Answers1

3

My guess: plugin managers need to be triggered within the scope of .vimrc execution.

After that, it's too late, files under {rtp}/plugin can't be loaded. And I'm afraid it's the same with file {rtp}/ftplugin as they are also triggered by FileType before your autocommand is triggered.

see :h starting-something.

At best the plugin manager you're using has a way to load plugins if some conditions are detected. You'll need to read its documentation in that case. I know a few elaborated plugin managers have this feature.

NB: if the plugin you're trying to use is correctly written: ftplugin files (in your case as I read "ruby") that depends on autoload plugin files, then this should not be a problem: no need to bother with this.

Luc Hermitte
  • 17,351
  • 1
  • 33
  • 49
  • Thanks. I'm trying to follow the advice here: https://vi.stackexchange.com/a/6961/2021 for pathogen. Maybe it's just bad advice. – StevieD Jun 11 '20 at 00:53
  • What's really weird is autocmd BufEnter * execute pathogen#infect('bundle/ruby/ale') doesn't work but autocmd BufEnter * execute '!ls' does. – StevieD Jun 11 '20 at 00:55
  • Are you sure it doesn't work? Isn't &rtp value changed? Updating 'rtp' is the main purpose of the plugin manager. Loading the "plugins" is and has always been Vim task. plugin files are loaded after .vimrc has been loaded, ftplugin files are loaded on opening new buffer of the related filetype, autoload plugin files are loaded on demand. – Luc Hermitte Jun 11 '20 at 08:34