Giter Site home page Giter Site logo

iberianpig / tig-explorer.vim Goto Github PK

View Code? Open in Web Editor NEW
203.0 5.0 14.0 49 KB

Vim plugin to use Tig as a git client. Seamless switching between vim and Tig with opening in the same buffer.

License: MIT License

Vim Script 79.67% Shell 20.33%
tig vim git vim-plugins

tig-explorer.vim's Introduction

tig-explorer.vim

Vim plugin to use Tig as a git client.

  • Seamless switching between Vim and Tig
  • Adding buffer in the same process, not a child of Tig process.
  • Open files in tabs or vertically / horizontal split windows on Vim from Tig
  • Dynamically defining keymaps on Tig
  • Support Vim8 / NeoVim terminal
  • Open diff-mode side by side at the selected commit from Tig

https://gyazo.com/181fef546cced7ca6dc651dff59cd1bf

Requirement

Installation

" vim-plug
Plug 'iberianpig/tig-explorer.vim'

" NeoBundle
NeoBundle 'iberianpig/tig-explorer.vim'

NOTE: If you use Neovim, you have to add the dependency to the plugin bclose.vim:

" vim-plug
Plug 'rbgrouleff/bclose.vim'

" NeoBundle
NeoBundle 'rbgrouleff/bclose.vim'

Usage

Keymap on Tig

Following commands are available on Tig launched from tig-explorer.

e, <Ctrl-o>: edit on existing tab
<Ctrl-t>   : edit on new tab
<Ctrl-v>   : edit with vsplit window
<Ctrl-s>   : edit with split window

<ESC> o: open with commit on existing tab
<ESC> t: open with commit on new tab
<ESC> v: open with commit with vsplit window
<ESC> s: open with commit with split window

Keymaps are available in the main, blame, tree, and refs views. When opened with the commit, it opens in read-only mode. When opening with commit with split or vsplit, it will open with diffsplit.

Customize Keymap on Tig

tig-explorer.vim defines the following keymap by default

let g:tig_explorer_keymap_edit_e  = 'e'
let g:tig_explorer_keymap_edit    = '<C-o>'
let g:tig_explorer_keymap_tabedit = '<C-t>'
let g:tig_explorer_keymap_split   = '<C-s>'
let g:tig_explorer_keymap_vsplit  = '<C-v>'

let g:tig_explorer_keymap_commit_edit    = '<ESC>o'
let g:tig_explorer_keymap_commit_tabedit = '<ESC>t'
let g:tig_explorer_keymap_commit_split   = '<ESC>s'
let g:tig_explorer_keymap_commit_vsplit  = '<ESC>v'

Keymap on Vim

Add following script to ~/.vimrc

" open tig with current file
nnoremap <Leader>T :TigOpenCurrentFile<CR>

" open tig with Project root path
nnoremap <Leader>t :TigOpenProjectRootDir<CR>

" open tig grep
nnoremap <Leader>g :TigGrep<CR>

" resume from last grep
nnoremap <Leader>r :TigGrepResume<CR>

" open tig grep with the selected word
vnoremap <Leader>g y:TigGrep<Space><C-R>"<CR>

" open tig grep with the word under the cursor
nnoremap <Leader>cg :<C-u>:TigGrep<Space><C-R><C-W><CR>

" open tig blame with current file
nnoremap <Leader>b :TigBlame<CR>

Other options

By default, tig-explorer will use the built-in terminal if available. To force launching tig-explorer as a shell command, you can add the following to ~/.vimrc

" don't use builtin terminal
let g:tig_explorer_use_builtin_term=0

On Gvim, it is available only built-in terminal.

Support

Patreon

tig-explorer.vim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tig-explorer.vim's Issues

Neovim support

Currently this doesn't work on Neovim. ๐Ÿ˜ข The reason is that terminal applications launched by :! <appname> can't accept interactive input on stdin:

		The command runs in a non-interactive shell connected
		to a pipe (not a terminal). Use |:terminal| to run an
		interactive shell connected to a terminal.

A neat solution would be to use the builtin terminal in vim8/neovim to launch tig instead, similar to how fzf-vim works.

Should be working even if tigrc is not found

Even when tigrc is not found it should be working using a sensible default setting without error messages.

Error detected while processing function <SNR>176_initialize:
line   18:
tigrc is not found

Encoding cyrilic text for vim-tig window

I prefer, that terminal mode doesn't transcribe text to utf-8
this options not work

    encoding = 'utf-8';
    termencoding = 'utf-8';
    fileencoding = 'utf-8';
    makeencoding = 'utf-8';

I have this format on commits preview. It must be a cyrilic.
Default tig shell command works fine

image

It does not work if the path to start vim is other than project root.

Hi.
If the path that starts vim is not the project root, the following occurs.

  • When you open a file in Tig by executing the Tig command, the path becomes a new file
  • Error when TigBlame command is executed
    • tig: No blame exist for #{Relative path of the current directory}#{Absolute path opened in Vim}

This product is awesome. Thanks:)

Got errors when first open tig-explorer in vim: Invalid argument & Undefined variables

Just upgraded tig-explorer and got these messages only at the first time I open tig-explorer in vim. After this, it works fine in the same vim session. Any insights? Thanks!

BTW, my environment is:

  • nvim 0.4.3
  • Python3.7
  • MacOS
  • tig 2.4.1
  • tig-explorer latest commit: ae0d30c
Error detected while processing /Users/someone/dotfiles/vim/plugged/tig-explorer.vim/autoload/tig_explorer.vim:
line   92:
E475: Invalid argument: diff, mods, commit='HEAD', file='', lineno=0)
line   94:
E121: Undefined variable: a:file
E15: Invalid expression: a:file == ''
line  101:
E121: Undefined variable: file0
E116: Invalid arguments for function split
E15: Invalid expression: split(file0, ':')
line  102:
E121: Undefined variable: parts
E116: Invalid arguments for function len
E15: Invalid expression: len(parts) == 2
line  109:
E121: Undefined variable: a:diff
E15: Invalid expression: a:diff == '!'
line  112:
E121: Undefined variable: commit
E15: Invalid expression: commit.":".file
line  113:
E121: Undefined variable: ref
line  114:
E121: Undefined variable: ref
E116: Invalid arguments for function bufexists
E15: Invalid expression: bufexists(ref)
line  138:
E193: :endfunction not inside a function
Error detected while processing function tig_explorer#blame:
line    9:
E684: list index out of range: 0
E116: Invalid arguments for function <SNR>169_exec_tig_command

TigOpenFileWithCommit is broken

:TigOpenFileWithCommit without arguments used to call tig_explorer#open_file_with_commit with no arguments using the default value being the current file and head.

:TigOpenFileWithCommit! would then open a diff with the current head version. Handy to see what has changed. This doesn't work anymore since tig_explorer#open_file_with_commit has been changed to only accept a fixed number of argument (I'm not sure why).
Now you have to type explicitely :TigOpenFileWithCommit HEAD % 0.

What a fantastic plugin!!!

Just wanted to thank you for creating this gem of a plugin.

Simple, elegant and powerful. Love the commands provided. This is THE plugin for git in vim.

Hats off.

Don't hardcode temporary paths

Currently the following paths are hardcoded in the plugin:

  • /tmp/.tigrc
  • /tmp/tig_explorer_current_file

This will cause issues where /tmp isn't writable, multiple users on the same system use this plugin, etc.

A better solution would be use something like tempname() to generate a filename that will be guaranteed to be secure and writable.

hangs when suspended

If go into tig from vim, if I suspend the tig process with Ctrl-Z, everything hangs.

The only way to get out is to send SIGCONT to the tig process from the command line.

Hangs in gvim

Is the plugin supposed to work in gvim? tig works fine if I run it with :terminal tig.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.