Giter Site home page Giter Site logo

vim-floaterm's Introduction

Use (neo)vim terminal in the floating/popup window.

CI GitHub license Maintenance

Features

  • Support neovim floatwin and vim8 popupwin
  • Manage multiple terminal instances
  • Customizable terminal window style
  • Switch/preview floating terminal buffers using fuzzy-finder plugins such as denite.nvim or fzf, etc.
  • Use with other external command-line tools(ranger, fzf, ripgrep etc.)
  • Use as a custom task runner for asynctasks.vim or asyncrun.vim

Requirements

  • Vim or neovim with terminal feature

Installation

  • packer.nvim
use 'voldikss/vim-floaterm'
  • vim-plug
Plug 'voldikss/vim-floaterm'
  • dein.nvim
call dein#add('voldikss/vim-floaterm')

Get Started

Use :FloatermNew to open a terminal window, use :FloatermToggle to hide/reopen that. The filetype of the terminal buffer is floaterm.

If you've opened multiple floaterm instances, they will be attached to a double-circular-linkedlist. Then you can use :FloatermNext or : FloatermPrev to switch between them.

❗️Note: Long-running jobs (e.g. yarn watch) inside the builtin terminal would probably slowdown your operation. It's recommended to put them into the external terminals.

Commands

:FloatermNew[!] [options] [cmd] Open a floaterm window.

  • If ! is given, execute cmd in $SHELL. Try :FloatermNew python and : FloatermNew! python to learn about the difference.
  • If execute without cmd, open $SHELL.
  • The options is formed as --key[=value], it is used to specify local attributes of a specific floaterm instance. Note that in order to input space, you have to form it as \ followed by space, and \ must be typed as \\
    • cwd working directory that floaterm will be opened at. Accepts a path, the literal <root> which represents the project root directory, the literal <buffer> which specifies the directory of the active buffer, or the literal <buffer-root> which corresponds to the project root directory of the active buffer.
    • name name of the floaterm
    • silent If --silent is given, spawn a floaterm but not open the window, you may toggle it afterwards
    • disposable If --disposable is given, the floaterm will be destroyed once it is hidden.
    • title see g:floaterm_title
    • width see g:floaterm_width
    • height see g:floaterm_height
    • opener see g:floaterm_opener
    • wintype see g:floaterm_wintype
    • position see g:floaterm_position
    • autoclose see g:floaterm_autoclose
    • borderchars see g:floaterm_borderchars
    • titleposition see g:floaterm_titleposition
  • This command basically shares the consistent behaviors with the builtin :terminal:
    • The special characters(:help cmdline-special) such as % and <cfile> will be auto-expanded, to get standalone characters, use \ followed by the corresponding character(e.g., \%).
    • Note that <bar>(i.e., |) will be seen as an argument of the command, therefore it can not be followed by another Vim command.
  • If execute this command with a range, i.e., '<,'>:FloatermNew ..., the selected lines will be sent to the created floaterm. For example, see python repl use case below.
  • Use <TAB> to get completion.

For example, the command

:FloatermNew --height=0.6 --width=0.4 --wintype=float --name=floaterm1 --position=topleft --autoclose=2 ranger --cmd="cd ~"

will open a new floating/popup floaterm instance named floaterm1 running ranger --cmd="cd ~" in the topleft corner of the main window.

The following command allows you to compile and run your C code in the floaterm window:

:FloatermNew --autoclose=0 gcc % -o %< && ./%<

:FloatermPrev Switch to the previous floaterm instance

:FloatermNext Switch to the next floaterm instance

:FloatermFirst Switch to the first floaterm instance

:FloatermLast Switch to the last floaterm instance

:FloatermUpdate [options] Update floaterm window attributes(height, width, etc.).

  • The options is the same as in :FloatermNew (except --silent).
  • Use <TAB> to get completion.

