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] Use Vim 8 terminal when appropriate #1055

Closed
1 task done
junegunn opened this issue Sep 19, 2017 · 7 comments
Closed
1 task done

[vim] Use Vim 8 terminal when appropriate #1055

junegunn opened this issue Sep 19, 2017 · 7 comments

Comments

@junegunn
Copy link
Owner

  • Category
    • Vim

There are 5 types of layout options supported by Vim plugin of fzf: up, down, left, right, and window.

Layout --height tmux Vim 8 terminal Neovim terminal
up NO YES YES YES
down YES YES YES YES
left NO YES YES YES
right NO YES YES YES
window NO NO YES YES

Summary

  • I prefer using --height the most for down layout. It's clean and does not require you to be on tmux. But some users prefer tmux panes as they can zoom in the pane (Not opening in tmux pane fzf.vim#296), so we provide g:fzf_prefer_tmux flag.
  • In Neovim, we always use builtin terminal as Neovim cannot properly start interactive programs without using it (Neovim compatibility #137)
  • Vim 8 recently introduced its own terminal emulator following Neovim's path, and we've started using it on GVim and Windows Vim (Use the terminal by default for nvim-0.2.1 or GVim (nightly) #1019). But it's still young and has issues (e.g. Enter key not working in tig when run inside a terminal window vim/vim#1998)
  • We don't use it yet on terminal Vim, thus we currently can't support window layout and also up, left, and right if the user is not on tmux.
  • The following patch is for enabling it for layouts other than down. It takes precedence over using tmux unless g:fzf_prefer_tmux is true. I'm not sure if it's the right decision at the moment because of the open issue of Vim 8 terminal (i.e. CTRL-J vs CTRL-M).
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index c0bae81..ecf1d1d 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -386,10 +386,11 @@ try
   endif
 
   let prefer_tmux = get(g:, 'fzf_prefer_tmux', 0)
-  let use_height = has_key(dict, 'down') &&
-        \ !(has('nvim') || s:is_win || has('win32unix') || s:present(dict, 'up', 'left', 'right')) &&
+  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 use_term = has('nvim-0.2.1') || (has('nvim') && !s:is_win) || (has('terminal') && has('patch-8.0.995') && (has('gui_running') || s:is_win))
+  let has_term = has('nvim-0.2.1') || has('nvim') && !s:is_win || has('terminal') && has('patch-8.0.995')
+  let use_term = has_term && (has('gui_running') || s:is_win || !use_height && 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_tmux && use_tmux
     let use_height = 0
@janlazo
Copy link
Contributor

janlazo commented Sep 27, 2017

Any Vim patches required for non-Windows Vim?

@junegunn
Copy link
Owner Author

No, it works now, though I'm unhappy with vim/vim#1998 being open

@janlazo
Copy link
Contributor

janlazo commented Sep 29, 2017

Will there be another release soon?
I want to test the preview fixes for the ruby script.

@junegunn
Copy link
Owner Author

I'll take a few more days and think about if there's anything else I'd like to address in the next release, but I'll build and upload an alpha version tonight so you can test it beforehand if you want. Thanks.

@janlazo
Copy link
Contributor

janlazo commented Sep 29, 2017

It's fine for me on default settings so we can use the ruby preview script in fzf.vim under the 16 color limit in cmd.exe.

@janlazo
Copy link
Contributor

janlazo commented Sep 30, 2017

@junegunn After more testing with the Vim 8 terminal on ConEmu with $ConEmuANSI ==# 'ON' for ANSI escape codes, I prefer using :! to the Vim/Neovim terminal, especially for the preview. winpty does not work well with ConEmu and it inherits ConEmu's environment variables. This is a problem in both Vim and Neovim so it's better to resolve this upstream first.

I'll submit a PR when I figure out how to detect ConEmu correctly and consistently in nested Vim/Neovim terminals.

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