5 ms·
Very early on in my vim journey, I used to use fugitive[1], which is sort of a lighter equivalent of magit for vim. However, I found that too overkill and unwie
by ackyshake 5y ago
Very early on in my vim journey, I used to use fugitive[1], which is sort of a lighter equivalent of magit for vim. However, I found that too overkill and unwieldy. I never really found any benefits to forcing myself to stay inside vim to run some git command.
These days, I just use git in a tmux split rather than trying to force vim to show some arbitrary git UI. For a nice interactive git UI, I use tig[1]. Tig is essentially like fugitive/magic insofar as it allows me to interactively view a nice graphical log, stage/commit, traverse a file's historical blame, etc. It's a nicer UI compared to something like `gitk`.
I have these mappings in my `~/.vim/vimrc` for git/tig functionalities:
nnoremap gb :<C-u>echo system('git rev-parse --abbrev-ref @ <bar> tr -d "\n"')<CR>
nnoremap gB :<C-u>silent !tig blame <C-r>=shellescape(expand("%"))<CR> +<C-r>=expand(line('.'))<CR><CR>:silent redraw!<CR>
nnoremap gO :<C-u>silent !tig<CR>:silent redraw!<CR>
[1]: https://github.com/tpope/vim-fugitive https://github.com/tpope/vim-fugitive
[2]: https://github.com/jonas/tig https://github.com/jonas/tig
- rjzzleep 5y agoWell that's useful. I've been using `!tig` forever. For some reason it was convenient enough for me to never turn it into a mapping. I feel like `tig` damaged me in the sense that using tig and then pressing `S` is my usual workflow, so I just can't get used to either fugitive or magit. Thanks for these mappings
- probotect0r 5y agoI have started using lazygit in tmux splits or neovim terminals and I love it!
- sodapopcan 5y agoFugitive is really useful for a lot of stuff, though I don't use anywhere near all of its functionality. For example, I never rebase within vim. But blaming and especially staging/committing is a far better experience with fugitive than in plain terminal.
- imbnwa 5y agoAlso `blame` and `grep`
- sodapopcan 5y agoI mentioned blame! :) I also make heavy use of :Gedit for easily looking at files on other branches.
- imbnwa 5y agoMissed that. Never used :Gedit, appears hella convenient
- sodapopcan 5y ago:Gedit master:% is a common one I use to see what the current file looks like on master.
- ackyshake 5y agoThere is interactive blaming, staging and committing with tig too, so give that a try. That said though, I actually prefer using the shell to stage and commit stuff. I think I'm way faster when I'm on the shell performing those actions than in either tig or fugitive.
- sodapopcan 5y agoTig looks great but fugitive is in my fingers (been using it for something like 7 or 8 years at this point). I'll still check it out. Not sure when the last time you used fugitive but there was a major overhaul a couple of years ago. You can expand diffs in the commit window and stage parts of the files. But obviously, stick with what you're comfortable with!
- lowski_ 5y agoI'm not sure what I did wrong but your mapping didn't work for me on Neovim - it either immediately closed the terminal or didn't know what <bar> means. Eventually I moved to https://github.com/codeindulgence/vim-tig https://github.com/codeindulgence/vim-tig which does the same via `:Tig` and `:Tig!`. I added those mappings to achieve something similar: nnoremap <leader>gb :Tig! blame<cr> nnoremap <leader>g0 :Tig! status<CR> Thank you for inspiration! Tig FTW!
- ackyshake 5y agoI don't use neovim so I don't know what the differences are. The commands work fine for me in vim however.
- cloverr20 5y agoAll the mapping worked fine for me as well in vim, and I found gB to be super useful, earlier I had to go first in tree view and then select the file and then use the blame view.
- iberianpig 5y agoPlease check best tig integration for vim. https://github.com/iberianpig/tig-explorer.vim https://github.com/iberianpig/tig-explorer.vim