Created
June 4, 2016 21:01
-
-
Save zQueal/3fe9470ddc7fb0f5a7d47ddc4388d605 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:plug_gx() | |
let line = getline('.') | |
let sha = matchstr(line, '^ \X*\zs\x\{7}\ze ') | |
let name = empty(sha) ? matchstr(line, '^[-x+] \zs[^:]\+\ze:') | |
\ : getline(search('^- .*:$', 'bn'))[2:-2] | |
let uri = get(get(g:plugs, name, {}), 'uri', '') | |
if uri !~ 'github.com' | |
return | |
endif | |
let repo = matchstr(uri, '[^:/]*/'.name) | |
let url = empty(sha) ? 'https://github.com/'.repo | |
\ : printf('https://github.com/%s/commit/%s', repo, sha) | |
call netrw#BrowseX(url, 0) | |
endfunction | |
augroup PlugGx | |
autocmd! | |
autocmd FileType vim-plug nnoremap <buffer> <silent> gx :call <sid>plug_gx()<CR> | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment