anishathalye / dotbot

A tool that bootstraps your dotfiles ⚡️
MIT License
6.9k stars 287 forks source link

Trying to link a file from a submodule into a subdirectory of a directory managed by dotbot #337

Open StFS opened 1 year ago

StFS commented 1 year ago

I have a directory that I mange with dotbot:

- link:
  ~/.vim: vim/

I also have a submodule in my dotfiles repo:

dotfiles/vim-modules/pathogen

Inside this submodule, there is a file (pathogen/autoload/pathogen.vim) that I need to place in ~/.vim/autoload/pathogen.vim so that vim autoloads that plugin.

I've tried doing it like this (trying to symlink the file from the submodule into the dotfiles vim directory so that the ~/.vim/ symlink will have it included):

- link:
    ~/.vim: vim/
    vim/autoload/pathogen.vim:
      create: true
      path: vim-modules/pathogen/autoload/pathogen.vim

But this is not working.

The error I'm getting is:

Nonexistent source vim/autoload/pathogen.vim -> vim-modules/pathogen/autoload/pathogen.vim

Is there some way to make dotfiles create a symlink inside the dotfiles directory itself?

I hope I'm making myself understood here... but probably not... sorry about that 😞

anishathalye commented 1 year ago

You can do this, but I suggest an alternative approach. Here are four different ways I think you can achieve your goal of loading Vim plugins (1 is most recommended, 4 is least recommended).

  1. Use Vim 8's native package loading. This is what I'm using in my dotfiles currently.
  2. If you want to use Pathogen: use the runtime function in your vimrc to load Pathogen, no symlink necessary. This is what I used to do in my dotfiles.
  3. If you want a symlink: you can add symlinks in a Git repo itself, so you can just ln -s ... and check in that file into Git.
  4. If you want Dotbot to create that symlink for you: have two separate link: steps (so they are ordered with respect to each other), and for the second one, set the link target to ~/.vim/autoload/pathogen.vim (assuming the autoload directory exists already; if not, you will need to create: it using Dotbot). You will also need to add the file to your .gitignore.