From 908cda693f5243a197ccaf5faf5679d0e2ce29a0 Mon Sep 17 00:00:00 2001 From: Radoslav Borissov Date: Fri, 19 Apr 2019 20:55:05 +0300 Subject: intit. --- README.md | 29 +++++++++++++++++++++ plugin/fugitive-gitea.vim | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 README.md create mode 100644 plugin/fugitive-gitea.vim diff --git a/README.md b/README.md new file mode 100644 index 0000000..2736dae --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# fugitive-bitbucketserver + +## Installation + +Via Plugin Manager +#### Vundle +```viml + Plugin 'borissov/fugitive-gitea' +``` +#### VIM Plug +```viml + Plug 'borissov/fugitive-gitea' +``` +### Manual Installation +```bash +cd ~/.vim/bundle +git clone git://github.com/borissov/fugitive-gitea +``` + +## Settings +In your vimrc file add options to set your bitbucket server urls. + +```viml +let g:fugitive_gitea_domains = ['http://yoururl.com'] +``` + + +### Originaly from +tommcdo/vim-fubitive diff --git a/plugin/fugitive-gitea.vim b/plugin/fugitive-gitea.vim new file mode 100644 index 0000000..162c139 --- /dev/null +++ b/plugin/fugitive-gitea.vim @@ -0,0 +1,65 @@ +function! s:function(name) abort + return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) +endfunction + +function! s:giteaserver_url(opts, ...) abort + if a:0 || type(a:opts) != type({}) + return '' + endif + + let domains = g:fugitive_gitea_domains + let domain_patterns = [] + + for domain in domains + call add(domain_patterns, escape(split(domain, '://')[-1], '.')) + endfor + + let domain_pattern = join(domain_patterns, '\|') + let repo = matchstr(a:opts.remote,'^\%(https\=://\|git://\|\(ssh://\)\=git@\)\%(.\{-\}@\)\=\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=$') + if repo ==# '' + return '' + endif + + + if index(domains, 'http://' . matchstr(repo, '^[^:/]*')) >= 0 + let root = 'http://'.repo + else + let root = 'https://'.repo + endif + + let path = substitute(a:opts.path, '^/', '', '') + if path =~# '^\.git/refs/heads/' + return root . '/commits/'.path[16:-1] + elseif path =~# '^\.git/refs/tags/' + return root . '/src/'.path[15:-1] + elseif path =~# '.git/\%(config$\|hooks\>\)' + return root . '/admin' + elseif path =~# '^\.git\>' + return root + endif + if a:opts.commit =~# '^\d\=$' + let commit = a:opts.repo.rev_parse('HEAD') + else + let commit = a:opts.commit + endif + if get(a:opts, 'type', '') ==# 'tree' || a:opts.path =~# '/$' + return '' + elseif get(a:opts, 'type', '') ==# 'blob' || a:opts.path =~# '[^/]$' + let url = root . '/src/commit/'.commit.'/'.path + if get(a:opts, 'line1') + let url .= '\#L' . a:opts.line1 + if get(a:opts, 'line2') != get(a:opts, 'line1') + let url .= '-L' . a:opts.line2 + endif + endif + else + let url = root . '/commit/' . commit + endif + return url +endfunction + +if !exists('g:fugitive_browse_handlers') + let g:fugitive_browse_handlers = [] +endif + +call insert(g:fugitive_browse_handlers, s:function('s:giteaserver_url')) -- cgit v1.2.3-54-g00ecf