mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-12-07 04:34:35 +08:00
Feed custom file under cursor into netrw's gx
References https://github.com/tpope/vim-fugitive/issues/1550
This commit is contained in:
@@ -2212,12 +2212,6 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
|
|
||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
|
|
||||||
let browsex = maparg('<Plug>NetrwBrowseX', 'n')
|
|
||||||
let remote_check = '\Cnetrw#CheckIfRemote(\%(netrw#GX()\)\=)'
|
|
||||||
if browsex =~# remote_check
|
|
||||||
exe 'nnoremap <silent> <buffer> <Plug>NetrwBrowseX' substitute(browsex, remote_check, '0', 'g')
|
|
||||||
endif
|
|
||||||
|
|
||||||
return 'silent ' . s:DoAutocmd('BufReadPost') .
|
return 'silent ' . s:DoAutocmd('BufReadPost') .
|
||||||
\ (modifiable ? '' : '|setl nomodifiable') . '|silent ' .
|
\ (modifiable ? '' : '|setl nomodifiable') . '|silent ' .
|
||||||
\ s:DoAutocmd('User Fugitive' . substitute(b:fugitive_type, '^\l', '\u&', ''))
|
\ s:DoAutocmd('User Fugitive' . substitute(b:fugitive_type, '^\l', '\u&', ''))
|
||||||
@@ -6116,6 +6110,24 @@ function! fugitive#MapJumps(...) abort
|
|||||||
call s:Map('n', 'g?', ":<C-U>help fugitive-map<CR>", '<silent>')
|
call s:Map('n', 'g?', ":<C-U>help fugitive-map<CR>", '<silent>')
|
||||||
call s:Map('n', '<F1>', ":<C-U>help fugitive-map<CR>", '<silent>')
|
call s:Map('n', '<F1>', ":<C-U>help fugitive-map<CR>", '<silent>')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let old_browsex = maparg('<Plug>NetrwBrowseX', 'n')
|
||||||
|
let new_browsex = substitute(old_browsex, '\Cnetrw#CheckIfRemote(\%(netrw#GX()\)\=)', '0', 'g')
|
||||||
|
let new_browsex = substitute(new_browsex, 'netrw#GX()\|expand((exists("g:netrw_gx")? g:netrw_gx : ''<cfile>''))', 'fugitive#GX()', 'g')
|
||||||
|
if new_browsex !=# old_browsex
|
||||||
|
exe 'nnoremap <silent> <buffer> <Plug>NetrwBrowseX' new_browsex
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! fugitive#GX() abort
|
||||||
|
try
|
||||||
|
let results = &filetype ==# 'fugitive' ? s:StatusCfile() : &filetype ==# 'git' ? s:cfile() : []
|
||||||
|
if len(results) && len(results[0])
|
||||||
|
return FugitiveReal(s:Generate(results[0]))
|
||||||
|
endif
|
||||||
|
catch /^fugitive:/
|
||||||
|
endtry
|
||||||
|
return expand(get(g:, 'netrw_gx', expand('<cfile>')))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:StatusCfile(...) abort
|
function! s:StatusCfile(...) abort
|
||||||
|
|||||||
Reference in New Issue
Block a user