:[N]FloatermToggle[!] [floaterm_name] Open or hide the floaterm window.

  • If N is given, toggle the floaterm whose buffer number is N
  • If floaterm_name is given, toggle the floaterm instance whose name attribute is floaterm_name. Otherwise create a new floaterm named floaterm_name.
  • Use <TAB> to get completion.
  • If ! is given, toggle all floaterms (:FloatermHide! or : FloatermShow!)

:[N]FloatermShow[!] [floaterm_name] Show the current floaterm window.

  • If N is given, show the floaterm whose buffer number is N
  • If floaterm_name is given, show the floaterm named floaterm_name.
  • If ! is given, show all floaterms (If multiple floaterms have the same position attribute, only one of them will be show)

:[N]FloatermHide[!] [floaterm_name] Hide the current floaterms window.

  • If N is given, hide the floaterm whose buffer number is N
  • If floaterm_name is given, show the floaterm named floaterm_name.
  • If ! is given, hide all floaterms

:[N]FloatermKill[!] [floaterm_name] Kill the current floaterm instance

  • If N is given, kill the floaterm whose buffer number is N
  • If floaterm_name is given, kill the floaterm instance named floaterm_name.
  • If ! is given, kill all floaterms

:FloatermSend[!] [--name=floaterm_name] [cmd] Send command to a job in floaterm.

  • If --name=floaterm_name is given, send lines to the floaterm instance whose name is floaterm_name. Otherwise use the current floaterm.
  • If cmd is given, it will be sent to floaterm and selected lines will be ignored.
  • This command can also be used with a range, i.e., '<,'>:FloatermSend [--name=floaterm_name] to send selected lines to a floaterm.
    • If cmd is given, the selected lines will be ignored.
    • If use this command with a !, i.e., '<,'>:FloatermSend! [--name=floaterm_name] the common white spaces in the beginning of lines will be trimmed while the relative indent between lines will still be kept.
  • Use <TAB> to get completion.
  • Examples
    :FloatermSend                        " Send current line to the current floaterm (execute the line in the terminal)
    :FloatermSend --name=ft1             " Send current line to the floaterm named ft1
    :FloatermSend ls -la                 " Send `ls -la` to the current floaterm
    :FloatermSend --name=ft1 ls -la      " Send `ls -la` to the floaterm named ft1
    :23FloatermSend ...                  " Send the line 23 to floaterm
    :1,23FloatermSend ...                " Send lines between line 1 and line 23 to floaterm
    :'<,'>FloatermSend ...               " Send lines selected to floaterm(visual block selection are supported)
    :%FloatermSend ...                   " Send the whole buffer to floaterm

Options

g:floaterm_shell

Type String. Default: &shell

g:floaterm_title

Type String. Show floaterm info(e.g., 'floaterm: 1/3' implies there are 3 floaterms in total and the current is the first one) at the top left corner of floaterm window.

Default: 'floaterm: $1/$2'($1 and $2 will be substituted by 'the index of the current floaterm' and 'the count of all floaterms' respectively)

Example: 'floaterm($1|$2)'

g:floaterm_wintype

Type String. 'float'(nvim's floating or vim's popup) by default. Set it to 'split' or 'vsplit' if you don't want to use floating or popup window.

g:floaterm_width

Type Number (number of columns) or Float (between 0 and 1). If Float, the width is relative to &columns.

Default: 0.6

g:floaterm_height

Type Number (number of lines) or Float (between 0 and 1). If Float, the height is relative to &lines.

Default: 0.6

g:floaterm_position

Type String. The position of the floating window. Available values:

  • If wintype is split/vsplit: 'leftabove', 'aboveleft', 'rightbelow', 'belowright', 'topleft', 'botright'. Default: 'botright'.

    It's recommended to have a look at those options meanings, e.g. :help :leftabove.

  • If wintype is float: 'top', 'bottom', 'left', 'right', 'topleft', 'topright', 'bottomleft', 'bottomright', 'center', 'auto'(at the cursor place). Default: 'center'

In addition, there is another option 'random' which allows to pick a random position from above when (re)opening a floaterm window.

g:floaterm_borderchars

Type String. 8 characters of the floating window border (top, right, bottom, left, topleft, topright, botright, botleft).

