Giter Club home page Giter Club logo

fterm.nvim's Introduction

FTerm.nvim

๐Ÿ”ฅ No-nonsense floating terminal plugin for neovim ๐Ÿ”ฅ

FTerm

Requirements

  • Neovim 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 meant for edit in the default terminal. See custom terminal section for use case.

  • dimensions: Object containing the terminal window dimensions.

    The value for each field 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: Neovim's 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 }

map('n', '<A-i>', '<CMD>lua require("FTerm").toggle()<CR>', opts)
map('t', '<A-i>', '<C-\\><C-n><CMD>lua require("FTerm").toggle()<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:

local term = require("FTerm.terminal")

local gitui = term:new():setup({
    cmd = "gitui",
    dimensions = {
        height = 0.9,
        width = 0.9
    }
})

 -- Use this to toggle gitui in a floating terminal
function _G.__fterm_gitui()
    gitui:toggle()
end

Screenshot

gitui

local term = require("FTerm.terminal")

local top = term:new():setup({
    cmd = "bpytop"
})

 -- Use this to toggle bpytop in a floating terminal
function _G.__fterm_top()
    top:toggle()
end

Screenshot

bpytop

Credits

vim-floaterm for the inspiration

fterm.nvim's People

Contributors

numtostr avatar joeltari avatar jonathf avatar

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.