- Notifications
You must be signed in to change notification settings - Fork0
pianocomposer321/consolation.nvim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A general-perpose terminal wrapper and management plugin for neovim, written in lua
https://asciinema.org/a/88T1XmVG6Xak4580OHsrBV7kW
I know what you're thinking: "There are already dozens of terminal wrapper plugins for vim/neovim out there! Why yet another?" And you'd be partially right - the default configuration of consolation.nvim is basically the same asalltheotherterminalwrapperpluginsoutthere. But, as is the case with many vim and neovim plugins, consolation.nvim is much more than its default configuration.
The main reason thatthe author created this plugin is because while there is no shortage of either terminal management plugins (e.g.Neoterm) or floating terminal plugins (e.g.Floaterm), trying to get either the terminal management plugin to work with floating windows or the floating terminal plugin to accept input programmatically is a major pain. The idea of this plugin is to take absolutelyany asthetically enhancing terminal plugin and make it easy to use programmatically as well. What this means practically speaking is that you can have a floating terminal (like withFloaterm orFTerm) that can be controlled with lua functions similarly toNeoterm.
Packer.nvim:use 'pianocomposer321/consolation.nvim'vim-plug:Plug 'pianocomposer321/consolation.nvim'etc.
The way you interact with Consolation is through itsWrapper object.
Returns a newWrapper object
Setup theWrapper using the provided configuration options
create(function): The function used to create the terminal
Default
function()vim.cmd("vnew | term")end
open(function): The function used to open the terminal.
Default
function(self)localwinnr=self.get_winnr()ifwinnr==-1thenvim.cmd("vnew")vim.cmd("b"..self.bufnr)elsevim.cmd(winnr.."wincmd w")endend
close(function): The function used to close the terminal.
Default
function(self)localwinnr=self.get_winnr()vim.cmd(winnr.."wincmd c")end
kill(function): The function used to kill the terminal.
Default
function (self)vim.cmd("bd!"..self.bufnr)end
Except forcreate, all of these functions accept one argument, which is a reference to theWrapper object iself. This way all of its variables likebufnr,winid, etc. are avaliable to the functions.
Creates a new terminal buffer, using thecreate function specified in theWrapper:setup(opts) function, and updates values for the terminal'sbufnr,winid, etc.
Opens the terminal using theopen function specified in theWrapper:setup(opts) function.
cmd(string, defaultnil): Command to run upon opening the terminalcreate(bool, defaulttrue): Whether to create the terminal if it does not already exist
Closes the terminal using theclose function specified in theWrapper:setup(opts) function.
Kills the terminal using thekill function specified in theWrapper:setup(opts) function, and resets theWrapper object'schannel,winid, andbufnr variables tonil.
Toggles the terminal using either theopen or theclose function specified in theWrapper:setup() opts function.
create(bool, defaulttrue): Whether to create the terminal when opening it if it does not already exist
Sends a command to the terminal.
cmd(string, REQUIRED): The command to sendopen(bool, defaulttrue): Whether to open the terminal before running the commandcreate(bool, defaulttrue): Whether to create the terminal if it does not already exist
Utility function that returns whether the terminal buffer is currently displayed in a window (IOW, open).
Utility function that returns theWrapper object'swinnr. (:help bufwinnr())
localWrapper=require("consolation").WrapperBuiltinTerminalWrapper=Wrapper:new()BuiltinTerminalWraper:setup {create=function()vim.cmd("vnew | term")end,open=function(self)ifself:is_open()thenlocalwinnr=vim.fn.bufwinnr(self.bufnr)vim.cmd(winnr.."wincmd w")elsevim.cmd("vnew")vim.cmd("b"..self.bufnr)endend,close=function(self)localwinnr=vim.fn.bufwinnr(self.bufnr)vim.cmd(winnr.."wincmd c")end,kill=function(self)vim.cmd("bd!"..self.bufnr)end}-- Try:-- BuiltinTerminalWraper:open {cmd = "echo hi"}-- BuiltinTerminalWraper:send_command {cmd = "echo hi again"}-- BuiltinTerminalWraper:close()-- BuiltinTerminalWraper:toggle()-- BuiltinTerminalWraper:kill()
localterm=require("Fterm.terminal")Runner=term:new():setup()FtermWrapper=Wrapper:new()FtermWrapper:setup {create=function()Runner:open()end,open=function(_)Runner:open()end,close=function(_)Runner:close()end,kill=function(_)Runner:close(true)end}
About
A general-purpose terminal wrapper and management plugin for neovim, written in lua
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