Default: ─│─│┌┐┘└

g:floaterm_rootmarkers

Type List of String. Markers used to detect the project root directory for --cwd=<root> or --cwd=<buffer-root>.

Default: ['.project', '.git', '.hg', '.svn', '.root']

g:floaterm_giteditor

Type Boolean. Whether to override $GIT_EDITOR in floaterm terminals so git commands can open open an editor in the same neovim instance. See git for details. This flag also overrides $HGEDITOR for Mercurial.

Default: v:true

g:floaterm_opener

Type String. Command used for opening a file in the outside nvim from within :terminal.

Available: 'edit', 'split', 'vsplit', 'tabe', 'drop' or user-defined commands

Default: 'split'

g:floaterm_autoclose

Type Number. Whether to close floaterm window once the job gets finished.

  • 0: Always do NOT close floaterm window
  • 1: Close window if the job exits normally, otherwise stay it with messages like [Process exited 101]
  • 2: Always close floaterm window

Default: 1.

g:floaterm_autohide

Type Number. Whether to hide previous floaterms before switching to or opening a another one.

  • 0: Always do NOT hide previous floaterm windows
  • 1: Only hide those whose position (b:floaterm_position) is identical to that of the floaterm which will be opened
  • 2: Always hide them

Default: 1.

g:floaterm_autoinsert

Type Boolean. Whether to enter Terminal-mode after opening a floaterm.

Default: v:true

g:floaterm_titleposition

Type String. The position of the floaterm title.

Available: 'left', 'center', 'right'.

Default: 'left'

Keymaps

This plugin doesn't supply any default mappings. Here are the configuration examples.

" Configuration example
let g:floaterm_keymap_new    = '<F7>'
let g:floaterm_keymap_prev   = '<F8>'
let g:floaterm_keymap_next   = '<F9>'
let g:floaterm_keymap_toggle = '<F12>'

You can also use other keys as shown below:

let g:floaterm_keymap_new = '<Leader>ft'

All options for the mappings are listed below:

  • g:floaterm_keymap_new
  • g:floaterm_keymap_prev
  • g:floaterm_keymap_next
  • g:floaterm_keymap_first
  • g:floaterm_keymap_last
  • g:floaterm_keymap_hide
  • g:floaterm_keymap_show
  • g:floaterm_keymap_kill
  • g:floaterm_keymap_toggle

Note that the key mappings are set from the plugin/floaterm.vim, so if you are using on-demand loading feature provided by some plugin-managers, the keymap above won't take effect(:help load-plugins). Then you have to define the key bindings by yourself. For example,

nnoremap   <silent>   <F7>    :FloatermNew<CR>
tnoremap   <silent>   <F7>    <C-\><C-n>:FloatermNew<CR>
nnoremap   <silent>   <F8>    :FloatermPrev<CR>
tnoremap   <silent>   <F8>    <C-\><C-n>:FloatermPrev<CR>
nnoremap   <silent>   <F9>    :FloatermNext<CR>
tnoremap   <silent>   <F9>    <C-\><C-n>:FloatermNext<CR>
nnoremap   <silent>   <F12>   :FloatermToggle<CR>
tnoremap   <silent>   <F12>   <C-\><C-n>:FloatermToggle<CR>

Highlights

There are two highlight-groups to specify the color of floaterm (also the border color if g: floaterm_wintype is 'float') window.

To customize, use hi command together with the colors you prefer.

" Configuration example

" Set floaterm window's background to black
hi Floaterm guibg=black
" Set floating window border line color to cyan, and background to orange
hi FloatermBorder guibg=orange guifg=cyan
Demo

Besides, there is a neovim only highlight group which can be used to configure no-current-focused window(:help NormalNC).

" Configuration example

" Set floaterm window foreground to gray once the cursor moves out from it
hi FloatermNC guifg=gray
Demo

Autocmd

autocmd User FloatermOpen        " triggered after opening a new/existed floaterm

Advanced Topics

Use with command line tools

The following cases should work both in Vim and NeoVim unless otherwise specifically noted.

