purarue / yadm-git.vim

Integrates yadm with vim-fugitive and vim-gitgutter, so you can manage your dotfiles without leaving vim
MIT License
12 stars 2 forks source link
vim vim-plugin yadm

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:

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](https://neovim.io/doc/user/builtin.html#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:

{
    'purarue/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