Skip to content

Commit c26ad83

Browse files
committed
added fallback to builtin terminal when snacks in not available
1 parent c9b574e commit c26ad83

File tree

2 files changed

+217
-142
lines changed

2 files changed

+217
-142
lines changed

README.md

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44

55
lightweight neovim code runner plugin that works with Snacks.nvim terminal
66

7+
## Table of Contents
8+
- [canter.nvim](#canternvim)
9+
- [Introduction](#introduction)
10+
- [Table of Contents](#table-of-contents)
11+
- [Requirements](#requirements)
12+
- [Installation](#installation)
13+
- [With lazy.nvim](#with-lazynvim)
14+
- [Other package managers](#other-package-managers)
15+
- [Configuration](#configuration)
16+
- [Options](#options)
17+
- [Default options](#default-options)
18+
- [Example config](#example-config)
19+
- [Usage](#usage)
20+
- [Terminal Usage](#terminal-usage)
21+
- [Shebang example with node](#shebang-example-with-node)
22+
- [Default Keybinds](#default-keybinds)
23+
- [Roadmap](#roadmap)
24+
- [Credits](#credits)
25+
726
## Requirements
827

928
- Neovim (>= 0.7)
@@ -44,13 +63,24 @@ opts = {
4463
-- File extension to runner/interpreter mapping
4564
runners = {},
4665

47-
-- Terminal configuration (passed to Snacks.nvim)
48-
Snacks_terminal_opts = {
49-
win = {
50-
position = "bottom",
51-
relative = "editor"
66+
-- Terminal configuration
67+
terminal = {
68+
type = "snacks", -- "snacks" or "builtin"
69+
70+
-- Options for built-in terminal
71+
builtin_opts = {
72+
position = "vsplit", -- "vsplit", "split", or "float"
73+
escape_keymap = true, -- escape terminal mode with <Esc>
5274
},
53-
interactive = false
75+
76+
-- Options for Snacks.nvim terminal
77+
snacks_opts = {
78+
win = {
79+
position = "bottom",
80+
relative = "editor"
81+
},
82+
interactive = false
83+
}
5484
},
5585

5686
-- Default keymaps (can be overridden)
@@ -70,9 +100,10 @@ opts = {
70100
**NOTE** - does not come with runners by default, you must add your own.
71101

72102
- `runners`: table `([file_extension] = runner/interpreter)`
73-
- `Snacks_terminal_opts`: table of options passed to Snacks.nvim terminal
74-
- `win`: window positioning options
75-
- `interactive`: whether terminal starts in interactive mode
103+
- `terminal`: table of options passed to terminal
104+
- `type`: type of terminal
105+
- `builtin_opts`: options for built-in terminal
106+
- `snacks_opts`: options for Snacks.nvim terminal
76107
- `keymaps`: table of keybindings and their descriptions
77108

78109
#### Example config
@@ -84,12 +115,11 @@ opts = {
84115
["rb"] = "ruby",
85116
["py"] = "python"
86117
},
87-
Snacks_terminal_opts = {
88-
win = {
89-
position = "right", -- Change terminal position to right
90-
relative = "editor"
91-
},
92-
interactive = true -- Always start in interactive mode
118+
terminal = {
119+
type = "builtin",
120+
builtin_opts = {
121+
position = "vsplit",
122+
}
93123
}
94124
}
95125
```
@@ -109,6 +139,12 @@ opts = {
109139
- same as above, but stops before actually executing so you can add flags or confirm the command before pressing enter.
110140
- necessarily, the terminal is interactive by default in this mode.
111141

142+
### Terminal Usage
143+
144+
When using the built-in terminal in wait mode:
145+
- Press `<Esc>` to exit terminal mode and return to normal mode (if `escape_keymap` is enabled)
146+
- Alternatively, use the default Neovim terminal escape sequence: `<C-\><C-n>`
147+
112148
### Shebang example with node
113149

114150
`test.js`
@@ -158,4 +194,4 @@ opts = {
158194

159195
## Credits
160196

161-
- plugin inspired by keymap script by u/linkarzu on r/neovim
197+
- plugin inspired by keymap script by u/linkarzu on [r/neovim](https://www.reddit.com/r/neovim/comments/1ai19ux/execute_current_file_script_using_a_keymap_i_use/)

0 commit comments

Comments
 (0)