floaterm

Normally if you run vim/nvim somefile.txt within the builtin terminal, you would get another nvim/vim instance running in the subprocess.

Floaterm, which is a builtin script in this plugin, allows you to open files from within : terminal without starting a nested nvim. To achieve that, just literally replace vim/nvim with floaterm, e.g. floaterm somefile.txt

P.S.

  • #208 describes how to use gf in the floating terminal window.
  • floaterm is too long to type? set alias in your bashrc, e.g. alias f=floaterm
  • For configurable open action, refer to g:floaterm_opener
Demo

Execute git commit in the terminal window without starting a nested vim/nvim.

Refer to g:floaterm_giteditor to disable this behavior.

Refer to g:floaterm_opener for configurable open action

Demo

This plugin has implemented a wrapper for fzf command. So it can be used as a tiny fzf plugin.

Try :FloatermNew fzf or even wrap this to a new command like this:

command! FZF FloatermNew fzf
Demo

Requirements:

This plugin has implemented a wrapper for rg command.

Try :FloatermNew rg or create yourself a new command like this:

command! Rg FloatermNew --width=0.8 --height=0.8 rg

or map via .vimrc

" Hotkey: \ + rg
nmap <leader>rg :Rg<CR>
Demo You can use Alt-A to select all files and Alt-D to deselect them. Use Ctrl-/ to toggle preview.

This plugin has implemented a wrapper for broot.

Try :FloatermNew broot or create yourself a new command like this:

command! Broot FloatermNew --width=0.8 --height=0.8 broot
Demo

There is also an fff wrapper

Try :FloatermNew fff or define a new command:

command! FFF FloatermNew fff
Demo

There is also an nnn wrapper

Try :FloatermNew nnn or define a new command:

command! NNN FloatermNew nnn
Demo

There is also an xplr wrapper

Try :FloatermNew xplr or define a new command:

command! XPLR FloatermNew xplr
Demo

There is also an lf wrapper. It is recommened to use lf.vim which is an lf wrapper with more features (Overriding netrw, Lfcd, etc.).

Try :FloatermNew lf or define a new command:

command! LF FloatermNew lf
Demo

This plugin can also be a handy ranger plugin since it also has a ranger wrapper

Try :FloatermNew ranger or define a new command:

command! Ranger FloatermNew ranger
Demo

This plugin can also be a handy joshuto plugin since it also has a joshuto wrapper

Try :FloatermNew joshuto or define a new command:

command! Joshuto FloatermNew joshuto

There is also a vifm wrapper

Try :FloatermNew vifm or define a new command:

command! Vifm FloatermNew vifm
Demo

There is also a yazi wrapper

Try :FloatermNew yazi or define a new command:

command! Yazi FloatermNew yazi

Furthermore, you can also use other command-line programs, such as lazygit, htop, ncdu, etc.

Use lazygit for instance:

Demo

Use :FloatermNew python to open a python shell. After that you can use : FloatermSend to send lines to the Python interactive shell.

Or you can just select lines and execute :'<,'>FloatermNew --wintype=split python, then the selected lines will be sent and executed once a python repl floaterm window is opened.

This can also work for other languages which have interactive shells, such as lua, node, etc.

Demo

Use with other plugins

Use vim-clap to switch/preview floating terminal buffers.

Install clap-floaterm and try :Clap floaterm

Demo

Use denite to switch/preview/open floating terminal buffers.

Install denite-floaterm and try :Denial floaterm

Demo

Use CocList to switch/preview/open floating terminal buffers.

Install coc-floaterm and try :CocList floaterm

Demo

Install fzf-floaterm and try :Floaterms

Install LeaderF-floaterm and try :Leaderf floaterm

This plugin can be a runner for asynctasks.vim or asyncrun.vim. See asyncrun.extra for the installation and usage.

Demo

How to define more wrappers

The wrapper script must be located in autoload/floaterm/wrapper/ directory, e.g., autoload/floaterm/wrapper/fzf.vim.

