wsdjeg / vim-fetch

Make Vim handle line and column numbers in file names with a minimum of fuss
http://www.vim.org/scripts/script.php?script_id=5089
MIT License
312 stars 17 forks source link

Handle prefixes from (git) diff #12

Closed blueyed closed 8 years ago

blueyed commented 8 years ago

I've thought that we've talked about this before, but could not find it now.

I am using the following snippet to be able to open files from e.g. git-diff, where the prefix is ignored. It seems to be a good fit for this plugin?!

" Check if the new file (with git-diff prefix removed) is readable and
" edit that instead (copy'n'paste from shell).
" (for git diff: `[abiw]`).
au BufNewFile * nested let s:fn = expand('<afile>') |
  \ echom filereadable(s:fn) |
  \ if ! filereadable(s:fn) |
  \   let s:fn = substitute(s:fn, '^\S/', '', '') |
  \   if filereadable(s:fn) |
  \     exec 'edit' s:fn |
  \     bdelete # |
  \     redraw |
  \     echomsg 'Got unreadable file, editing' s:fn 'instead.' |
  \   endif |
  \ endif
kopischke commented 8 years ago

Yes we did, actually, in #6 (I had to look for it too, the topic of the issue is a bit generic). I am still not sure if interpreting paths is not best left to &includeexpr and friends, but as I am currently reworking fetch to handle #9 and the refactoring needed for that has taken me 90 % of the way towards user configurable specs, I might go the last mile for the next release and open up the API.

kopischke commented 8 years ago

Closing as duplicate, but stay tuned for the next release.