Un peu d'ordre

Après la discipline je parle d'ordre, ceux qui ne me connaissent pas doivent se poser des questions...
(et ceux qui me connaissent encore plus :-) )

Alors je vais rassurer tout le monde : Je vais commencer petit, sur mon ordinateur, dans mon répertoire .vim

Avant ma crise mon répertoire .vim ressemblait à ça : 
drwxr-xr-x 4 arnaud arnaud 4096 2011-05-19 23:30 after
drwxr-xr-x 4 arnaud arnaud 4096 2011-05-19 23:30 autoload
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:30 bin
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 colors
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:30 compiler
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 doc
drwxr-xr-x 3 arnaud arnaud 4096 2011-05-19 23:30 ftplugin
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 indent
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 keymap
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 lang
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:30 nerdtree_plugin
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 plugin
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 print
-rw-r--r-- 1 arnaud arnaud   85 2011-05-19 23:30 README
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 record
drwxr-xr-x 2 arnaud arnaud 4096 2011-06-09 22:22 snippets
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 spell
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:30 syntax
-rw-r--r-- 1 arnaud arnaud  193 2011-05-19 23:30 test.vim
drwxr-xr-x 2 arnaud arnaud 4096 2011-05-19 23:43 tutor
-rwxr-xr-x 1 arnaud arnaud  916 2011-05-19 23:30 vim-config
-rwxr-xr-x 1 arnaud arnaud 4030 2011-05-19 23:49 vim-keys

Maintenant j'ai ça :
drwxr-xr-x 2 arnaud arnaud 4096 2011-06-09 22:39 autoload
drwxr-xr-x 8 arnaud arnaud 4096 2011-06-09 22:39 bundle
-rw-r--r-- 1 arnaud arnaud   31 2011-06-09 22:34 TODO
-rwxr-xr-x 1 arnaud arnaud  916 2011-06-09 22:39 vim-config
-rwxr-xr-x 1 arnaud arnaud 4030 2011-06-09 22:39 vim-keys

Le truc ?
C'est un plugin vim appelé pathogen.

Pathogen permet d'organiser tous les plugins dans un répertoire bundle, qui contient les plugins chacun dans leur sous répertoire plutôt que de mélanger leur contenu dans des répertoires communs (ftplugin, plugin, autoload...)

L'installation est simple :
git clone https://github.com/tpope/vim-pathogen.git
mv vim-pathogen/autoload .vim
rm -rf vim-pathogen/
cd .vim
mkdir bundle

Je recopie mes fichiers de configs habituels qui sont versionnés :
cp ../git/dotfiles/vim/vim-* .

Il suffit alors d'ajouter au ~/.vimrc les lignes suivantes au tout début de votre fichier : 
filetype off
call pathogen#runtime_append_all_bundles()

Il faut maintenant (re-)installer (dans mon cas) les plugins que le
souhaite utiliser :
cd bundle
hg clone https://bitbucket.org/ns9tks/vim-fuzzyfinder
git clone https://github.com/tpope/vim-fugitive.git
git clone https://github.com/tpope/vim-surround.git
git clone https://github.com/scrooloose/nerdtree.git
git clone https://github.com/msanders/snipmate.vim.git
hg clone https://bitbucket.org/ns9tks/vim-l9

Je récupère mes snippets perl modifiés de mon répertoire versionné :
cp ../../git/dotfiles/vim/snippets/perl.snippets snipmate.vim/snippets/

Je rajoute un fichier pour me souvenir de la dépendance de L9 qui est requis par snipmate et qui me servira pour les dépendances à venir :
vi DEPENDENCIES

Mon répertoire bundle ressemble finalement à ça :
-rw-r--r--  1 arnaud arnaud   27 2011-06-09 22:39 DEPENDENCIES
drwxr-xr-x  6 arnaud arnaud 4096 2011-06-09 22:39 nerdtree
drwxr-xr-x 10 arnaud arnaud 4096 2011-06-09 22:39 snipmate.vim
-rw-r--r--  1 arnaud arnaud   29 2011-06-09 22:39 test.pl
drwxr-xr-x  5 arnaud arnaud 4096 2011-06-09 22:39 vim-fugitive
drwxr-xr-x  6 arnaud arnaud 4096 2011-06-09 22:39 vim-fuzzyfinder
drwxr-xr-x  6 arnaud arnaud 4096 2011-06-09 22:39 vim-l9
drwxr-xr-x  5 arnaud arnaud 4096 2011-06-09 22:39 vim-surround

Et voilà c'est fait !

Mon vim est à nouveau utilisable : j'ai mis de l'ordre dans mes plugins sans avoir à réécrire mes fichiers de configuration.

ADDITIF : Si on veut versionner cette configuration il faut agir légèrement différemment en ajoutant les plugins versionné sous git non pas par un clone mais par un git add submodule à la racine du dépôt git, par exemple :
git add submodule https://github.com/tpope/vim-fugitive.git vim/bundle/vim-fugitive

Une fois tous les submodules ajoutés il ne reste plus qu'a exécuter :
git submodule update --init 

La mise à jour d'un submodule se fait simplement dans le répertoire du submodule par un :
git pull


Commentaires

Posts les plus consultés de ce blog

Change your Gogs admin password

What is the average salary for Perl programmers in 2020?

JavaScript for Perl lovers.