There are two ways for a command to be spawned:

  • To be executed after spawning $SHELL. Here is the old implementation of fzf wrapper

    function! floaterm#wrapper#fzf#(cmd, jobopts, config) abort
      return [v:true, 'floaterm $(fzf)']
    endfunction

    The code above returns a list. floaterm $(fzf) is the command to be executed. v:true means the command will be executed after the &shell startup.

  • To be executed through termopen()/term_start() function, in that case, a callback option can be provided. See fzf wrapper

    function! floaterm#wrapper#fzf#(cmd, jobopts, config) abort
      let s:fzf_tmpfile = tempname()
      let cmd = a:cmd . ' > ' . s:fzf_tmpfile
      let a:jobopts.on_exit = funcref('s:fzf_callback')
      return [v:false, cmd]
    endfunction
    
    function! s:fzf_callback(...) abort
      if filereadable(s:fzf_tmpfile)
        let filenames = readfile(s:fzf_tmpfile)
        if !empty(filenames)
          if has('nvim')
            call floaterm#window#hide(bufnr('%'))
          endif
          let locations = []
          for filename in filenames
            let dict = {'filename': fnamemodify(filename, ':p')}
            call add(locations, dict)
          endfor
          call floaterm#util#open(locations)
        endif
      endif
    endfunction

    In the example above, after executing :FloatermNew fzf, function floaterm#wrapper#fzf# will return

    [v:false, 'fzf > /tmp/atmpfilename'].

    Here v:false means cmd

    fzf > /tmp/atmpfilename

    will be passed through termopen()(neovim) or term_start()(vim). As the result, an fzf interactive will be opened in a floaterm window.

    When user picks a file using ENTER, fzf exits and the filepath will be written in /tmp/atmpfilename and s:fzf_callback() will be invoked to open the file. Note that the function s: fzf_callback() is registered by

    let a:jobopts.on_exit = funcref('s:fzf_callback')

    The variable a:jobopts in the above code will be eventually passed to termopen()(neovim) or term_start()(vim). For more info, see :help jobstart-options(neovim) or :help job-options(vim)

How to write sources for fuzzy finder plugins

Function floaterm#buflist#gather() returns a list contains all the floaterm buffers.

Function floaterm#terminal#open_existing({bufnr}) opens the floaterm whose buffer number is {bufnr}.

For reference, see floaterm source for LeaderF.

Contributing

  • Improve the documentation
  • Help resolve issues labeled as help wanted

FAQ

https://github.com/voldikss/vim-floaterm/issues?q=label%3AFAQ

Breaking Changes

https://github.com/voldikss/vim-floaterm/issues?q=label%3A%22breaking+change%22

Related projects

Credits

License

MIT

vim-floaterm's People

Contributors

alexeygumirov avatar asbjornhaland avatar balazser avatar benwoodward avatar delphinus avatar enigmage avatar hanaasagi avatar hasundue avatar hawkinst avatar hoxell avatar itstommymorgan avatar jerrywang1981 avatar julpikar avatar kazhala avatar kjelly avatar konfekt avatar kulakilam avatar ldonnez avatar lucobellic avatar martintrojer avatar mccurdyc avatar meain avatar mroavi avatar rashil2000 avatar sayanarijit avatar the-homeless-god avatar vn-ki avatar voldikss avatar wodesuck avatar wookayin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-floaterm's Issues

errors on start

Hi,try to run the command to trigger when with clean neovim config. You'll see some errors.
Also the example recommended setting to map F12 doesn't work as there is no util#toggleWindows.

Otherwise interesting concept!

lightline (active) lost when closing floating terminal

I use lightline and it has an appearance for focused window that is different than unfocused ones. When opening the floaterm the background window becomes unfocused and lightline changes accordingly, but when closing floaterm lightline doesn't update. :call lightline#update() forces the refresh.

Files opened within terminal immediately close

Opening files with floaterm inside the terminal works, but the command immediately ends inside the terminal (and prints 0).

This is especially problematic when using it with git commit as the editor immediately closes from git's point of view, and it only sees an empty commit message.

zsh-autosuggestions work in floating window, but not in 'normal' mode / quickfix window

Hopefully this is clear from the screenshots. When Floatterm is invoked with default floaterm_type, i.e. this global variable is not set, the terminal appears in a floating window, and suggestions from zsh-autosuggestions are visible.
image

However, if g:floaterm_type is set to 'normal', then they are not visible.
image

Another issue that is visible in these screenshots is that when the window type is set to 'normal' then the colorscheme is inherited from whatever has been set in my init.vim. However, in floating window mode the colorscheme is something else. I can create a separate issue for this if not answered here.

EDIT: Ideally I'd like a terminal in a fullscreen buffer with no borders that I can toggle with a shortcut. Is setting g:floaterm_width, and g:floaterm_height to 1 the best way to do that, or is there a better way? Do I even need this plugin to do that?

FloatTerm-only mapping or autocmd

It would be great to have a feature where we can add custom keymaps or commands that work on the floating terminal only. Using tmap or something might work but I would want to not affect other normal terminal buffers --- it should be only applicable to the floating terminal buffer.

Autocmd would be one option to implement this. Alternatively, if there is a vimscript API that would tell if the current buffer is a FloatTerm buffer (maybe exposing b: variable would work). Or do we already have this feature?

Ability to open normal or floating floaterms

Ability to open normal or floating floaterms on demand. Adding to this, ability to control the size of the terms as well.

In context of this feature request and #69, I think the current API of opening terms is wrong. I think an API similar to fzf where there are calls to open terminals would be more suitable for this plugin.

Not starting insert mode with tnoremap

I noticed a slight issue while reading #51. I intended to use FloatermNew from terminals with this vimrc below.

nnoremap <A-n> <Cmd>FloatermNew<CR>
tnoremap <A-n> <Cmd>FloatermNew<CR>

The nnoremap <A-n> does good. It starts a terminal with the insert mode. But with tnoremap <A-n>, it does not start the insert mode.

asciicast

For the present, this code below solves the problem. Just FYI.

nnoremap <A-n> <Cmd>FloatermNew<CR>
tnoremap <A-n> <Cmd>FloatermNew<CR><Cmd>startinsert<CR>

Opening a new floaterm with command line

For example, some commands like the following would be handy:

:FloatermNew ls
:FloatermToggle ls -alh

which should open a floating terminal window and execute the command after the shell startup. If there is an user-defined event or callback, one can use autocmd to emulate keyboard input but not sure if this is possible.

We can also consider extending the vimscript APIs (e.g. call g:floaterm.new(command string or argv)). What would be the best way for this?

Can't differentiate between floating terminal and editor

image

My setup

" Floating stuff
noremap  <leader>t  :FloatermToggle<CR>i
noremap! <leader>t  <Esc>:FloatermToggle<CR>i
tnoremap <leader>t  <C-\><C-n>:FloatermToggle<CR>
let g:floaterm_width = 100
let g:floaterm_winblend = 30
let g:floaterm_background = '#000000'

The background doesn't seem to work.

No module named 'denite'

Thanks for the excellent plugin.

When I update my remote plug use cmd: UpdateRemotePlugins, I got a error message:

Encountered ModuleNotFoundError loading plugin at /Users/zang/.config/nvim/plugged/vim-floaterm/rplugin/python3/denite_f
loaterm.py: No module named 'denite'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pynvim/plugin/host.py", line 171, in _load
module = imp.load_module(name, file, pathname, descr)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py", line 234, in lo
ad_module
return load_source(name, filename, file)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py", line 171, in lo
ad_source
module = _load(spec)
File "", line 696, in _load
File "", line 677, in _load_unlocked
ModuleNotFoundError: No module named 'denite'
remote/host: python3 host registered plugins []
remote/host: generated rplugin manifest: /Users/zang/.local/share/nvim/rplugin.vim

So, how can I solve it, thanks.

Add variable for minmum width and height

Do you think it would be a good idea to add some global variables to limit the minmum width and height of the floaterm? Because some times, the original vim is not that large. Set the floaterm size to some ratio to the parent vim size would make it too small for effective using.

