├── LICENSE ├── README.md └── plugin └── tig.vim /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Nick Butler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vim Tig 2 | ======= 3 | Love [Tig](https://github.com/jonas/tig)? Me too! 4 | Love Vim? OMG we're totes the same! 5 | So here's a simple plugin to make calling tig in vim easy peasy. 6 | 7 | Requirements 8 | ------------ 9 | Neovim. This plugin uses Neovim's built in terminal; therefore it will crash 10 | and burn on classic Vim. Classic support may be added if either 11 | 12 | 1. enough people want it 13 | 2. I go back to classic Vim 14 | 3. someone else does it :) 15 | 16 | Installation 17 | ------------ 18 | Use your favourite plugin manager. 19 | 20 | Usage 21 | ----- 22 | Simply run `:Tig` 23 | or bind a key to it, e.g.: 24 | ``` 25 | map :Tig 26 | ``` 27 | 28 | Pass tig commands: 29 | ``` 30 | :Tig show 31 | ``` 32 | 33 | Show commit log of current file: 34 | ``` 35 | :Tig! 36 | ``` 37 | 38 | Configuration 39 | ------------- 40 | Tig executable: `let g:tig_executable = 'tig'` 41 | Tig command to run: `let g:tig_default_command = 'status'` 42 | Vim command to run on tig exit: `let g:tig_on_exit = 'bw!'` 43 | Vim command before opening terminal: `let g:tig_open_command = 'enew'` 44 | 45 | Contributing 46 | ------------ 47 | 1. Fork it! 48 | 2. Create your feature branch: `git checkout -b my-new-feature` 49 | 3. Commit your changes: `git commit -am 'Add some feature'` 50 | 4. Push to the branch: `git push origin my-new-feature` 51 | 5. Submit a pull request :D 52 | 53 | Credits 54 | ------- 55 | [Nick Butler](https://www.codeindulgence.com) 56 | 57 | Additional thanks to [Mizuchi](https://github.com/Mizuchi) for [vim-ranger](https://github.com/Mizuchi/vim-ranger/) which was used as a reference. 58 | -------------------------------------------------------------------------------- /plugin/tig.vim: -------------------------------------------------------------------------------- 1 | if has('nvim') 2 | if !exists('g:tig_executable') 3 | let g:tig_executable = 'tig' 4 | endif 5 | 6 | if !exists('g:tig_default_command') 7 | let g:tig_default_command = 'status' 8 | endif 9 | 10 | if !exists('g:tig_on_exit') 11 | let g:tig_on_exit = 'bw!' 12 | endif 13 | 14 | if !exists('g:tig_open_command') 15 | let g:tig_open_command = 'enew' 16 | endif 17 | 18 | function! s:tig(bang, ...) 19 | let s:callback = {} 20 | let current = expand('%') 21 | let s:altfile = expand('#') 22 | 23 | function! s:callback.on_exit(id, status, event) 24 | exec g:tig_on_exit 25 | if !empty(s:altfile) 26 | let @# = s:altfile 27 | endif 28 | endfunction 29 | 30 | function! s:tigopen(arg) 31 | call termopen(g:tig_executable . ' ' . a:arg, s:callback) 32 | endfunction 33 | 34 | exec g:tig_open_command 35 | if a:bang > 0 36 | call s:tigopen(current) 37 | elseif a:0 > 0 38 | call s:tigopen(a:1) 39 | else 40 | call s:tigopen(g:tig_default_command) 41 | endif 42 | setlocal nonumber 43 | setlocal norelativenumber 44 | setlocal signcolumn=no 45 | setlocal filetype=tig 46 | startinsert 47 | endfunction 48 | 49 | command! -bang -nargs=? Tig call s:tig(0, ) 50 | endif 51 | --------------------------------------------------------------------------------