vim-floaterm icon indicating copy to clipboard operation
vim-floaterm copied to clipboard

How to use gd gf inside floating window

Open ahmadie opened this issue 4 years ago • 2 comments

I was trying to use gd gf on file links inside the floating terminal, but then nvim switch to a new or an existing buffer inside the floating window itself.

ahmadie avatar Nov 20 '20 05:11 ahmadie

Put this code into after/ftplugin/floaterm.vim:

function s:open_in_normal_window() abort
  let f = findfile(expand('<cfile>'))
  if !empty(f) && has_key(nvim_win_get_config(win_getid()), 'anchor')
    FloatermHide
    execute 'e ' . f
  endif
endfunction

nnoremap <silent><buffer> gf :call <SID>open_in_normal_window()<CR>

or use autocmd in your vimrc like this:

function s:open_in_normal_window() abort
  let f = findfile(expand('<cfile>'))
  if !empty(f) && has_key(nvim_win_get_config(win_getid()), 'anchor')
    FloatermHide
    execute 'e ' . f
  endif
endfunction

autocmd FileType floaterm nnoremap <silent><buffer> gf :call <SID>open_in_normal_window()<CR>

voldikss avatar Dec 18 '20 02:12 voldikss

I feel it would be awesome if the floaterm supports gf, gF by itself like git commit things.

Matts966 avatar Mar 04 '21 12:03 Matts966