PS: Thanks for bringing us this wonderful plugin.

[Feature Request] Enable to split before editing

nvr command accepts -cc {command} to execute before evaluating. I want to set -cc split for floaterm command and start editing with splitting windows.

  1. Accept -cc itself.
    • floaterm -cc split /path/to/file
  2. Add option for nvr.
    • let g:floaterm_nvr_option = '-cc split'

How do you feel about this?

Dynamic values of g:floaterm_width and g:floaterm_height

g:floaterm_width and g:floaterm_height are constant (integer) expressions, so we cannot have values that are dependent on the window height/width, etc.

One option would be to allow float-type values, or to accept functions.

FloatermToggle always creates a new terminal instance?

After upgrading the plugin, toggling will now always load a new terminal. Previously it would keep the previous terminal state.

This makes opening the terminal window slow as It has to load the zsh everytime. Also would clear out the terminal prints from the previous commands.

Make startinsert optional

Hi,

currently startinsert is executed on every :FloatermToggle and terminal switching via :FloatermNext or :FloatermPrev. I recommend to add a configuration flag the way neoterm did, like g:floaterm_autoinsert = 0 (default := 1).

Ability to change the size of "current" term windows

(preword, great plugin, thanks!)

I find it generally much quicker to run e.g. tests or related one-off type actions in a floatterm. This is usually fine. but sometimes the output becomes very large or long and it would be preferable to expand the existing term window to make it easier to look in.

My initial thought would be an API (which I could assign some terminal mapping to) which allowed me to "zoom into" or resize the existing term floating window to (fullsize in my case) temporarily whilst i sleuth.

Thoughts?

Send Esc sequence to terminal

It seems impossible to send Esc or any other control characters to the terminal. If I run something like git commit in the terminal, it opens another vim instance to write the commit and there is no way for me to close them vim instance since the terminal never receives the Esc command. Is there a way to still send it?

Two problems with nvr (floaterm CLI): GIT_EDITOR, floaterm#util#open

Hi, I appreciate this plugin again. I would like to discuss two problems I found about the floaterm CLI which calls neovim-remote (nvr).

1. Please don't set GIT_EDITOR

