Created
July 4, 2013 17:31
-
-
Save deris/5929250 to your computer and use it in GitHub Desktop.
NeoBundleの相対パスを開く(operator-user対応)
This file contains hidden or 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
NeoBundle 'tyru/open-browser' | |
NeoBundle 'kana/vim-operator-user' | |
call operator#user#define('open-neobundlepath', 'OpenNeoBundlePath') | |
map gz <Plug>(operator-open-neobundlepath) | |
function! OpenNeoBundlePath(motion_wise) | |
if line("'[") != line("']") | |
return | |
endif | |
let start = col("'[") - 1 | |
let end = col("']") | |
let sel = strpart(getline('.'), start, end - start) | |
let sel = substitute(sel, '^\%(github\|gh\|git@github\.com\):\(.\+\)', 'https://github.com/\1', '') | |
let sel = substitute(sel, '^\%(bitbucket\|bb\):\(.\+\)', 'https://bitbucket.org/\1', '') | |
let sel = substitute(sel, '^gist:\(.\+\)', 'https://gist.github.com/\1', '') | |
let sel = substitute(sel, '^git://', 'https://', '') | |
if sel =~ '^https\?://' | |
call openbrowser#open(sel) | |
elseif sel =~ '/' | |
call openbrowser#open('https://github.com/'.sel) | |
else | |
call openbrowser#open('https://github.com/vim-scripts/'.sel) | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment