Skip to content

Instantly share code, notes, and snippets.

@deris
Created July 4, 2013 17:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deris/5929250 to your computer and use it in GitHub Desktop.
Save deris/5929250 to your computer and use it in GitHub Desktop.
NeoBundleの相対パスを開く(operator-user対応)
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