The plugin overrides $GIT_EDITOR when floaterm is autoloaded (#60). I don't want it as I already have my own $GIT_EDITOR config in vimrc, so it should be configurable (using some g: variables). Well, I suggest this behavior should be turned off by default and users may want to explicit enable this feature, but either default might be fine.

2. floaterm#util#open just does not work

Even if I have $GIT_EDITOR = 'floaterm', it doesn't work as expected. What the floaterm CLI does is just call neovim remote (or nvr) with: --remote-expr "floaterm#util#edit('$name')

But this function behaves weird. By default it simply hides the floaterm window and runs :edit. It closes the floating window --- why? Is it intended?

I am running nvr commands from floating terminals and non-floating terminals (e.g. split and vsplit then :term), so what I expected is opening a new floating terminal as the name of function suggests.

Do not open an existing terminal buffer on first run

Thanks for this plugin.

When I open a terminal in a buffer, then run :FloatTermToggle for the first time, the first terminal buffer gets opened.
I'd like to have a new terminal session just for floatterm instead.

bottomleft position is broken

Terminal overlaps with the border when using bottomleft position.

bottomleft

Possible fix:

diff --git i/autoload/floaterm/floatwin.vim w/autoload/floaterm/floatwin.vim
index 192ddc6..6781669 100644
--- i/autoload/floaterm/floatwin.vim
+++ w/autoload/floaterm/floatwin.vim
@@ -66,8 +66,8 @@ function! s:floatwin_pos(width, height) abort
     let vert = 'S'
     let hor = 'E'
   elseif g:floaterm_position ==# 'bottomleft'
-    let row = &lines
-    let col = 0
+    let row = &lines - 2
+    let col = 1
     let vert = 'S'
     let hor = 'W'
   elseif g:floaterm_position ==# 'center'

bottomleft2

TODO

- [ ] Give floaterm buffer a unique variable to differentiate from other terminals(if there are multiple terminal buffers...)

function! s:onOpenTerm() abort
augroup NvimCloseTermWin
autocmd!
autocmd TermClose <buffer> if &buftype=='terminal' | bdelete! | endif
augroup END
setlocal winblend=30
setlocal bufhidden=hide
setlocal signcolumn=no
setlocal nobuflisted
setlocal nocursorline
setlocal nonumber
setlocal norelativenumber
endfunction

for winnr in range(1, winnr('$'))
if getbufvar(winbufnr(winnr), '&buftype') == 'terminal'
let found_winnr = winnr
endif
endfor
if found_winnr > 0
if &buftype == 'terminal'
" if current window is the terminal window, close it
execute found_winnr . ' wincmd q'
else
" if current window is not terminal, go to the terminal window
execute found_winnr . ' wincmd w'
endif

`hiGroup` not follow `g:floaterm_border_highlight`

NormalFloat will cause some color problem here I dont know why, and Normal is OK.
Then i found hiGroup not follow g:floaterm_border_highlight, this could be a forgotten work.

let hiGroup = 'NormalFloat'
while v:true
let hiInfo = execute('hi ' . hiGroup)
let g:floaterm_background = matchstr(hiInfo, 'guibg=\zs\S*')
let hiGroup = matchstr(hiInfo, 'links to \zs\S*')
if g:floaterm_background !=# '' || hiGroup ==# ''
break
endif
endwhile
endif
if g:floaterm_background !=# ''
execute 'hi FloatTermNormal term=NONE guibg='. g:floaterm_background
setlocal winhighlight=NormalFloat:FloatTermNormal,FoldColumn:FloatTermNormal

My config:

map <leader>m :FloatermToggle<CR>
tnoremap <Esc> <C-\><C-n>:FloatermToggle<CR>
let g:floaterm_winblend = 10
let g:floaterm_position = 'center'
let g:floaterm_border_highlight = 'Normal'

background color not respected in floating windows

I can see the highlight group was applied like below, but actually it does not change the background of the floating windows.

FloatTermNormal xxx guibg=red

Because setwinvar is being called on the terminal buffer, not a floating window one:

call setwinvar(bufnr('%'), '&winhl', 'Normal:FloatTermNormal')

Actually nvim_open_win returns a different window number and this is the correct window handle to call setwinvar on.

Seg fault

(if the mappings matter at all)
Given:

nmap <silent> <Leader>fp :FloatermNew python<cr>
tnoremap  <silent> <Leader>ft <C-\><C-n>:FloatermToggle<CR>

I regularly see a segfault when:

  • open vim
  • fp
  • ft

If I instead, FloatermToggle before running FloatermNew python, it does not segfault.

I want to say there are other circumstances through which I've triggered this behavior, but this is the only one i can trigger on demand right now.

lf wrapper deletes previous buffer from list.

I think this is the same for all the wrappers..

  if filereadable(tmp_file)
    bd!
    let file_data = readfile(tmp_file)
    execute delete(tmp_file)
  else
    return
  endif

The buffer is deleted on line 32. This destroys the floating window but destroys the buffer from the list as well.

If I remove this line, the floating window is not destroyed upon pressing q to quit lf.

Not sure how to destroy the floating window, and it's terminal without destroying the buffer it was initialised from?

Popup term in wrong location.

Hi,
When I split vertically into 2 windows, and the cursor is on the 2nd window, on the right, my centered float term is no longer centered like this.
Screenshot 2020-01-12 at 15 31 32

Could you possibly know why?
Thank you.

Border window on nvim is sometimes not closed

image

Steps:

  1. FloatermNew height=0.3 width=0.4 name='1'
  2. FloatermNew height=0.3 width=0.4 name='2'
  3. FloatermToggle 1
  4. Without toggling 1, select another window.
  5. FloatermToggle 2
  6. Now toggle both 1 and 2.
  7. Border window remains

I do not understand enough about the code base to debug this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.