2

I'm working on different projects and I want to select what plugins to enable (or disable) for every project. I'm using Pathogen to manage my plugins.

Plugins list:

.vim \
     |-bundle \
              |-vim-markdown
              |-latexsuite
              |-dirdo
              |-localvimrc
              |-nerdtree
     |-autostart
     |-doc

I've a main .vimrc which by default enables all plugins and a local lvimrc in every project main directory enabled by Localvimrc, in which I add some plugins to the disabled plugins list.

.vimrc

" Enables vim-pathogen and disables nearly all plugins
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
let g:pathogen_disabled = []
" This makes vim invoke Latex-Suite when you open a tex file.
filetype plugin on

latex-project's lvimrc

let g:pathogen_disabled = []
call add(g:pathogen_disabled, 'vim-markdown')

blog project's lvimrc

let g:pathogen_disabled = []
call add(g:pathogen_disabled, 'latexsuite')

The problem

Everything works fine except vim-markdown which is not loaded when I open my blog's html/markdown files (I've already added *.html extension in ftdetect/markdown.vim). Moreover, vim-markdown is not listed in the output of :scriptnames when editing my blog files.

Any hint?

fradeve
  • 284
  • 4
  • 15

3 Answers3

1

Did you know you could have more than one bundle directory? You could create different bundle directories for different projects.

So you could do something like this:

runtime bundle_main/pathogen/autoload/pathogen.vim
call pathogen#infect('bundle_main')
call pathogen#infect('bundle_projectX')
call pathogen#infect('bundle_projectY')
call pathogen#helptags()

You could conditionally load the plugin folders too.

Also with regards to vim-markdown: There are many implementations. See https://github.com/hallison/vim-markdown It seems to be more actively maintained.

darcyparker
  • 1,199
  • 9
  • 13
  • Thank you, but calling `infect` on different bundles was one of my first attempts, and it failed. I used to source a bundle of plugin common to all my projects (that's what you called `main`) and then in local `.vimrc` I sourced the bundles with plugins useful for the project I were working on; somehow, this was not functional (the LaTeX plugin was activated but the Markdown one wasn't). – fradeve Jul 25 '12 at 08:02
0

Would adding filetype plugin on to every .lvimrc help to fix the problem?

romainl
  • 186,200
  • 21
  • 280
  • 313
  • As in `.vimrc`, I've added it after `call add(g:pathogen_disabled, 'latexsuite')`, but unfortunately this not solves the issue. – fradeve Jul 24 '12 at 13:19
0

As a VAM developer I could say that we had to add the following to make ftdetect plugins work. Briefly: adding paths to &rtp does not cause ftdetect files to be sourced, thus we have to source them manually. Pathogen also has a hack for this, but it uses filetype off then filetype on. This hack is not invoked when using pathogen#runtime_append_all_bundles, thus either add

call pathogen#cycle_filetype()

after pathogen#runtime_append_all_bundles or just use pathogen#infect instead which does this for you. If this does not work try also adding

unlet! g:did_load_filetype

before calling pathogen.

You can also migrate to VAM: like pathogen it puts all plugins to separate directories, but unlike it you have to specify which ones you want to activate instead of activating all by default and blacklisting. Here you can’t use documented API and avoid running this hack at the same time.

ZyX
  • 52,536
  • 7
  • 114
  • 135
  • Ok, @ZyX, I'm testing VAM and it seems really full-featured. It has impressed me and I'll give it a chance. Running `:scriptnames` in both latex and blog projects I've noticed that, differently from Pathogen, VAM correctly activate plugins were called by a local `.vimrc` (using vim-addon-local-vimrc). This is the good. The bad is that both markdown@tpope and vim-latex plugins are not functional. The second, in particular, gives a bunch of `E117: Unknown function: IMAP`, both when installing it from VAM or loading from the tar.gz from the original site. VAM is *the* way but I need my plugins. – fradeve Jul 24 '12 at 16:37
  • @fradeve Can’t reproduce: doing `vim -u /dev/null -N --cmd 'let &rtp="/path/to/vam,".$VIMRUNTIME | filetype plugin indent on | runtime! autoload/vam.vim | ActivateAddons vim-latex markdown@tpope'` activates both plugins completely correctly, latex mappings are set on `set ft=tex` and tpope’s markdown filetype plugin is loaded correctly on `set ft=markdown`. No errors regarding unexistence of IMAP. – ZyX Jul 24 '12 at 17:15
  • * `vim -u /dev/null` is *not* `vim -u NONE`. Second skips loading plugins as well, first is just empty vimrc. – ZyX Jul 24 '12 at 17:20
  • @fradeve What is the outputs of scriptnames, where `vam#ActivateAddons()` is called and with which arguments, what is `g:vim_addon_manager` contents prior to call, what is vim-latex directory listing and how did you install it (just Activate and `Y` on all questions?)? Before answering try to delete (move to another location) vim-latex and let VAM check it out (requires git, though I believe you already have it) (skip if answer on the last question in parens is yes). – ZyX Jul 24 '12 at 17:28
  • Probably I get it. First scenario: I add `call vam#ActivateAddons("LaTeX-Suite_aka_Vim-LaTeX")"` or `":ActivateAddons(["LaTeX-Suite_aka_Vim-LaTeX"])` to local `.vimrc` (managed by vim-addon-local-vimrc) and I get the error mentioned above. Second scenario: A) open vim B) open LaTeX file to work on C) `:ActivadeAddons LaTeX-Suite_aka_Vim-LaTeX` works flawlessly. How can I use local `.vimrc` and load the plugin automagically? Yes, I've answered `Y` to all questions during installation and all the script dependencies are satisfied. – fradeve Jul 25 '12 at 01:03
  • @fradeve Second variant (`:ActivateAddons(...)`) is false and won’t work. It should not show the missing IMAP error though. To install git version you currently have to use `vim-latex` name (will be fixed once I am sure they both point to the same plugin. Currently vim.org is down). Better variant of calling `vam#ActivateAddons` is `call vam#ActivateAddons([...])`, though yours is also correct (just limited to 20 plugins and not supporting options dictionary). Can’t check whether I can reproduce your problem with this source at the moment: vim.org is down. – ZyX Jul 25 '12 at 03:19
  • @fradeve I believe the root of the problem may be the time when local vimrc is sourced: is it sourced by one of the plugins thus *after vim started to source plugins*? (Though here new plugins just may not be sourced, IMAP error is given because of the filetype event happening after all this initialization stuff.) In this case vim is likely to skip new additions to runtimepath and you have to use `call vam#ActivateAddons(["LaTeX-Suite_aka_Vim-LaTeX"], {"force_loading_plugins_now": 1})`. *Do it only in local vimrc*. Most, but not every plugin can handle double sourcing gracefully. – ZyX Jul 25 '12 at 03:25
  • Now checking out `LaTeX-Suite_aka_Vim-LaTeX` will checkout git source unless explicitly disabled. `vim-latex` entry was removed. – ZyX Jul 25 '12 at 04:52
  • Using `call vam#ActivateAddons(["plugin-bundle-name"], {"force_loading_plugins_now": 1})` solved it, both for LaTeX and markdown plugins. Thank you, I probably won't get it without your help. – fradeve Jul 25 '12 at 07:58
  • @fradeve I believe this is true: it was not documented until this discussion. You are always welcome. – ZyX Jul 25 '12 at 14:33