Skip to content

Commit

Permalink
docs: terminal keybinds
Browse files Browse the repository at this point in the history
  • Loading branch information
opalmay committed Feb 7, 2023
1 parent f0d8d70 commit 3ee8ada
Showing 1 changed file with 44 additions and 0 deletions.
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.keybinds` 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 keybinds can be overridden or modified with the following code:

```lua
lvim.builtin.terminal.keybinds = {
{ 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 keybinds, simply extend the `lvim.builtin.terminal.keybinds` table, as shown in this example:

```lua
local keybinds = {
{ 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.keybinds, keybinds)
```

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

1 comment on commit 3ee8ada

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log for details.

Unrecognized words (2)

fullscreen
keymap

To accept ✔️ these unrecognized words as correct, run the following commands

... in a clone of the git@github.com:LunarVim/lunarvim.org.git repository
on the terminal-keybinds-docs branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/LunarVim/lunarvim.org/actions/runs/4118053446/attempts/1'

Please sign in to comment.