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 up fetch API for external usage #6
Comments
I’m wondering if that is not best handled by |
Yes, it's also a case for gf/gF, but those do not work when opening Vim. My use case is using git or some other tool in the terminal, then copying some path from a patch output and starting Vim with it. This usually means to start Vim using |
OK, never mind the EDIT: I only just noticed you mentioned git (sorry, early morning here); are we talking about |
Yes. Another example are patches in Debian packages, which (at least used to be) commonly applied using |
Correct me if I’m wrong, but none of these actually include position information, right? This is about guessing the correct file path only from a contextually truncated format? |
Yes. |
Thought so. I’m not sure that is a good fit for vim-fetch – I think I’d rather have it remain focused on jump specs. However, I have a few ideas about how to make vim-fetch’s heuristics available outside the plug-in’s scope. For instance, instead of passing the key to a hardwired matcher, one could make its API accept arbitrary handlers, so you could do something like let handler = {'pattern': '\m^[^~\./]/'}
function! handler.parse(file) abort
return [substitute(a:file, self.pattern, '', ''), [0, 0]]
endfunction
" define autocmd group...
autocmd BufNewFile,BufWinEnter [^~./]/?* call fetch#buffer(handler) in your |
Ok.
That looks good! |
I’m on the fence about this; with the extension of their capabilities to @blueyed your input would be appreciated :). |
Another possible way would be to modularise the internals of function! s:checkdiffpath() abort
if !filereadable(bufname('%')) && !fetch#buffer#ignored(bufnr('%'))
call fetch#buffer#instead(substitute(s:fn, '\m^\S\{-}/', '', ''))
endif
endfunction
autocmd BufNewFile,BufWinEnter [^~./]/?* call s:checkdiffpath()
And then there is the option of creating another plug-in entirely, one only tasked with resolving false file paths, with user configurable resolution patterns (a superset of DidYouMean, if you want).
@blueyed thoughts? |
I’ve removed this from the 2.0 release milestone, but will leave the issue open for discussion for the time being. |
Closing, but kept in mind for future consideration. |
I've just remembered that I have the following in my vimrc:
This helps when copy'n'pasting a path from a patch / diff header, e.g. from
git diff
.I think it might be a good addition for vim-fetch, applying all specs with an optional path prefix, too.
It could be limited to just a single char prefix (
a/
,b/
,i/
,w/
, ...).The text was updated successfully, but these errors were encountered: