Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: terminal keybinds #367

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/configuration/keybindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,47 @@ To change the terminal mapping:
```lua
lvim.builtin.terminal.open_mapping = "<c-t>"
```

Create custom terminal commands by extending the `lvim.builtin.terminal.terminals` table.
`size` is specified as a percentage of the buffer size, with `size = 1` equivalent to fullscreen.
The `desc` parameter will display in Whichkey for mappings starting with `<leader>`. Other values are passed to `toggleterm:new`

The built-in terminals can be overridden or modified with the following code:

```lua
lvim.builtin.terminal.terminals = {
{ keymap = "<M-1>", direction = "horizontal" },
{ keymap = "<M-2>", direction = "vertical" },
{ keymap = "<M-3>", direction = "float" },
{ keymap = "<leader>gg", cmd = "lazygit", size= 1 },
}
```
To create user-defined terminals, simply extend the `lvim.builtin.terminal.terminals` table, as shown in this example:

```lua
local terminals = {
{ keymap = "<leader>u", cmd = "sudo dmesg | less", desc = "Show Kernel Logs", size = 1 },
{ keymap = "<leader>h", cmd = "htop", desc = "Interactive System Monitor", size = 0.8 },
{ keymap = "<M-4>", cmd = "neofetch", close_on_exit = false, direction = "horizontal", size = 0.6 },
{
keymap = "<leader>os",
direction = "vertical",
cmd = "docker ps",
desc = "List Docker Containers",
close_on_exit = false,
persist_mode = false,
size = 0.3,
},
}
vim.list_extend(lvim.builtin.terminal.terminals, terminals)
```

Default values for the terminals can be found in `lvim.builtin.terminal.terminals_defaults`:
```lua
lvim.builtin.terminal.terminals_defaults = {
-- `cmd` defaults to `lvim.builtin.terminal.shell`
direction = "horizontal",
horizontal_size = 0.3,
vertical_size = 0.4,
}
```