From ee69335de176d9325267b0fd2597a22901d927b1 Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Wed, 29 Mar 2023 15:38:59 +1100 Subject: [PATCH] Use ?plain=1 for range links to GitHub markups GitHub markups are by default rendered by [1], which doesn't map original line anchors into the previews. [1] https://github.com/github/markup --- autoload/rhubarb.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoload/rhubarb.vim b/autoload/rhubarb.vim index 1709981..4e5999c 100644 --- a/autoload/rhubarb.vim +++ b/autoload/rhubarb.vim @@ -296,6 +296,8 @@ endfunction " Section: Fugitive :GBrowse support +" https://github.com/github/markup +let s:markup_exts = ['markdown', 'mdown', 'mkdn', 'md', 'textile', 'rdoc', 'org', 'creole', 'mediawiki', 'wiki', 'rst', 'asciidoc', 'adoc', 'asc', 'pod'] function! rhubarb#FugitiveUrl(...) abort if a:0 == 1 || type(a:1) == type({}) let opts = a:1 @@ -323,6 +325,9 @@ function! rhubarb#FugitiveUrl(...) abort elseif get(opts, 'type', '') ==# 'blob' || opts.path =~# '[^/]$' let escaped_commit = substitute(commit, '#', '%23', 'g') let url = root . '/blob/' . escaped_commit . '/' . path + if get(opts, 'line1') > 0 && index(s:markup_exts, fnamemodify(path, ':e')) >= 0 + let url .= '?plain=1' + endif if get(opts, 'line2') > 0 && get(opts, 'line1') == opts.line2 let url .= '#L' . opts.line1 elseif get(opts, 'line1') > 0 && get(opts, 'line2') > 0