[
  {
    "path": "README.md",
    "content": "# File-line\n\n### Plugin for vim to enable opening a file in a given line\n\nWhen you open a `file:line`, for instance when coping and pasting from an error from your\ncompiler vim tries to open a file with a colon in its name.\n\nExamples:\n  \n    vim index.html:20\n    vim app/models/user.rb:1337\n\nWith this little script in your plugins folder if the stuff after the colon is a number and\na file exists with the name especified before the colon vim will open this file and take you\nto the line you wished in the first place. \n\nThis script is licensed with GPLv3 and you can contribute to it on github at\n[github.com/bogado/file-line](https://github.com/bogado/file-line).\n \n## Install details\n\nIf you use `Bundle`, add this line to your `.vimrc`:\n\n    Bundle 'bogado/file-line'\n  \nAnd launch `:BundleInstall` in vim.\n\nOr just copy the file into your plugins path (`$HOME/.vim/plugin` under unixes).\n\n"
  },
  {
    "path": "plugin/file_line.vim",
    "content": "\" Avoid installing twice or when in unsupported Vim version.\nif exists('g:loaded_file_line') || (v:version < 701)\n\tfinish\nendif\nlet g:loaded_file_line = 1\n\n\" below regexp will separate filename and line/column number\n\" possible inputs to get to line 10 (and column 99) in code.cc are:\n\" * code.cc(10)\n\" * code.cc(10:99)\n\" * code.cc:10\n\" * code.cc:10:99\n\"\n\" closing braces/colons are ignored, so also acceptable are:\n\" * code.cc(10\n\" * code.cc:10:\nlet s:regexpressions = [ '\\(.\\{-1,}\\)[(:]\\(\\d\\+\\)\\%(:\\(\\d\\+\\):\\?\\)\\?' ]\n\nfunction! s:reopenAndGotoLine(file_name, line_num, col_num)\n\tif !filereadable(a:file_name)\n\t\treturn\n\tendif\n\n\tlet l:bufn = bufnr(\"%\")\n\n\texec \"keepalt edit \" . fnameescape(a:file_name)\n\texec a:line_num\n\texec \"normal! \" . a:col_num . '|'\n\tif foldlevel(a:line_num) > 0\n\t\texec \"normal! zv\"\n\tendif\n\texec \"normal! zz\"\n\n\texec \"bwipeout \" l:bufn\n\texec \"filetype detect\"\nendfunction\n\nfunction! s:gotoline()\n\tlet file = bufname(\"%\")\n\n\t\" :e command calls BufRead even though the file is a new one.\n\t\" As a workaround Jonas Pfenniger<jonas@pfenniger.name> added an\n\t\" AutoCmd BufRead, this will test if this file actually exists before\n\t\" searching for a file and line to goto.\n\tif (filereadable(file) || file == '')\n\t\treturn file\n\tendif\n\n\tlet l:names = []\n\tfor regexp in s:regexpressions\n\t\tlet l:names =  matchlist(file, regexp)\n\n\t\tif ! empty(l:names)\n\t\t\tlet file_name = l:names[1]\n\t\t\tlet line_num  = l:names[2] == ''? '0' : l:names[2]\n\t\t\tlet  col_num  = l:names[3] == ''? '0' : l:names[3]\n\t\t\tcall s:reopenAndGotoLine(file_name, line_num, col_num)\n\t\t\treturn file_name\n\t\tendif\n\tendfor\n\treturn file\nendfunction\n\n\" Handle entry in the argument list.\n\" This is called via `:argdo` when entering Vim.\nfunction! s:handle_arg()\n\tlet argname = expand('%')\n\tlet fname = s:gotoline()\n\tif fname != argname\n\t\tlet argidx = argidx()\n\t\texec (argidx+1).'argdelete'\n\t\texec (argidx)'argadd' fnameescape(fname)\n\tendif\nendfunction\n\nfunction! s:startup()\n\tautocmd BufNewFile * nested call s:gotoline()\n\tautocmd BufRead * nested call s:gotoline()\n\n\tif argc() > 0\n\t\tlet argidx=argidx()\n\t\tsilent call s:handle_arg()\n\t\texec (argidx+1).'argument'\n\t\t\" Manually call Syntax autocommands, ignored by `:argdo`.\n\t\tdoautocmd Syntax\n\t\tdoautocmd FileType\n\tendif\nendfunction\n\nif !isdirectory(expand(\"%:p\"))\n\tautocmd VimEnter * call s:startup()\nendif\n"
  }
]