Skip to content

Allow more complex parameters #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ Show commit log of current file:
:Tig!
```

Show blame view of current file:
```
:Tig! blame
```

You can also manually craft tig commands by using variable expansion:

* `%` will expand to the current file path
* `+` will expand to the current line number (prefixed with `+` so that tig
will jump to that line)

```
:Tig! blame +
:Tig blame + -- %
```
(These two actually result in the same tig command line being executed.)

Configuration
-------------
Tig executable: `let g:tig_executable = 'tig'`
Expand Down
20 changes: 14 additions & 6 deletions plugin/tig.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,22 @@ if has('nvim')
call termopen(g:tig_executable . ' ' . a:arg, s:callback)
endfunction

exec g:tig_open_command
let arg = ''
if a:0 > 0
let args = a:1
let args = substitute(args, '%', current, '')
let args = substitute(args, '+', '+' . line('.'), '')
let arg .= ' ' . args
endif
if a:bang > 0
call s:tigopen(current)
elseif a:0 > 0
call s:tigopen(a:1)
else
call s:tigopen(g:tig_default_command)
let arg .= ' -- ' . current
endif
if len(arg) == 0
let arg = g:tig_default_command
endif

exec g:tig_open_command
call s:tigopen(arg)
setlocal nonumber
setlocal norelativenumber
setlocal signcolumn=no
Expand Down