From 9a81092c7fb6eb36498bc0e2710b8420752a8f5a Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 28 May 2020 16:28:41 +0200 Subject: feat(abbrevURL): switch abbreviating to SUSE abbrs to external command. --- abbrevURL | 34 ++++++++++++++++++++++++++++++++++ plugin/spec.vim | 18 +----------------- 2 files changed, 35 insertions(+), 17 deletions(-) create mode 100755 abbrevURL diff --git a/abbrevURL b/abbrevURL new file mode 100755 index 0000000..5f37c59 --- /dev/null +++ b/abbrevURL @@ -0,0 +1,34 @@ +#!/usr/bin/lua +local str = '' + +if #arg == 0 then +str = io.read("*l") +else +str = arg[1]:lower() +end + +str = str:gsub("https://github.com/(.*)/issues/(%d+)", "gh#%1#%2") +str = str:gsub("https://github.com/(.*)/pull/(%d+)", "gh#%1#%2") +str = str:gsub("https://gitlab.com/(.*)/-/issues/(%d+)", "gl#%1#%2") +str = str:gsub("https://gitlab.com/(.*)/issues/(%d+)", "gl#%1#%2") +str = str:gsub("https://gitlab.com/(.*)/pull/(%d+)", "gl#%1#%2") +str = str:gsub("https://sourceforge.net/support/tracker.php%?aid=(%d+)", "sh#%1") +str = str:gsub("https://sf.net/support/tracker.php%?aid=(%d+)", "sh#%1") +str = str:gsub("https://sourceforge.net/p/(.*)/patches/(%d+)/", "shp#%1#%2") +str = str:gsub("https://sourceforge.net/p/(.*)/bugs/(%d+)/", "shb#%1#%2") +str = str:gsub("https://sf.net/support/p/(.*)/patches/(%d+)/", "shp#%1#%2") +str = str:gsub("https://sf.net/support/p/(.*)/bugs/(%d+)/", "shb#%1#%2") +str = str:gsub("https://bitbucket.org/(.*)/issues/(%d+)/", "bt#%1#%2") +str = str:gsub("https://build.suse.de/request/show/(%d+)", "ssr#%1") +str = str:gsub("https://build.opensuse.org/request/show/(%d+)", "sr#%1") +str = str:gsub("https://bugzilla.opensuse.org/show_bug.cgi%?id=(%d+)", "boo#%1") +str = str:gsub("https://bugzilla.opensuse.org/(%d+)", "boo#%1") +str = str:gsub("https://bugzilla.suse.com/show_bug.cgi%?id=(%d+)", "bsc#%1") +str = str:gsub("https://bugzilla.suse.com/(%d+)", "bsc#%1") +str = str:gsub("https://bugzilla.redhat.com/show_bug.cgi%?id=(%d+)", "rh#%1") +str = str:gsub("https://bugzilla.redhat.com/(%d+)", "rh#%1") +str = str:gsub("https://jira.suse.com/browse/(%a+)", "jsc#%1") +str = str:gsub("https://bugs.python.org/issue(%d+)", "bpo#%1") +str = str:gsub("https://bugs.launchpad.net/[^]+/+bug/(%d+)", "lp#%1") + +print(str) diff --git a/plugin/spec.vim b/plugin/spec.vim index 376e666..6dc02dc 100644 --- a/plugin/spec.vim +++ b/plugin/spec.vim @@ -1,20 +1,4 @@ -function! ReplaceURLs() - s!https://github.com/\(.*\)/\(issues\|pull\)/\(\d\+\)!gh#\1#\3!e - s!https://gitlab.com/\(.*\)/\(-/\)\?\(issues\|pull\)/\(\d\+\)!gl#\1#\4!e - s!https://\(sourceforge\|sf\).net/support/tracker.php?aid=\(\d\+\)!sh#\2!e - s!https://\(sourceforge\|sf\).net/p/\(.*\)/bugs/\(\d\+\)/!shb#\2#\3!e - s!https://\(sourceforge\|sf\).net/p/\(.*\)/patches/\(\d\+\)/!shp#\2#\3!e - s!https://bitbucket.org/\(.*\)/issues/\(\d\+\)!bt#\1#\2!e - s!https://build.suse.de/request/show/\(\d*\)!ssr#\1!e - s!https://build.opensuse.org/request/show/\(\d*\)!sr#\1!e - s!https://bugzilla.opensuse.org/\(show_bug.cgi?id=\)\?\(\d*\).*$!boo#\2!e - s!https://bugzilla.suse.com/\(show_bug.cgi?id=\)\?\(\d*\).*$!bsc#\2!e - s!https://jira.suse.\(com\|de\)/browse/\(\d*\)!jsc#\2!e - s!https://bugs.python.org/issue\(\d\+\)!bpo#\1!e - s!https://bugs.launchpad.net/\([^/]\+\)/+bug/\(\d\+\)!lp#\2!e -endfunction - -noremap gG :call ReplaceURLs() +noremap gG :,!abbrevURL " for netrw let g:netrw_browsex_viewer='setsid osurl' -- cgit