Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIM: add option to use vim8 terminal #1860

Open
5 of 10 tasks
qhadron opened this issue Feb 9, 2020 · 1 comment
Open
5 of 10 tasks

VIM: add option to use vim8 terminal #1860

qhadron opened this issue Feb 9, 2020 · 1 comment

Comments

@qhadron
Copy link

qhadron commented Feb 9, 2020

  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

Problem / Steps to reproduce

Similar to #1055, I enjoy using vim8's terminal to use terminal mappings for cycling fzf modes.
However, if I have the down key in g:fzf_layout dictionary, fzf will always prefer to use height mode.

Is it possible to add a g:fzf_prefer_term that chooses the vim 8 terminal over height mode? Maybe something like this?

--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -406,14 +406,19 @@ try
   endif

   let prefer_tmux = get(g:, 'fzf_prefer_tmux', 0)
+  let prefer_term = get(g:, 'fzf_prefer_term', 0)
   let use_height = has_key(dict, 'down') && !has('gui_running') &&
         \ !(has('nvim') || s:is_win || has('win32unix') || s:present(dict, 'up', 'left', 'right', 'window')) &&
         \ executable('tput') && filereadable('/dev/tty')
   let has_vim8_term = has('terminal') && has('patch-8.0.995')
   let has_nvim_term = has('nvim-0.2.1') || has('nvim') && !s:is_win
   let use_term = has_nvim_term ||
-    \ has_vim8_term && !has('win32unix') && (has('gui_running') || s:is_win || !use_height && s:present(dict, 'down', 'up', 'left', 'right', 'window'))
+    \ has_vim8_term && !has('win32unix') && (has('gui_running') || s:is_win || (!use_height || prefer_term) && s:present(dict, 'down', 'up', 'left', 'right', 'window'))
   let use_tmux = (!use_height && !use_term || prefer_tmux) && !has('win32unix') && s:tmux_enabled() && s:splittable(dict)
+  if prefer_term && use_term
+    let use_height = 0
+    let use_tmux = 0
+  endif
   if prefer_tmux && use_tmux
     let use_height = 0
     let use_term = 0
@junegunn
Copy link
Owner

Instead of adding a new option, I'm thinking of changing the code to always use the built-in terminal when available as I'd like to iron out the differences between Vim and Neovim and make the code simpler.

The reason I chose --height over terminal in that case was two-fold.

  1. The built-in terminal of Vim 8 was not stable back then. This is no longer true.
  2. Can use more space; FZF can use two more lines at the bottom of the screen (statusline and command line of Vim)
    • But the drawback of using --height is that it pushes the contents upwards while fzf is running

Anyway, until I decide what I'm going to do with it, you can force fzf to use terminal buffer by using window layout.

let g:fzf_layout = { 'window': 'bot'.float2nr(&lines * 0.4).'new' }

If you have a bleeding-edge Vim, you can make fzf run inside a pop-up window so that the existing windows are not affected.

let g:fzf_layout = { 'window': { 'width': 1, 'height': 0.4, 'yoffset': 1, 'border': 'horizontal' } }

(See junegunn/fzf.vim#942)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants