MarcWeber / vim-addon-manager

manage and install vim plugins (including their dependencies) in a sane way. If you have any trouble contact me. Usually I reply within 24 hours
Other
660 stars 59 forks source link

Global VAM installation for root and users #110

Closed Massimo-B closed 11 years ago

Massimo-B commented 11 years ago

Hi,

I have setup VAM inside /etc/vim/vim-addons. I do this to have the same add-on set for root and users, actually it's only me and root. This works fine now as root. But running vim as user tries to re-install all add-ons into ~/.vim/vim-addons:

$ ls -1d /etc/vim/*
/etc/vim/gvimrc
/etc/vim/vim-addons/
/etc/vim/vimrc
/etc/vim/vimrc.local
/etc/vim/vimrc.vam

vimrc.vam is mostly the commented version from docs:

fun! EnsureVamIsOnDisk(plugin_root_dir)
    " windows users may want to use http://mawercer.de/~marc/vam/index.php
    " to fetch VAM, VAM-known-repositories and the listed plugins
    " without having to install curl, 7-zip and git tools first
    " -> BUG [4] (git-less installation)
    let vam_autoload_dir = a:plugin_root_dir.'/vim-addon-manager/autoload'
    if isdirectory(vam_autoload_dir)
        return 1
    else
        if 1 == confirm("Clone VAM into ".a:plugin_root_dir."?","&Y\n&N")
            " I'm sorry having to add this reminder. Eventually it'll pay off.
            call confirm("Remind yourself that most plugins ship with ".
            \"documentation (README*, doc/*.txt). It is your ".
            \"first source of knowledge. If you can't find ".
            \"the info you're looking for in reasonable ".
            \"time ask maintainers to improve documentation")
            call mkdir(a:plugin_root_dir, 'p')
            execute '!git clone --depth=1 https://github.com/MarcWeber/vim-addon-manager '.
                \ shellescape(a:plugin_root_dir, 1).'/vim-addon-manager'
            " VAM runs helptags automatically when you install or update
            " plugins
            exec 'helptags '.fnameescape(a:plugin_root_dir.'/vim-addon-manager/doc')
        endif
        return isdirectory(vam_autoload_dir)
    endif
endfun

fun! SetupVAM()
     let g:vim_addon_manager = {'scms': {'git': {}}}
     fun! MyGitCheckout(repository, targetDir)
         let a:repository.url = substitute(a:repository.url, '^git://github', 'http://github', '')
         return vam#utils#RunShell('git clone --depth=1 $.url $p', a:repository, a:targetDir)
     endfun
     let g:vim_addon_manager.scms.git.clone=['MyGitCheckout']

    " VAM install location:
    let plugin_root_dir = expand('/etc/vim/vim-addons')
    if !EnsureVamIsOnDisk(plugin_root_dir)
        echohl ErrorMsg | echomsg "No VAM found!" | echohl NONE
        return
    endif
    let &rtp.=(empty(&rtp)?'':',').plugin_root_dir.'/vim-addon-manager'

    " Tell VAM which plugins to fetch & load:
    try
        let s:plugins = ''
        let s:plugins .= 'BlockDiff xml '
        if has("gui_running")
            let s:plugins .= 'Powerline '
        endif
        let s:plugins .= 'Distinguished '
        let s:plugins .= 'SuperTab%1643 '
        let s:plugins .= 'The_NERD_tree '
        let s:plugins .= 'bash-support '
        let s:plugins .= 'c%213 '
        let s:plugins .= 'clang_complete '
        let s:plugins .= 'matchit.zip '
        let s:plugins .= 'perl-support '
        let s:plugins .= 'snipmate-snippets '
        let s:plugins .= 'taglist '
        let s:plugins .= 'tlib '
        let s:plugins .= 'vim-addon-mw-utils '
        let s:plugins .= 'xml '

        call vam#ActivateAddons(split(s:plugins, ' '))
    catch /.*/
        echoe v:exception
    endtry
endfun
call SetupVAM()

It seems that plugin_root_dir is somehow different for the user. I tried for debugging:

let g:plugin_root_dir = expand('/etc/vim/vim-addons')

but it results into /etc/vim/vim-addons as well for the user.

