vim & git submodules: how to put my own files into submodules?
I am using vim with pathogen开发者_如何转开发 and all plugins installed as a submodules. This works great, but I've got a problem with one plugin - xptemplate. It requires putting personal code snippets into specific directory "bundle/xptemplate/personal/". I've created personal snippet for ruby and put it in "bundle/xptemplate/personal/ruby/ruby.xpt.vim" and it works... but doing "git submodule update" reverts my work. And updating plugins is a thing that I would like to do from time to time. Another disadvantage is that I cannot easily clone my vim config on another machine - I had to copy this file manually.
Is there a way to do it right? I thought about adding something like "personal/*" to .gitignore file in "bundle/xptemplate". I have not tested it, but even if it worked it would solve only problem with reverting my work by submodule update, and not allow me to push my snippets to github.
I will appreciate any help.
This is completely independent of vim and pathogen, just a general answer about how submodules can be used.
If you want to modify a submodule of a project, you must do the following:
end up with a new commit checked out in the submodule (for example by committing to it)
add the updated submodule to the superproject, and commit that
So, if you want to change one of your plugin submodules, edit away, then before you do anything like a submodule update, commit them to the submodule, come back up to the superproject, add the changes to the submodule, and commit there too.
You made a comment about "pushing [your changes] to github." If you want to do that, you'll need to be sure to push the changes in the submodule too; the superproject has to be able to fetch the needed commit of the submodule to check out! Of course, this means that if you're using plugins written by others and can't push back to them, you'll want to throw your version (a fork, if you will) up on github and use that as the authoritative source for your superproject.
If you need more help adapting all this to fit your specific setup, leave me a comment and I'll work with you.
xptemplate searches all of the 'runtimepath'(see :help runtimepath) to find snippet files like "*.xpt.vim".
Thas way you don't need to put your own snippets in the submodule folder. But just add the folder containing your snippet to 'runtimepath'( in your .vimrc ):
set runtimepath+=/foo/bar
And path to your snippets should be: "/foo/bar/ruby/ruby.xpt.vim".
精彩评论