I'm newbie in git, so question may be really stupid, sorry for that. I mean, I even found here on stackoverflow questions pretty close to mine, but still don't understand how to solve problem correctly.

I have github repo with my dotfiles, including for vim. I'm using pathogen with vim, so natural way to get plugins seams to be

git submodule add https://github.com/msanders/snipmate.vim.git vim/bundle/snipmate
...
git submodule init
git submodule update
git submodule foreach git submodule init
git submodule foreach git submodule update

wich I found somewhere. Last four commands I simply added to my setup script to run every time I clone this repo.

The first problem is git status always shows me

# modified:   vim/bundle/snipmate (untracked content)
# ...

in the # Changed but not updated: section and git add vim/bundle/snipmate doesn't help. It is pretty annoying.

The second problem is I obviously don't wand to keep snipmate snippets as default, I want to change them, and because of pathogen snippets are stored in snipmate folder, which is submodule, not my own repo. Of course, I could simply clone them there, or even create a fork of some of them, but is doesn't seem like a good solution:

  • It messes up my own code with other's code can be found on github;
  • I'm not really going to modify snipmate, I'm going to configure it;
  • All that stuff makes complicated or even impossible to update thirty-part plugins.

Maybe someone could help with finding a "correct" answer?

有帮助吗?

解决方案

You could start by reading snipmate's doc which states that the default recommended location for your own snippets is (supposing your stuff is under ~/.vim) ~/.vim/snippets/<filetype>.snippets. Outside of the plugin's directory, outside of the submodule.

Yes Git submodules are cool but they are probably not the perfect solution for managing your Vim config.

其他提示

I use snipmate and pathogen with vim. Pathogen makes using submodules possible (and much easier!)

My snipmate plugin is installed here:

.vim/bundle/snipmate

My snippets are installed here:

.vim/bundle/snipmate-snippets

An example snippet is here:

.vim/bundle/snipmate-snippets/snippets/c.snippets

I also have a work-specific repo with snippets. They're here:

.vim/bundle/work/snippets/cpp.snippets

So long as there's a snippets folder in your runtimepath (:help rtp), you're good. That's the magic of pathogen.

To setup my submodules I did:

git submodule add git://github.com/garbas/vim-snipmate.git bundle/snipmate
git submodule add git://github.com/honza/snipmate-snippets.git bundle/snipmate-snippets

When I want to update my vim repo I do this:

git pull origin master
git submodule update --init

If I actually change the remote for a submodule (like if I forked snipmate on github and want to point my local repo at the new fork), I change .gitmodules and do:

git submodule sync

By using submodules, it will make it easier to update git submodule git pull origin and easier to modify and push updates back to the maintainer.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top