[
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 Kohei Yamada\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# tig-explorer.vim\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Vim](https://img.shields.io/badge/Vim-8.0+-green.svg)](https://www.vim.org/)\n[![Neovim](https://img.shields.io/badge/Neovim-0.3+-green.svg)](https://neovim.io/)\n\nVim plugin to use [Tig](https://github.com/jonas/tig) as a git client.\n* Seamless switching between Vim and Tig\n* Adding buffer in the same process, not a child of Tig process.\n* Open files in tabs or vertically / horizontal split windows on Vim from Tig\n* Dynamically defining keymaps on Tig\n* Support Vim8 / NeoVim terminal\n* Open diff-mode side by side at the selected commit from Tig\n\n[![https://gyazo.com/181fef546cced7ca6dc651dff59cd1bf](https://i.gyazo.com/181fef546cced7ca6dc651dff59cd1bf.gif)](https://gyazo.com/181fef546cced7ca6dc651dff59cd1bf)\n\n## Table of Contents\n\n- [Requirement](#requirement)\n- [Installation](#installation)\n- [Commands](#commands)\n- [Usage](#usage)\n  - [Keymap on Tig](#keymap-on-tig)\n  - [Customize Keymap on Tig](#customize-keymap-on-tig)\n  - [Keymap on Vim](#keymap-on-vim)\n- [Configuration](#configuration)\n- [License](#license)\n\n## Requirement\n\n* [tig](https://github.com/jonas/tig)\n\n## Installation\n\n### [lazy.nvim](https://github.com/folke/lazy.nvim)\n\n```lua\n{\n  'iberianpig/tig-explorer.vim',\n  dependencies = { 'rbgrouleff/bclose.vim' }, -- required for Neovim\n}\n```\n\n### [packer.nvim](https://github.com/wbthomason/packer.nvim)\n\n```lua\nuse {\n  'iberianpig/tig-explorer.vim',\n  requires = { 'rbgrouleff/bclose.vim' }, -- required for Neovim\n}\n```\n\n### [vim-plug](https://github.com/junegunn/vim-plug)\n\n```vim\nPlug 'iberianpig/tig-explorer.vim'\nPlug 'rbgrouleff/bclose.vim' \" required for Neovim\n```\n\n**NOTE: If you use Neovim, you have to add the dependency to the plugin [bclose.vim](https://github.com/rbgrouleff/bclose.vim).**\n\n## Commands\n\n| Command | Description |\n|---------|-------------|\n| `:Tig [args]` | Open Tig with optional arguments |\n| `:TigOpenCurrentFile` | Open Tig with the current file |\n| `:TigOpenProjectRootDir` | Open Tig at the project root directory |\n| `:TigGrep [pattern]` | Run Tig grep (prompts for pattern if omitted) |\n| `:TigGrepResume` | Resume the last Tig grep search |\n| `:TigBlame` | Open Tig blame for the current file |\n| `:TigStatus` | Open Tig status view |\n| `:TigOpenFileWithCommit [commit] [file] [lineno]` | Open a file at the specified commit in read-only mode |\n| `:TigOpenFileWithCommit! [commit] [file] [lineno]` | Open a file at the specified commit with diffsplit |\n\n## Usage\n\n### Keymap on Tig\n\nFollowing commands are available on Tig launched from tig-explorer.\n```\ne, <Ctrl-o>: edit on existing tab\n<Ctrl-t>   : edit on new tab\n<Ctrl-v>   : edit with vsplit window\n<Ctrl-s>   : edit with split window\n\n<ESC> o: open with commit on existing tab\n<ESC> t: open with commit on new tab\n<ESC> v: open with commit with vsplit window\n<ESC> s: open with commit with split window\n```\n\nKeymaps are available in the main, blame, tree, and refs views.\nWhen opened with the commit, it opens in read-only mode.\nWhen opening with commit with split or vsplit, it will open with diffsplit.\n\n#### Customize Keymap on Tig\n\ntig-explorer.vim defines the following keymap by default\n\n```vim\nlet g:tig_explorer_keymap_edit_e  = 'e'\nlet g:tig_explorer_keymap_edit    = '<C-o>'\nlet g:tig_explorer_keymap_tabedit = '<C-t>'\nlet g:tig_explorer_keymap_split   = '<C-s>'\nlet g:tig_explorer_keymap_vsplit  = '<C-v>'\n\nlet g:tig_explorer_keymap_commit_edit    = '<ESC>o'\nlet g:tig_explorer_keymap_commit_tabedit = '<ESC>t'\nlet g:tig_explorer_keymap_commit_split   = '<ESC>s'\nlet g:tig_explorer_keymap_commit_vsplit  = '<ESC>v'\n```\n\n### Keymap on Vim\n\nAdd following script to ~/.vimrc\n\n```vim\n\" open tig with current file\nnnoremap <Leader>T :TigOpenCurrentFile<CR>\n\n\" open tig with Project root path\nnnoremap <Leader>t :TigOpenProjectRootDir<CR>\n\n\" open tig grep\nnnoremap <Leader>g :TigGrep<CR>\n\n\" resume from last grep\nnnoremap <Leader>r :TigGrepResume<CR>\n\n\" open tig grep with the selected word\nvnoremap <Leader>g y:TigGrep<Space><C-R>\"<CR>\n\n\" open tig grep with the word under the cursor\nnnoremap <Leader>cg :<C-u>:TigGrep<Space><C-R><C-W><CR>\n\n\" open tig blame with current file\nnnoremap <Leader>b :TigBlame<CR>\n```\n\n## Configuration\n\n### Terminal\n\nBy default, tig-explorer will use the built-in terminal if available.\nTo force launching tig-explorer as a shell command, you can add the following to\n~/.vimrc\n\n```vim\n\" don't use builtin terminal\nlet g:tig_explorer_use_builtin_term=0\n```\n\nOn Gvim, only the built-in terminal is available.\n\n### Custom tigrc\n\nIf you have a custom tigrc file in a non-standard location, you can specify it:\n\n```vim\nlet g:tig_explorer_orig_tigrc='/path/to/your/tigrc'\n```\n\nBy default, tig-explorer searches for your tigrc in the following order:\n1. `$XDG_CONFIG_HOME/tig/config`\n2. `~/.config/tig/config`\n3. `~/.tigrc`\n4. `/etc/tigrc`\n\n## License\n\n[MIT](LICENSE) - Copyright (c) 2017 Kohei Yamada\n"
  },
  {
    "path": "autoload/tig_explorer.vim",
    "content": "\"=============================================================================\n\" File: tig_explorer.vim\n\" Author: iberianpig\n\" Created: 2017-04-03\n\"=============================================================================\n\nscriptencoding utf-8\n\nif !exists('g:loaded_tig_explorer')\n  finish\nendif\nlet g:loaded_tig_explorer = 1\n\nlet s:save_cpo = &cpoptions\nset cpoptions&vim\n\n\" Public\n\nfunction! tig_explorer#open(str, ...) abort\n  let args = a:0 ? join(a:, ' ') : ''\n  let command = s:strip_commit(a:str) . ' ' . args\n  call s:exec_tig_command(command)\nendfunction\n\nfunction! tig_explorer#open_current_file() abort\n  let current_path = expand('%:p')\n  :call tig_explorer#open(current_path)\nendfunction\n\nfunction! tig_explorer#open_project_root_dir() abort\n  try\n    let root_dir = s:project_root_dir()\n  catch\n    echoerr 'tig-explorer.vim: ' . v:exception\n    return\n  endtry\n  :call tig_explorer#open(root_dir)\nendfunction\n\nfunction! tig_explorer#grep(str) abort\n  if a:str ==# ''\n    let word = s:input('Pattern: ')\n  else\n    let word = a:str\n  endif\n\n  \" if canceled\n  if word ==# '0'\n    return\n  elseif word ==# '-1'\n    return\n  endif\n\n  let g:tig_explorer_last_grep_keyword = word\n\n  \" NOTE: Escape shellwords\n  if !get(g:, 'tig_explorer_use_builtin_term', has('terminal'))\n    let args = s:shellwords(word)\n    let escaped_word = ''\n\n    for arg in args\n      let escaped_word = join([escaped_word, shellescape(arg, 1)], ' ')\n    endfor\n    let word = escaped_word\n  endif\n\n  :call s:exec_tig_command('grep ' . word)\nendfunction\n\nfunction! tig_explorer#grep_resume() abort\n  let keyword = get(g:, 'tig_explorer_last_grep_keyword', '')\n  :call tig_explorer#grep(keyword)\nendfunction\n\nfunction! tig_explorer#blame() abort\n  \" extract the current commit if a path as the shape commit:file\n  \" which happend when using TigOpenWithCommit\n  let parts = split(expand('%'), ':')\n  if len(parts) == 2\n    let commit = parts[0]\n    let file = parts[1]\n    call s:exec_tig_command('blame ' . commit .' +' . line('.') . ' -- '. fnameescape(file))\n  else\n    let root_dir = fnamemodify(s:project_root_dir(), ':p')\n    let file = substitute(expand('%:p'), root_dir, \"./\", \"\")\n    call s:exec_tig_command('blame +' . line('.') . ' ' . fnameescape(file))\n  endif\nendfunction\n\nfunction! tig_explorer#status() abort\n  call s:exec_tig_command('status')\nendfunction\n\n\" Open a file for the given commit\n\" Usefull when editing file from tree or blame view\nfunction! tig_explorer#open_file_with_commit(diff, mods, commit, file, lineno)\n  let commit = get(a:, 'commit', 'HEAD')\n  let file = get(a:, 'file', '')\n  let lineno = get(a:, 'lineno', 0)\n\n  let file0 = ''\n  \" if no file is provided use the current one\n  if file == ''\n    let file0 = expand('%')\n    let diff = 1\n  else\n    let file0 = expand(file)\n  endif\n  \" split commit file if needed\n  echomsg file0\n  let parts = split(file0, ':')\n  if len(parts) == 2\n    let commit = substitute(commit, '%',  parts[0],'' )\n    let file = parts[1]\n  else\n    let file = parts[0]\n    let commit = substitute(commit, '%', 'HEAD','')\n  endif\n  if a:diff == '!'\n    diffthis\n  endif\n  let ref = commit . \":\" . file\n  echomsg ref\n  if bufexists(ref)\n    if a:diff == '!'\n      execute a:mods \"edit\" ref\n    else\n      execute a:mods \"split\" ref\n    endif\n  else\n    let ftype = &filetype\n    if a:diff == '!'\n      execute a:mods \"new\"\n    else\n      execute a:mods \"enew\"\n    endif\n    execute \"file\" ref\n    let git_output = system('git show ' . ref)\n    call setbufline(bufnr('%'), 1, split(git_output, '\\n'))\n    let &filetype = ftype\n    setlocal nomodified\n    setlocal nomodifiable\n    setlocal readonly\n    execute \"+\" lineno\n  endif\n  if a:diff == '!'\n    diffthis\n  endif\nendfunction\n\n\n\n\" Private\n\nfunction! s:tig_available() abort\n  if !executable('tig')\n    echoerr 'You need to install tig.'\n    return 0\n  endif\n  return 1\nendfunction\n\nfunction! s:initialize() abort\n\n  function! s:set_orig_tigrc(path) abort\n    if filereadable(expand(a:path))\n      let s:orig_tigrc=a:path\n      return 1 \"true\n    endif\n    return 0 \"fail\n  endfunction\n\n  if exists('g:tig_explorer_orig_tigrc')\n    let result = s:set_orig_tigrc(g:tig_explorer_orig_tigrc)\n  else\n    let result = s:set_orig_tigrc('$XDG_CONFIG_HOME/tig/config') ||\n          \\ s:set_orig_tigrc('~/.config/tig/config') ||\n          \\ s:set_orig_tigrc('~/.tigrc') ||\n          \\ s:set_orig_tigrc('/etc/tigrc')\n  endif\n  if !result\n    echomsg  'tig-explorer.vim: tigrc is not found'\n    let s:orig_tigrc = tempname() \"workaround\n    exec 'silent ! touch ' . s:orig_tigrc\n  endif\n\n  let s:tmp_tigrc = tempname()\n  let s:path_file = tempname()\n\n  let s:keymap_edit_e  = get(g:, 'tig_explorer_keymap_edit_e',  'e')\n  let s:keymap_edit    = get(g:, 'tig_explorer_keymap_edit',    '<C-o>')\n  let s:keymap_tabedit = get(g:, 'tig_explorer_keymap_tabedit', '<C-t>')\n  let s:keymap_split   = get(g:, 'tig_explorer_keymap_split',   '<C-s>')\n  let s:keymap_vsplit  = get(g:, 'tig_explorer_keymap_vsplit',  '<C-v>')\n\n  let s:keymap_commit_edit    = get(g:, 'tig_explorer_keymap_commit_edit',    '<ESC>o')\n  let s:keymap_commit_tabedit = get(g:, 'tig_explorer_keymap_commit_tabedit', '<ESC>t')\n  let s:keymap_commit_split   = get(g:, 'tig_explorer_keymap_commit_split',   '<ESC>s')\n  let s:keymap_commit_vsplit  = get(g:, 'tig_explorer_keymap_commit_vsplit',  '<ESC>v')\n\n\n  let s:before_exec_tig  = s:plugin_root . '/script/setup_tmp_tigrc.sh'\n        \\ . ' ' . s:orig_tigrc\n        \\ . ' ' . s:tmp_tigrc\n        \\ . ' ' . s:path_file\n        \\ . ' \"' . s:keymap_edit_e  . '\"'\n        \\ . ' \"' . s:keymap_edit    . '\"'\n        \\ . ' \"' . s:keymap_tabedit . '\"'\n        \\ . ' \"' . s:keymap_split   . '\"'\n        \\ . ' \"' . s:keymap_vsplit  . '\"'\n        \\ . ' \"' . s:keymap_commit_edit    . '\"'\n        \\ . ' \"' . s:keymap_commit_tabedit . '\"'\n        \\ . ' \"' . s:keymap_commit_split   . '\"'\n        \\ . ' \"' . s:keymap_commit_vsplit  . '\"'\n\n  let s:tig_prefix = 'TIGRC_USER=' . s:tmp_tigrc . ' '\nendfunction\n\nfunction! s:tig_callback(exit_code) abort\n  if a:exit_code == 0\n    if has('nvim')\n      silent! Bclose!\n    else\n      let current_buf = bufnr('%')\n      silent! buffer #\n      \" NOTE: Prevent to quit vim\n      if winnr('$') == 1 && bufnr('%') ==# current_buf\n        enew\n      endif\n    endif\n  endif\n\n  try\n    call s:open_file()\n  endtry\nendfunction\n\nfunction! s:exec_tig_command(tig_args) abort\n  if !s:tig_available()\n    return\n  endif\n\n  let current_dir = getcwd()\n  try\n    let root_dir = s:project_root_dir()\n  catch\n    echoerr 'tig-explorer.vim: ' . v:exception\n    return\n  endtry\n  \" NOTE: It MUST execute tig command from project root\n  \" TigBlame or Edit are broken if execute from a relative path\n  execute 'lcd ' . fnamemodify(root_dir, ':p')\n  if !filewritable(root_dir . '/.git')\n    echoerr(\".git is not writable\")\n    return\n  endif\n\n  let command = s:tig_prefix  . 'tig' . ' ' . a:tig_args\n  exec 'silent !' . s:before_exec_tig\n  if has('nvim')\n    enew\n    call termopen(command, {\n          \\ 'name': 'tig',\n          \\ 'on_exit': {job_id, code, event -> s:tig_callback(code)},\n          \\ })\n    startinsert\n  elseif has('gui_running') && has('terminal') || get(g:, 'tig_explorer_use_builtin_term', has('terminal'))\n    call term_start('env ' . command, {\n         \\ 'term_name': 'tig',\n         \\ 'curwin': v:true,\n         \\ 'term_rows' : winheight('%'),\n         \\ 'term_cols' : winwidth('%'),\n         \\ 'term_finish': 'close',\n         \\ 'exit_cb': {status, code -> s:tig_callback(code)},\n         \\ })\n  else\n    exec 'silent !' . command\n    call s:open_file()\n  endif\n  \" NOTE: Back to current_dir\n  execute 'lcd ' . fnamemodify(current_dir, ':p')\n  redraw!\nendfunction\n\nfunction! s:open_file() abort\n  if !filereadable(s:path_file)\n    return\n  endif\n\n  let current_dir = getcwd()\n  try\n    execute 'lcd ' . fnamemodify(s:project_root_dir(), ':p')\n    for f in readfile(s:path_file)\n      exec f\n    endfor\n  finally\n    call delete(s:path_file)\n    execute 'lcd ' . fnamemodify(current_dir, ':p')\n  endtry\nendfunction\n\nfunction! s:project_root_dir() abort\n  let l:current_file_dir = expand('%:p:h')\n  let l:git_dir = findfile('.git', l:current_file_dir . ';')\n  if l:git_dir ==# ''\n    let l:git_dir = finddir('.git', l:current_file_dir . ';')\n\n    if l:git_dir ==# ''\n      throw 'Not a git repository: ' . l:current_file_dir\n    endif\n\n    \" git submodule\n    let l:git_module_dir = finddir('modules', l:current_file_dir . ';')\n    if l:git_module_dir !=# ''\n      let l:git_module_dir_git = finddir('.git', fnamemodify(l:git_module_dir, ':p') . ';')\n      if fnamemodify(l:git_module_dir_git, ':p') ==# fnamemodify(l:git_dir, ':p')\n        let l:git_submodule_index = findfile('index', l:current_file_dir . ';')\n        if l:git_submodule_index !=# ''\n          let l:git_submodule_dir = fnamemodify(l:git_submodule_index, ':p:h')\n          let l:git_submodule_workdir = trim(system('cd ' . shellescape(l:git_submodule_dir) . ' && git config --get core.worktree'))\n          if l:git_submodule_workdir !=# ''\n            let l:git_submodule_workdir = glob(l:git_submodule_dir . '/' . l:git_submodule_workdir)\n            if isdirectory(l:git_submodule_workdir)\n              return l:git_submodule_workdir\n            endif\n          endif\n        endif\n      endif\n    endif\n  endif\n\n  \" git repository\n  if isdirectory(l:git_dir)\n    let l:root_dir = fnamemodify(l:git_dir, ':p:h:h')\n  else\n    let l:root_dir = fnamemodify(l:git_dir, ':p:h')\n  endif\n\n  if !isdirectory(l:root_dir)\n    return l:current_file_dir\n  endif\n  return l:root_dir\nendfunction\n\nfunction! s:shellwords(str) abort \"make list by splitting the string by whitespace\n  let words = split(a:str, '\\%(\\([^ \\t\\''\"]\\+\\)\\|''\\([^\\'']*\\)''\\|\"\\(\\%([^\\\"\\\\]\\|\\\\.\\)*\\)\"\\)\\zs\\s*\\ze')\n  let words = map(words, 'substitute(v:val, ''\\\\\\([\\\\ ]\\)'', ''\\1'', \"g\")')\n  let words = map(words, 'matchstr(v:val, ''^\\%\\(\"\\zs\\(.*\\)\\ze\"\\|''''\\zs\\(.*\\)\\ze''''\\|.*\\)$'')')\n  return words\nendfunction\n\n\n\" return 0 (<ESC>) or -1 (<Ctrl-c>)\nfunction! s:input(...) abort\n  new\n  cnoremap <buffer> <silent> <Esc> __CANCELED__<CR>\n  try\n    let input = call('input', a:000)\n    if input =~ '__CANCELED__'\n      call histdel('input', -1)\n      let input = 0\n    endif\n  catch /^Vim:Interrupt$/\n    let input = -1\n  finally\n    bwipeout!\n    redraw!\n    return input\n  endtry\nendfunction\n\nfunction! s:strip_commit(path)\n  return substitute(a:path, '^[^:]*:','','')\nendfunction\n\" Initialize\n\n\" NOTE: '<sfile>' must be called top level\nlet s:plugin_root=expand('<sfile>:p:h:h')\n\ncall s:initialize()\n\nlet &cpoptions = s:save_cpo\nunlet s:save_cpo\n\n\n"
  },
  {
    "path": "doc/tags",
    "content": ":TigBlame\ttig-explorer.txt\t/*:TigBlame*\n:TigGrep\ttig-explorer.txt\t/*:TigGrep*\n:TigGrepResume\ttig-explorer.txt\t/*:TigGrepResume*\n:TigOpenCurrentFile\ttig-explorer.txt\t/*:TigOpenCurrentFile*\n:TigOpenProjectRootDir\ttig-explorer.txt\t/*:TigOpenProjectRootDir*\ntig-explorer-commands\ttig-explorer.txt\t/*tig-explorer-commands*\ntig-explorer-contents\ttig-explorer.txt\t/*tig-explorer-contents*\ntig-explorer-customize\ttig-explorer.txt\t/*tig-explorer-customize*\ntig-explorer-install\ttig-explorer.txt\t/*tig-explorer-install*\ntig-explorer-introduction\ttig-explorer.txt\t/*tig-explorer-introduction*\ntig-explorer-keymaps\ttig-explorer.txt\t/*tig-explorer-keymaps*\ntig-explorer-requirements\ttig-explorer.txt\t/*tig-explorer-requirements*\ntig-explorer-support\ttig-explorer.txt\t/*tig-explorer-support*\ntig-explorer.txt\ttig-explorer.txt\t/*tig-explorer.txt*\n"
  },
  {
    "path": "doc/tig-explorer.txt",
    "content": "*tig-explorer.txt*  Plugin to use Tig as a git client.\n\n==============================================================================\nCONTENTS                                               *tig-explorer-contents*\n\n- Introduction                                     |tig-explorer-introduction|\n- Requirements                                     |tig-explorer-requirements|\n- Install                                               |tig-explorer-install|\n- Commands                                             |tig-explorer-commands|\n- Keymaps                                               |tig-explorer-keymaps|\n- Customize                                           |tig-explorer-customize|\n- Support                                               |tig-explorer-support|\n\n==============================================================================\nINTRODUCTION                                       *tig-explorer-introduction*\n\nThis plugins supports:\n\n- Seamless switching between Vim and Tig\n- Adding buffer in the same process not a child of Tig process.\n- Open files in tabs or in vertically/horizontal split windows on Vim from Tig\n- Dynamically defining keymaps on Tig\n\n==============================================================================\nREQUIREMENTS                                       *tig-explorer-requirements*\n\n- tig (https://github.com/jonas/tig)\n\n==============================================================================\nINSTALL                                                 *tig-explorer-install*\n\nBy vim-plug: >\n    Plug 'iberianpig/tig-explorer.vim'\n<\n\nBy NeoBundle: >\n    NeoBundle 'iberianpig/tig-explorer.vim'\n<\n\nIf you use Neovim, you have to add the dependency to the plugin bclose.vim:\n\nBy vim-plug: >\n    Plug 'rbgrouleff/bclose.vim'\n<\n\nBy NeoBundle: >\n    NeoBundle 'rbgrouleff/bclose.vim'\n<\n\n==============================================================================\nCOMMANDS                                               *tig-explorer-commands*\n\nAdd following script to ~/.vimrc\n\nTigOpenCurrentFile                                       *:TigOpenCurrentFile*\n    Open tig with current file\n\nTigOpenProjectRootDir                                 *:TigOpenProjectRootDir*\n    Open tig with Project root path\n\nTigGrep                                                             *:TigGrep*\n    Open tig grep.\n    And you can pass PATTERN like `:TigGrep (PATTERN)` to grep\n    with the PATTERN.\n\nTigGrepResume                                                 *:TigGrepResume*\n    Resume from last grep\n\nTigBlame                                                           *:TigBlame*\n    Open tig blame with current file\n\nTigOpenFileWithCommit\n    Open a file at the given commit.  `:TigOpenWithCommit COMMIT FILE LINEO`\n    All arguments are optional.\n    If FILE contains `%` and `FILE` is contains so commit information.\n    The `%` in the commit will be replaced with the original commit.\n\n    For example `:TigOpenWithCommit %~` open the previous version of the\n    current file. This file will be called `HEAD~:file`.\n    Calling `:TigOpenFileWithCommit %~` again will open the previous version\n    of the previous version (`HEAD~~`).\n\nTigOpenFileWithCommit!\n    Like TigOpenFileWithCommit but show the diff between the current buffer\n    and the resulting buffer.\n\n    For example, `:vertical TigOpenFileWithCommit! HEAD` set a side by side\n    diff between the current buffer and its HEAD version.\n\n==============================================================================\nKEYMAPS                                                 *tig-explorer-keymaps*\n\nFollowing commands are available on tig launched from tig-explorer\n\ne, <Ctrl-o>: edit on existing tab\n<Ctrl-t>   : edit on new tab\n<Ctrl-s>   : edit with split window\n<Ctrl-v>   : edit with vsplit window\n\n<ESC> o: open with commit on existing tab\n<ESC> t: open with commit on new tab\n<ESC> v: open with commit with vsplit window\n<ESC> s: open with commit with split window\n\n When a commit is available (in main, blame, tree, refs view) view, the\n version of the file corresponding to this commit will be open instead of the\n version in the working directory. Split versions will open the two buffer in\n diff mode.\n \n==============================================================================\nCUSTOMIZE                                             *tig-explorer-customize*\n\nKeymaps can be cusotmized by following variables.\n\nFollowing keymap is defined as defaut >\n    let g:tig_explorer_keymap_edit_e  = 'e'\n    let g:tig_explorer_keymap_edit    = '<C-o>'\n    let g:tig_explorer_keymap_tabedit = '<C-t>'\n    let g:tig_explorer_keymap_split   = '<C-s>'\n    let g:tig_explorer_keymap_vsplit  = '<C-v>'\n<\n\nAnd you can add following script to ~/.vimrc\n\n>\n    \" open tig with current file\n    nnoremap <Leader>T :TigOpenCurrentFile<CR>\n\n    \" open tig with Project root path\n    nnoremap <Leader>t :TigOpenProjectRootDir<CR>\n\n    \" open tig grep\n    nnoremap <Leader>g :TigGrep<CR>\n\n    \" resume from last grep\n    nnoremap <Leader>r :TigGrepResume<CR>\n\n    \" open tig grep with the selected word\n    vnoremap <Leader>g :TigGrep<Space><C-R>\"<CR>\n\n    \" open tig grep with the word under the cursor\n    nnoremap <Leader>cg :<C-u>:TigGrep<Space><C-R><C-W><CR>\n\n    \" open tig blame with current file\n    nnoremap <Leader>b :TigBlame<CR>\n<\n\nBy default tig-explorer will use the builtin terminal if available.\nTo force launching tig-explorer as shell command you can add the following to\n~/.vimrc\n\n>\n    \" don't use builtin terminal\n    let g:tig_explorer_use_builtin_term=0\n<\n\n==============================================================================\nSUPPORT                                                 *tig-explorer-support*\n\nhttps://www.patreon.com/iberianpig\n\nvim:textwidth=78:tabstop=4:shiftwidth=4:expandtab:filetype=help:norl:\n"
  },
  {
    "path": "plugin/tig_explorer.vim",
    "content": "\"=============================================================================\n\" File: tig_explorer.vim\n\" Author: iberianpig\n\" Created: 2017-04-03\n\"=============================================================================\n\nscriptencoding utf-8\n\nif exists('g:loaded_tig_explorer')\n    finish\nendif\nlet g:loaded_tig_explorer = 1\n\nlet s:save_cpo = &cpoptions\nset cpoptions&vim\n\ncommand! -nargs=? Tig\n      \\  call tig_explorer#open(<q-args>)\n\ncommand! TigOpenCurrentFile\n      \\  call tig_explorer#open_current_file()\n\ncommand! TigOpenProjectRootDir\n      \\  call tig_explorer#open_project_root_dir()\n\ncommand! -nargs=? TigGrep\n      \\  call tig_explorer#grep(<q-args>)\n\ncommand! TigBlame\n      \\  call tig_explorer#blame()\n\ncommand! TigGrepResume\n      \\  call tig_explorer#grep_resume()\n\ncommand! TigStatus\n      \\  call tig_explorer#status()\n\ncommand! -bang -nargs=* TigOpenFileWithCommit\n      \\ call tig_explorer#open_file_with_commit(\"<bang>\",<q-mods>,<f-args>)\n\nlet &cpoptions = s:save_cpo\nunlet s:save_cpo\n\n"
  },
  {
    "path": "script/setup_tmp_tigrc.sh",
    "content": "#!/bin/sh\n\nif [ $# -ne 12 ]; then\n  echo \"require 12 argument\"\n  exit 1\nfi\norig_tigrc=$1\ntmp_tigrc=$2\npath_file=$3\nkeymap_edit_e=$4\nkeymap_edit=$5\nkeymap_tabedit=$6\nkeymap_split=$7\nkeymap_vsplit=$8\nkeymap_commit_edit=$9\nkeymap_commit_tabedit=${10}\nkeymap_commit_split=${11}\nkeymap_commit_vsplit=${12}\n\n# make temporary tigrc\ncp \"$orig_tigrc\" \"$tmp_tigrc\"\n\n# Overwriting temporary tigrc\n\n\nadd_custom_cmd() {\n  view=$1\n  keymap=$2\n  cmd=$3\n  echo \"bind $view $keymap <sh -c \\\"echo $cmd +%(lineno) %(file) > $path_file\\\"\" >> \"$tmp_tigrc\"\n}\n\nadd_current_with_commit_cmd() {\n  view=$1\n  keymap=$2\n  cmd=$3\n  echo \"bind $view $keymap <sh -c \\\"echo $cmd %(commit) % %(lineno) > $path_file\\\"\" >> \"$tmp_tigrc\"\n}\n\nadd_selected_with_commit_cmd() {\n  view=$1\n  keymap=$2\n  cmd=$3\n  echo \"bind $view $keymap <sh -c \\\"echo $cmd %(commit) %(file) %(lineno) > $path_file\\\"\" >> \"$tmp_tigrc\"\n}\n\nif [ $keymap_edit_e != \"\" ]; then\n  add_custom_cmd \"generic\" \"$keymap_edit_e\"  \"edit\"\nfi\n\nadd_custom_cmd \"generic\" \"$keymap_edit\"    \"edit\"\nadd_custom_cmd \"generic\" \"$keymap_tabedit\" \"tabedit\"\nadd_custom_cmd \"generic\" \"$keymap_split\"   \"split\"\nadd_custom_cmd \"generic\" \"$keymap_vsplit\"  \"vsplit\"\n\nadd_current_with_commit_cmd \"refs\" \"$keymap_commit_edit\"    \"TigOpenFileWithCommit\"\nadd_current_with_commit_cmd \"refs\" \"$keymap_commit_tabedit\" \"tab TigOpenFileWithCommit\"\nadd_current_with_commit_cmd \"refs\" \"$keymap_commit_split\"   \"TigOpenFileWithCommit!\"\nadd_current_with_commit_cmd \"refs\" \"$keymap_commit_vsplit\"  \"vertical TigOpenFileWithCommit!\"\n\nadd_current_with_commit_cmd \"main\" \"$keymap_commit_edit\"    \"TigOpenFileWithCommit\"\nadd_current_with_commit_cmd \"main\" \"$keymap_commit_tabedit\" \"tab TigOpenFileWithCommit\"\nadd_current_with_commit_cmd \"main\" \"$keymap_commit_split\"   \"TigOpenFileWithCommit!\"\nadd_current_with_commit_cmd \"main\" \"$keymap_commit_vsplit\"  \"vertical TigOpenFileWithCommit!\"\n\nadd_selected_with_commit_cmd \"blame\" \"$keymap_commit_edit\"    \"TigOpenFileWithCommit\"\nadd_selected_with_commit_cmd \"blame\" \"$keymap_commit_tabedit\" \"tab TigOpenFileWithCommit\"\nadd_selected_with_commit_cmd \"blame\" \"$keymap_commit_split\"   \"TigOpenFileWithCommit!\"\nadd_selected_with_commit_cmd \"blame\" \"$keymap_commit_vsplit\"  \"vertical TigOpenFileWithCommit!\"\n\nadd_selected_with_commit_cmd \"diff\" \"$keymap_commit_edit\"    \"TigOpenFileWithCommit\"\nadd_selected_with_commit_cmd \"diff\" \"$keymap_commit_tabedit\" \"tab TigOpenFileWithCommit\"\nadd_selected_with_commit_cmd \"diff\" \"$keymap_commit_split\"   \"TigOpenFileWithCommit!\"\nadd_selected_with_commit_cmd \"diff\" \"$keymap_commit_vsplit\"  \"vertical TigOpenFileWithCommit!\"\n\nadd_selected_with_commit_cmd \"tree\" \"$keymap_commit_edit\"    \"TigOpenFileWithCommit\"\nadd_selected_with_commit_cmd \"tree\" \"$keymap_commit_tabedit\" \"tab TigOpenFileWithCommit\"\nadd_selected_with_commit_cmd \"tree\" \"$keymap_commit_split\"   \"TigOpenFileWithCommit!\"\nadd_selected_with_commit_cmd \"tree\" \"$keymap_commit_vsplit\"  \"vertical TigOpenFileWithCommit!\"\n"
  }
]