aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-22 01:04:33 -0400
committerzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-22 01:04:33 -0400
commitbb0ff86bc21fd0099e55f6777dad244cddda7e4f (patch)
tree9f35e205fdb13a00298523c701337996fbcc953d
parentrename modules (diff)
add run command docs
-rw-r--r--README.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/README.md b/README.md
index 68e10b5..1cc4152 100644
--- a/README.md
+++ b/README.md
@@ -49,3 +49,30 @@ require("nvterm").setup({
}
})
```
+### Additional Functionality:
+
+NvTerm provides an api for you to send commands to the terminal. You can create different ones for different filetypes like so:
+```
+require("nvterm").setup()
+
+local terminal = require("nvterm.terminal")
+
+local ft_cmds = {
+ python = "python3 " .. vim.fn.expand('%'),
+ ...
+ <your commands here>
+}
+local mappings = {
+ { 'n', '<C-l>', function () terminal.send(ft_cmds[vim.bo.filetype]) end },
+ { 'n', '<Leader>s', function () terminal.new_or_toggle('horizontal') end },
+ { 'n', '<Leader>v', function () terminal.new_or_toggle('vertical') end },
+}
+for _, mapping in ipairs(mappings) do
+ vim.keymap.set(mapping[1], mapping[2], mapping[3], opts)
+end
+```
+
+`terminal.send` also takes a 'type' parameter, so you can choose what type of terminal to send the command to.
+By default, it runs the command in the last opened terminal, or a vertical one if none exist.
+`terminal.send(ft_cmds[vim.bo.filetype], "float")` will run the command in a floating terminal
+