Now comparing the :scriptnames of the user all add-ons are sourced from ~/.vim/vim-addons ignoring the plugin_root_dir:

 1: /etc/vim/vimrc
  2: /usr/share/vim/vim73/syntax/syntax.vim
  3: /usr/share/vim/vim73/syntax/synload.vim
  4: /usr/share/vim/vim73/syntax/syncolor.vim
  5: /usr/share/vim/vim73/filetype.vim
  6: /usr/share/vim/vimfiles/ftdetect/cmake.vim
  7: /usr/share/vim/vimfiles/ftdetect/gentoo.vim
  8: /usr/share/vim/vimfiles/ftdetect/ntp.vim
  9: /usr/share/vim/vimfiles/ftdetect/pam.vim
 10: /usr/share/vim/vim73/ftplugin.vim
 11: /etc/vim/vimrc.local
 12: /etc/vim/vimrc.vam
 13: /etc/vim/vim-addons/vim-addon-manager/autoload/vam.vim
 14: /usr/share/vim/vim73/indent.vim
 15: /usr/share/vim/vim73/syntax/nosyntax.vim
 16: ~/.vim/vim-addons/Distinguished/colors/distinguished.vim
 17: ~/.vim/vim-addons/BlockDiff/plugin/blockdiff.vim
 18: ~/.vim/vim-addons/SuperTab%1643/plugin/supertab.vim
 19: ~/.vim/vim-addons/The_NERD_tree/plugin/NERD_tree.vim
 20: ~/.vim/vim-addons/The_NERD_tree/autoload/nerdtree.vim
 21: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/path.vim
 22: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/menu_controller.vim
 23: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/menu_item.vim
 24: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/key_map.vim
 25: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/bookmark.vim
 26: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/tree_file_node.vim
 27: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/tree_dir_node.vim
 28: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/opener.vim
 29: ~/.vim/vim-addons/The_NERD_tree/plugin/nerdtree/creator.vim
 30: ~/.vim/vim-addons/The_NERD_tree/nerdtree_plugin/exec_menuitem.vim
 31: ~/.vim/vim-addons/The_NERD_tree/nerdtree_plugin/fs_menu.vim
 32: ~/.vim/vim-addons/bash-support/plugin/bash-support.vim
 33: ~/.vim/vim-addons/c%213/plugin/c.vim
 34: ~/.vim/vim-addons/c%213/autoload/mmtemplates/core.vim
 35: ~/.vim/vim-addons/clang_complete/plugin/clang_complete.vim
 36: ~/.vim/vim-addons/matchit.zip/plugin/matchit.vim
 37: ~/.vim/vim-addons/perl-support/plugin/perl-support.vim
 38: ~/.vim/vim-addons/taglist/plugin/taglist.vim
 39: ~/.vim/vim-addons/tlib/plugin/02tlib.vim
 40: /usr/share/vim/vimfiles/plugin/bugsummary.vim
 41: /usr/share/vim/vimfiles/plugin/gentoo-common.vim
 42: /usr/share/vim/vimfiles/plugin/gnupg.vim
 43: /usr/share/vim/vimfiles/plugin/newebuild.vim
 44: /usr/share/vim/vimfiles/plugin/newinitd.vim
 45: /usr/share/vim/vimfiles/plugin/newmetadata.vim
 46: /usr/share/vim/vim73/plugin/getscriptPlugin.vim
 47: /usr/share/vim/vim73/plugin/gzip.vim
 48: /usr/share/vim/vim73/plugin/matchparen.vim
 49: /usr/share/vim/vim73/plugin/netrwPlugin.vim
 50: /usr/share/vim/vim73/plugin/rrhelper.vim
 51: /usr/share/vim/vim73/plugin/spellfile.vim
 52: /usr/share/vim/vim73/plugin/tarPlugin.vim
 53: /usr/share/vim/vim73/plugin/tohtml.vim
 54: /usr/share/vim/vim73/plugin/vimballPlugin.vim
 55: /usr/share/vim/vim73/plugin/zipPlugin.vim

There is no users ~/.vimrc

Massimo-B commented 11 years ago

How? You mean by

:set

or

:let v:

?

ZyX-I commented 11 years ago

g:plugin_root_dir is not a setting, neither is l:plugin_root_dir (which is actually defined in a function): it is just a shortcut defined in order not to always write full path. Changing this shortcut to any value that does not match default one (see :h VAM-plugin_root_dir) leads to behavior that seems to be incorrect.

If issues appear, check all the documentation, especially third and fourth sections. Examples may be incorrect as they are not tested. Or they may be misleading like in this case. Third and fourth sections are being constantly updated.

ZyX-I commented 11 years ago

How? You mean by

First, variable defined there is l:plugin_root_dir, not g:plugin_root_dir. Second, neither l:plugin_root_dir (obviously: it is local to function) nor g:plugin_root_dir values are checked anywhere in VAM. They are not checked means they are not a setting, this has nothing to do with :set.

Massimo-B commented 11 years ago

Sorry, I can't follow you in some points. I was looking why the root-vim did use a different plugin root than the user-vim. I know setting my g:plugin_root_dir did not change it, it was just for debugging.

When re-reading the docs I have seen you have changed the commented version on Jan 18, 2013 :) A comment here about that would have been nice since the comment on the change says it fixes this issue :)

I added this section, and it works now:

" VAM install location:
    let c = get(g:, 'vim_addon_manager', {})
    let g:vim_addon_manager = c
    let c.plugin_root_dir = '/etc/vim/vim-addons'
    if !EnsureVamIsOnDisk(c.plugin_root_dir)
        echohl ErrorMsg | echomsg "No VAM found!" | echohl NONE
    return
    endif
    let &rtp.=(empty(&rtp)?'':',').c.plugin_root_dir.'/vim-addon-manager'

However, the commented part to be added into some vimrc is becoming quite large. Wouldn't it be helpful to put this stuff into some vam-init.vim file inside vim-addon-manager itself to get it updated, and to have only these points to add into users vimrc:

I have my own vimrc.vam sourced by vimrc.local, but even vimrc.vam is not static since I need to edit the plugin_root_dir on different installations (NFS environment, some userspace-only environments, ...). So I would rather like to have a static vam-init.vim and only change the plugin_root_dir from vimrc.

ZyX-I commented 11 years ago

What you see in documentation is just an example code doing much useless (for me) things like checking out VAM and not doing some useful things (setting a few options). If you need static VAM-init and non-static everything else just create it. You don’t require anything except vam#ActivateAddons call, thus is no need in vam-init. There is no way it can be simplified further by adding any files to the repository.