为什么这个 vim 插件没有加载?

Why is this vim plugin not getting loaded?

我正在使用 pathogen 构建一个插件包来管理我的博客。对于初学者,我想提取一些我直接在我的 vimrc 中定义的命令,并将它们移动到一个插件中。这是我设置捆绑包的方式:

call pathogen#infect('/home/frew/code/blog/etc/vim-bundle/{}')

这是插件开头的简短片段:

echom "loaded hugo plugin"
if exists('g:loaded_hugo') || &cp || v:version < 700
  finish
endif
let g:loaded_hugo = 1

function! Tagged(tag)
  exe 'args `bin/tag-files ' . a:tag . '`'
endfunction
command! -nargs=1 Tagged call Tagged('<args>')

这里是包的目录结构:

/home/frew/code/blog/etc/vim-bundle/
└── hugo
    └── plugin
        └── hugo.vim

2 directories, 1 file

echom 永远不会得到 运行,而且我跟踪了一个 gvim,这是我发现匹配 /home/frew/code/blog/etc/vim-bundle/ 的内容:(我用sort -u)

open("/home/frew/code/blog/etc/vim-bundle/hugo/ftdetect/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/html/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/markdown/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/markdown/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC <unfinished ...>
open("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC <unfinished ...>
open("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/vim/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/markdown/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/vim/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/vim/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC <unfinished ...>
open("/home/frew/code/blog/etc/vim-bundle/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 18
stat("/home/frew/code/blog/etc/vim-bundle/hugo/after", 0x7fffd759c6d0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/autoload/ctrlp/utils.vim", 0x7fffd759a620) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/autoload/editorconfig.vim", 0x7fffd759c650) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/autoload/gitgutter/async.vim", 0x7fffd759d2f0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/autoload/gitgutter/debug.vim",  <unfinished ...>
stat("/home/frew/code/blog/etc/vim-bundle/hugo/autoload/gitgutter/diff.vim", 0x7fffd759e6d0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/autoload/gitgutter/sign.vim", 0x7fffd75a0040) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/autoload/htmlcomplete.vim", 0x7fffd759c4c0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/filetype.vim", 0x7fffd759f830) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftoff.vim", 0x7fffd759f830) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/html.vim", 0x7fffd759cf40) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/html.vim", 0x7fffd759d050) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/html.vim", 0x7fffd759d270) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/markdown.vim", 0x7fffd759da70) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/markdown.vim", 0x7fffd759dda0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/markdown.vim",  <unfinished ...>
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/vim.vim", 0x7fffd759e6e0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/vim.vim", 0x7fffd759e830) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/ftplugin/vim.vim",  <unfinished ...>
stat("/home/frew/code/blog/etc/vim-bundle/hugo/indent/markdown.vim", 0x7fffd759da70) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/indent/markdown.vim", 0x7fffd759db80) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/indent/markdown.vim", 0x7fffd759dda0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/indent/vim.vim", 0x7fffd759e830) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/indent/vim.vim",  <unfinished ...>
stat("/home/frew/code/blog/etc/vim-bundle/hugo/scripts.vim", 0x7fffd75a0060) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/css.vim", 0x7fffd759ae20) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/css.vim", 0x7fffd759af30) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/css.vim", 0x7fffd759b150) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/html.vim", 0x7fffd759b9e0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/html.vim", 0x7fffd759baf0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/html.vim", 0x7fffd759bd10) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/javascript.vim", 0x7fffd759ae20) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/javascript.vim", 0x7fffd759af30) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/javascript.vim", 0x7fffd759b150) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/markdown.vim", 0x7fffd759c510) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/markdown.vim", 0x7fffd759c620) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/markdown.vim", 0x7fffd759c840) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/pod.vim", 0x7fffd759b230) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/pod.vim", 0x7fffd759b380) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/vb.vim", 0x7fffd759ae20) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/vb.vim", 0x7fffd759af30) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/vb.vim", 0x7fffd759b150) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/vim.vim", 0x7fffd759d2d0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/syntax/vim.vim",  <unfinished ...>
stat("/home/frew/code/blog/etc/vim-bundle/hugo/vimfiles", 0x7fffd759cce0) = -1 ENOENT (No such file or directory)
stat("/home/frew/code/blog/etc/vim-bundle/hugo/vimfiles/after", 0x7fffd759c750) = -1 ENOENT (No such file or directory)

很明显它找到了 hugo 插件目录,它甚至从未尝试查找相关的 plugin 子目录。

我在这里错过了什么?

更新:这里是&rtp的当前值:

/home/frew/code/blog/etc/vim-bundle/hugo,/home/frew/.vim,/home/frew/.vim/bundle-lua/neocomplete,/home/frew/.vim/
bundle-python/editorconfig,/home/frew/.vim/bundle-python/ultisnips,/home/frew/.vim/bundle/FastFold,/home/frew/.v
im/bundle/IndentAnything,/home/frew/.vim/bundle/airline,/home/frew/.vim/bundle/better-whitespace,/home/frew/.vim
/bundle/colors-solarized,/home/frew/.vim/bundle/commentary,/home/frew/.vim/bundle/csv,/home/frew/.vim/bundle/ctr
lp,/home/frew/.vim/bundle/denite,/home/frew/.vim/bundle/eunuch,/home/frew/.vim/bundle/exchange,/home/frew/.vim/b
undle/fugitive,/home/frew/.vim/bundle/fugitive-gitlab,/home/frew/.vim/bundle/gitgutter,/home/frew/.vim/bundle/go
,/home/frew/.vim/bundle/goyo,/home/frew/.vim/bundle/inkpot,/home/frew/.vim/bundle/l9,/home/frew/.vim/bundle/last
place,/home/frew/.vim/bundle/lost,/home/frew/.vim/bundle/matchit,/home/frew/.vim/bundle/matchmaker,/home/frew/.v
im/bundle/obsession,/home/frew/.vim/bundle/pathogen,/home/frew/.vim/bundle/perl,/home/frew/.vim/bundle/projectio
nist,/home/frew/.vim/bundle/python,/home/frew/.vim/bundle/quick-scope,/home/frew/.vim/bundle/repeat,/home/frew/.
vim/bundle/sleuth,/home/frew/.vim/bundle/splitjoin,/home/frew/.vim/bundle/surround,/home/frew/.vim/bundle/tabula
r,/home/frew/.vim/bundle/terminus,/home/frew/.vim/bundle/textobj-between,/home/frew/.vim/bundle/textobj-entire,/
home/frew/.vim/bundle/textobj-underscore,/home/frew/.vim/bundle/textobj-user,/home/frew/.vim/bundle/unimpaired,/
home/frew/.vim/bundle/vinegar,/home/frew/.vim/bundle/visual-star-search,/home/frew/.vim/bundle/wipeout,/var/lib/
vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,
/home/frew/.vim/bundle/tabular/after,/home/frew/.vim/bundle-python/ultisnips/after,/home/frew/.vim/after

Tim Pope 在 github 上回答了这个问题。插件在会话之前加载,因此如果您想加载插件,在会话时修改 &rtp 为时已晚。