yadm-git.vim

Integrates yadm with vim-fugitive and vim-gitgutter, so you can manage your dotfiles without leaving vim

MIT License

Stars
11

yadm-git.vim

Integrates yadm with vim-fugitive and vim-gitgutter so you can manage your dotfiles without leaving vim.

Whenever a buffer is loaded, uses yadm ls-files to detect if the current file is tracked by yadm. If it is, this:

  • runs FugitiveDetect from vim-fugitive, so fugitive can act on the yadm git repo. All fugitive bindings stay the same
  • sets g:gitgutter_git_executable to yadm, which causes vim-gitgutter to show changed git hunks using yadm

When you stop editing the dotfile (switch to a file which yadm isn't tracking), it resets them back to the defaults (Fugitive does that automatically).

For gitsigns yadm support, see gitsigns-yadm.nvim

Install

This uses jobstart, so it requires neovim. Am quite new to writing plugins, so would appreciate feedback and/or contributions for compatibility with vim

Should work with all vim plugin managers -- load the file in plugin

For example, using lazy:

{
    'seanbreckenridge/yadm-git.vim',
    event = "BufWinEnter",
    config = function()
        vim.g.yadm_git_fugitive_enabled = 0
    end
}

Configuration:

let g:yadm_git_enabled = 1 " setting this to 0 disables the plugin
let g:yadm_git_verbose = 0 " prints when it yadm ls-files detects a file

let g:yadm_git_fugitive_enabled = 1
let g:yadm_git_gitgutter_enabled = 1

" the location of your yadm repo (this is the default for yadm)
" used with FugitiveDetect when it detects a dotfile
let g:yadm_git_repo_path = "~/.local/share/yadm/repo.git"
" to 'reset' gitgutter git path after switching buffers
" to a non-dotfile. you probably dont need to set this
let g:yadm_git_default_git_path = "git"

Known Issues

Sometimes when switching back to a git repository from a dotfile, GitGutter doesn't redraw the hunks. This can be fixed by running :GitGutter to force a redraw