Skip to content

winter233/FTerm.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FTerm.nvim

🔥 No nonsense floating terminal written in lua 🔥

FTerm

Requirements

  • Neovim Nightly (0.5)

Install

use {
    "numtostr/FTerm.nvim",
    config = function()
        require("FTerm").setup()
    end
}
Plug 'numtostr/FTerm.nvim'

" Somewhere after plug#end()

lua require('FTerm').setup()

Functions

  • require('FTerm').setup() - To configure the terminal window.

  • require('FTerm').open() - To open the terminal

  • require('FTerm').close() - To close the terminal

    Actually this closes the floating window not the actual terminal buffer

  • require('FTerm').toggle() - To toggle the terminal

Configuration

Options can be provided when calling setup().

  • cmd: Command to run inside the terminal. (default: os.getenv('SHELL'))

NOTE: This is not intended for edit in the default terminal. See custom terminal section.

  • dimensions: Object containing the terminal window dimensions.

    Fields: (Values should be between 0 and 1)

    • height - Height of the terminal window (default: 0.8)
    • width - Width of the terminal window (default: 0.8)
    • x - X axis of the terminal window (default: 0.5)
    • y - Y axis of the terminal window (default: 0.5)
  • border: Native window border (default: single). See :h nvim_open_win for more configuration options.

Setup

require'FTerm'.setup({
    dimensions  = {
        height = 0.8,
        width = 0.8,
        x = 0.5,
        y = 0.5
    },
    border = 'single' -- or 'double'
})

-- Keybinding
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }

-- Closer to the metal
map('n', '<C-Space>', '<CMD>lua require("FTerm").toggle()<CR>', opts)
map('t', '<C-Space>', '<C-\\><C-n><CMD>lua require("FTerm").toggle()<CR>', opts)
map('n', '<F8>', '<CMD>lua require("FTerm").create()<CR>', opts)
map('t', '<F8>', '<C-\\><C-n><CMD>lua require("FTerm").create()<CR>', opts)
map('t', '<F11>', '<C-\\><C-n><CMD>lua require("FTerm").select_prev()<CR>', opts)
map('t', '<F12>', '<C-\\><C-n><CMD>lua require("FTerm").select_next()<CR>', opts)

Custom Terminal

By default FTerm only creates and manage one terminal instance but you can create your terminal by using the underlying terminal function and overriding the default command.

Below are some examples:

require("FTerm").create({ cmd="lazygit" })

Credits

vim-floaterm for the inspiration

About

open multi terminals in neovim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%