• Stars
    star
    105
  • Rank 318,232 (Top 7 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Lua-Neovim plugin that toggles a terminal

nvim-terminal

Terminal plugin to open/toggle the terminals in Neovim

demo.mp4

Features

  • Toggle terminal window
  • Quick switching between multiple terminal buffers

Install the plugin

packer

use {
    's1n7ax/nvim-terminal',
    config = function()
        vim.o.hidden = true
        require('nvim-terminal').setup()
    end,
}

Default Keymaps

leader + ; - Toggle open/close terminal

leader + 1 - Open terminal 1

leader + 2 - Open terminal 2

leader + 3 - Open terminal 3

leader + 4 - Open terminal 4

leader + 5 - Open terminal 5

leader + + - Increase window height

leader + - - Decrease window height

leader + leader + + - Increase window width

leader + leader + - - Decrease window width

Configuration

Simply pass the custom configuration to setup method

-- following option will hide the buffer when it is closed instead of deleting
-- the buffer. This is important to reuse the last terminal buffer
-- IF the option is not set, plugin will open a new terminal every single time
vim.o.hidden = true

require('nvim-terminal').setup({
    window = {
        -- Do `:h :botright` for more information
        -- NOTE: width or height may not be applied in some "pos"
        position = 'botright',

        -- Do `:h split` for more information
        split = 'sp',

        -- Width of the terminal
        width = 50,

        -- Height of the terminal
        height = 15,
    },

    -- keymap to disable all the default keymaps
    disable_default_keymaps = false,

    -- keymap to toggle open and close terminal window
    toggle_keymap = '<leader>;',

    -- increase the window height by when you hit the keymap
    window_height_change_amount = 2,

    -- increase the window width by when you hit the keymap
    window_width_change_amount = 2,

    -- keymap to increase the window width
    increase_width_keymap = '<leader><leader>+',

    -- keymap to decrease the window width
    decrease_width_keymap = '<leader><leader>-',

    -- keymap to increase the window height
    increase_height_keymap = '<leader>+',

    -- keymap to decrease the window height
    decrease_height_keymap = '<leader>-',

    terminals = {
        -- keymaps to open nth terminal
        {keymap = '<leader>1'},
        {keymap = '<leader>2'},
        {keymap = '<leader>3'},
        {keymap = '<leader>4'},
        {keymap = '<leader>5'},
    },
})

Add Keymaps Manually

nvim-terminal adds a global variable called NTGlobal. When you call require('nvim-terminal').setup() it adds terminal and window properties to NTGlobal

vim.api.nvim_set_keymap('n', '<leader>t', ':lua NTGlobal["terminal"]:toggle()<cr>', silent)
vim.api.nvim_set_keymap('n', '<leader>1', ':lua NTGlobal["terminal"]:open(1)<cr>', silent)
vim.api.nvim_set_keymap('n', '<leader>+', ':lua NTGlobal["window"]:change_height(2)<cr>', silent)
vim.api.nvim_set_keymap('n', '<leader>-', ':lua NTGlobal["window"]:change_height(-2)<cr>', silent)

PRO MODE

Default Terminal

terminal = require('nvim-terminal').DefaultTerminal;

local silent = { silent = true }

vim.api.nvim_set_keymap('n', '<leader>t', ':lua terminal:toggle()<cr>', silent)
vim.api.nvim_set_keymap('n', '<leader>1', ':lua terminal:open(1)<cr>', silent)
vim.api.nvim_set_keymap('n', '<leader>2', ':lua terminal:open(2)<cr>', silent)
vim.api.nvim_set_keymap('n', '<leader>3', ':lua terminal:open(3)<cr>', silent)

Customized Window

local Terminal = require('nvim-terminal.terminal')
local Window = require('nvim-terminal.window')

local window = Window:new({
	position = 'botright',
	split = 'sp',
	width = 50,
	height = 15
})

terminal = Terminal:new(window)

More Repositories

1

nvim-window-picker

This plugins prompts the user to pick a window and returns the window id of the picked window
Lua
155
star
2

dotnvim

Neovim Lua configuration pre-configured for Java, JavaScript, Typescript etc...
Lua
113
star
3

nvim-comment-frame

Detects the language using treesitter and adds a comment block
Lua
91
star
4

nvim-react

Reactive UI framework for neovim
Lua
47
star
5

nvim-search-and-replace

Really simple plugin to search and replace multiple files
Lua
42
star
6

neovim-lua-plugin-boilerplate

Starter template for creating Neovim Lua plugins
Lua
31
star
7

keyboard-layout-analyzer

Calculates the number of finger movements required to type something using different keyboard layouts.
Rust
19
star
8

keyboard-layout-status

Calculates the number of finger movements required to type something using different keyboard layouts.
Python
14
star
9

dotvim

Vim (vimscript) configuration for React JS, Typescript and many other languages
12
star
10

dwm-status

simple and flexible dwm status bar application
Python
11
star
11

youtube-neovim-treesitter-query

Presentation related to my Youtube tutorial
Lua
10
star
12

nvim-snips

My custom luasnip snippets mainly targeting my development work
Lua
6
star
13

nvim-ts-utils

Some useful tree-sitter utils I don't want keep inside my neovim configuration
Lua
6
star
14

youtube-java-debugging

Absolute minimal configuration for Neovim that is just enough to debug Java application
Lua
6
star
15

open-unicode-converter

open unicode converter implementation
JavaScript
6
star
16

youtube-treesitter

4
star
17

st

simple terminal with some of my favorite patches
C
3
star
18

projectdot-ide

TypeScript
3
star
19

book-designing-object-oriented-software

Just maintaining a summary + important stuff of the "Book Designing Object-Oriented Software" by Rebecca Wirfs-Brock
2
star
20

nvim-lazy-inner-block

Remap inner block operations without letter i
Lua
2
star
21

cypress-commons

Reusable components, commands & more to make your day easier
JavaScript
2
star
22

dwm

dwm with some of my favorite patches
C
1
star
23

demo-dotnvim

Don't use this!!! This is a Neovim config with few plugins, keymaps, options for my Youtube tutorials.
Lua
1
star
24

my-website

my website written in web assembly
Rust
1
star
25

facebook-manager

Predefined UI automation to manager private Facebook profile
TypeScript
1
star
26

linux-common

1
star
27

nvim-actions

Text manipulate but faster
Lua
1
star
28

nix-shell-tensorflow-with-cuda

nix-shell created for using tensorflow-with-cuda
Nix
1
star
29

lazyvim-dotnvim

Lua
1
star
30

dothome

Python
1
star
31

silenium

Java
1
star
32

youtube-generate-java-doc-comment-using-treesitter

This repository is related to two YouTube videos I have done
Lua
1
star
33

nvim-treesitter-format

Formats files using treesitter syntax tree
Lua
1
star
34

nvim-session

simple wrapper around mksession to auto save and load the session
Lua
1
star
35

nvim-settings

Persistent store for settings
Lua
1
star
36

simple-message-router

Router (https://www.npmjs.com/package/router) that has nothing to do with http
JavaScript
1
star
37

git-cheat-sheet

1
star
38

dmenu

dmenu with my favorite patches
C
1
star
39

pytorch-basics

Jupyter Notebook
1
star
40

http-client-testing-server

simple server designed to test http clients
JavaScript
1
star
41

yolov4-training-google-colab-workflow

Google colab notebook script to build the colab environment and start training in one click
Jupyter Notebook
1
star