If you’re looking for a straightforward, easy to run and configure terminal integration in Neovim I suggest checking out ugaterm.nvim.
I found out about this plugin after watching ryoppippi’s talk Neovim for Frontend Developers: Boosting Productivity and Creativity at VimConf 2024.
It’s super simple to configure and get running. If you’re using [lazy.nvim])(https://github.com/folke/lazy.nvim).
Create a ugaterm.lua
file in your plugins directory and add the following:
return {
'uga-rosa/ugaterm.nvim',
config = function()
require("ugaterm").setup({
open_cmd = function()
local height = vim.api.nvim_get_option("lines")
local width = vim.api.nvim_get_option("columns")
vim.api.nvim_open_win(0, true, {
relative = "editor",
row = math.floor(height * 0.1),
col = math.floor(width * 0.1),
height = math.floor(height * 0.8),
width = math.floor(width * 0.8),
})
end,
})
end,
}
I created some keymaps to make it easier for me to open, hide, and close terminals:
return {
'uga-rosa/ugaterm.nvim',
config = function()
require("ugaterm").setup({
open_cmd = function()
local height = vim.api.nvim_get_option("lines")
local width = vim.api.nvim_get_option("columns")
vim.api.nvim_open_win(0, true, {
relative = "editor",
row = math.floor(height * 0.1),
col = math.floor(width * 0.1),
height = math.floor(height * 0.8),
width = math.floor(width * 0.8),
})
end,
})
vim.api.nvim_set_keymap("n", "<Leader>uo", ":UgatermOpen<CR>", { noremap = true, silent = true, desc = "Open terminal" })
vim.api.nvim_set_keymap("n", "<Leader>uh", ":UgatermHide<CR>", { noremap = true, silent = true, desc = "Hide terminal" })
vim.api.nvim_set_keymap("n", "<Leader>ux", ":UgatermHide -delete<CR>", { noremap = true, silent = true, desc = "Close terminal" })
end,
}
Here’s what it looks like when running a Ruby script while a Ruby file is open in an existing buffer:
Read the full documentation or checkout my fork (PR to merge changes) that puts the relevant information in the README.md
file.
Of course if you really want no frills terminal you can simply use the :terminal
command built into Neovim but I liked the floating window that ugaterm provides. If you’re looking for a more feature rich terminal experience in Neovim there is toggleterm.nvim and terminal.nvim.