Tips – Using git submodule keep your vim plugin up-to-date

Posted by AllenWei | Posted in Tips, vim | Posted on 08-04-2010-05-2008

View Comments




<brfore this post. I assuming you already have a git repository for your vim config files somewhere.

When we install vim plugin we need copy files to different folders, it’s hard to keep it up-to-date. As lot’s of vim plugin have github repository. we can use git submodule and vim plugin pathogen to keep your plugin up-to-date.

Add bundle support for vim

Fortunately Tim Pope wrote a plugin called pathogen ,which make things easier.

In the home page of the plugin you can find fully install details.

After you add this plugin you can manage your vim plugin in on .vim/bundle folder. You can unzip/untar/svn-checkout/git-clone plugin into this folder. pathogen plugin will load it automatically.
this this what your .vim folder structure look like

.vim/
|-- bundle
|   |-- ack
|   |   `-- plugin
|   |       `-- ack.vim
|   |-- bufexplorer
|   |   |-- doc
|   |   |   `-- bufexplorer.txt
|   |   `-- plugin
|   |       `-- bufexplorer.vim
|   |-- conque
|   |   |-- autoload
|   |   |   `-- conque_term.vim
|   |   |-- doc
|   |   |   `-- conque_term.txt
|   |   |-- plugin
|   |   |   `-- conque_term.vim
|   |   `-- syntax
|   |       `-- conque_term.vim

So we have chance to maintain vim plugin as a whole.

How to add a submodule

For example, we add a git plugin fugitive as a submodule of our vim repository.

If you have already added this plugin, make sure remove folder using

git rm -r .vim/bundle/fugitive

Otherwise you will get error 'fugitive' already exists in the index

Then we add vim-fugitive as submodule

git submodule add git://github.com/tpope/vim-fugitive.git .vim/bundle/fugitive

After you add submodule you need register it, using

git submodule init

How to update submodule

If this plugin have updates, you can run

git submodule update

to update your submodule repository

The last step push your changes to github, you will see this in your github repository

Picture 2.png

How to remove a submodule

There is not efficient way to remove a submodule
* first step is remove references to the submodule in .gitmodules and .git/config.
* Then git rm --cached .vim/bundle/fugitive

Thanks

Thanks github and github guides about submodule and Tim Pope who wrote many greate vim plugin.


Vim OOP javascript indentation plugin

Posted by AllenWei | Posted in vim | Posted on 03-04-2010-05-2008

View Comments

Last post I introduced a vim javascript plugin called jsBeautify

But you’ll find when you write OO javascript, vim indent is wrong.

There also a vim indent plugin called OOP javascript indentation is want you need

Download the script put at ~/.vim/indent

Vim javascript code formatter – jsbeautify

Posted by AllenWei | Posted in vim | Posted on 03-04-2010-05-2008

View Comments

If you want to format javascript file in vim jsBeautify plugin is want you need.

you can go to http://www.vim.org/scripts/script.php?script_id=2727 download the script.

And place it into your .vim/plugin/

the default shortcut is <leader>ff

If you want to change it, open the jsBeautify plugin file, at the bottom you can find the keymap definition.

It also have a web site to format your js code http://jsbeautifier.org/

Ads Plugin created by Jake Ruston's Wordpress Plugins - Powered by and football database.