From 43ab63549abf0cf124b812f2874cc3731bbe1b85 Mon Sep 17 00:00:00 2001 From: Marc Hamamji Date: Fri, 14 Apr 2023 15:19:41 +0300 Subject: [PATCH 1/3] Add handler docs --- README.md | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 53e276a..b26cd68 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ A customizable Neovim plugin to run code inside the editor - [Installation](#installation) - [Usage](#usage) - [Configuration](#configuration) +- [Handlers](#handlers) - [Helpers](#helpers) - [Advanced handlers configurations](#advanced-handlers-configurations) - [Contribution](#contribution) @@ -53,7 +54,10 @@ A customizable Neovim plugin to run code inside the editor ## Usage ```lua - require('runner').run() -- Can also be called with the buffer number where the code is + require('runner').run() + + -- Can also be called with the buffer number where the code is: + -- require('runner').run( ) -- To set a mapping vim.keymap.set('n', '', require('runner').run) @@ -62,8 +66,9 @@ A customizable Neovim plugin to run code inside the editor ## Configuration #### `setup(options)` - - Runner comes with the following defaults: + + Using this setup function is **optional**. Runner comes with the following defaults: + ```lua require('runner').setup({ position = 'right', -- position of the terminal window when using the shell_handler @@ -74,9 +79,23 @@ A customizable Neovim plugin to run code inside the editor }) ``` - #### `set_handler(filetype, handler)` +## Handlers + + Runner has the concept of handlers. Handlers are language specific and are little + functions that run code. For example, a handler could run the project, run the tests, + build the project, or even run custom project scripts. + + A handler is a function that accepts a buffer number as an argument, and doesn't return + anything. The buffer number defaults to the buffer where the `run()` function was called, + or, if specified, the buffer number that was passed to the `run()` function. This buffer + number where the code to run is located. Runner runs the appropriate handler based on this + buffer's filetype. + + For using multiple handlers on the same filetype, see the [choice helper](#choice(handlers)) - Default handlers can be found [here](./lua/runner/handlers/init.lua). + #### `set_handler(filetype, handler)` + + This function **overwrites** the handler set for the specified filetype. Default handlers can be found [here](./lua/runner/handlers/init.lua). | Argument name | Description | Type | |---------------- | --------------- | --------------- | @@ -111,6 +130,7 @@ A customizable Neovim plugin to run code inside the editor - `select_horizontal` (defaults to ``): Opens the window at the bottom of the screen. - `select_vertical` (defaults to ``): Opens the window at the right of the screen.
+
| Argument name | Description | Type | |---------------- | --------------- | --------------- | From ba6ebadeb70997a13e5ba308bc83d76d4aa629f4 Mon Sep 17 00:00:00 2001 From: Marc Hamamji Date: Fri, 14 Apr 2023 15:24:03 +0300 Subject: [PATCH 2/3] Fix formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b26cd68..98f0646 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ A customizable Neovim plugin to run code inside the editor number where the code to run is located. Runner runs the appropriate handler based on this buffer's filetype. - For using multiple handlers on the same filetype, see the [choice helper](#choice(handlers)) + For using multiple handlers on the same filetype, see the [choice helper](#choice(handlers)). #### `set_handler(filetype, handler)` From b4191bc63da2338d363f4b9f93022f35f87d5187 Mon Sep 17 00:00:00 2001 From: Marc Hamamji Date: Fri, 14 Apr 2023 15:36:59 +0300 Subject: [PATCH 3/3] Rephrase handler description --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 98f0646..a36072a 100644 --- a/README.md +++ b/README.md @@ -85,11 +85,11 @@ A customizable Neovim plugin to run code inside the editor functions that run code. For example, a handler could run the project, run the tests, build the project, or even run custom project scripts. - A handler is a function that accepts a buffer number as an argument, and doesn't return - anything. The buffer number defaults to the buffer where the `run()` function was called, - or, if specified, the buffer number that was passed to the `run()` function. This buffer - number where the code to run is located. Runner runs the appropriate handler based on this - buffer's filetype. + A handler is a function that accepts a buffer number as an argument, and doesn't + return anything. This buffer number is the buffer where the code to run is located. + It defaults to the buffer where the `run()` function was called, or, if specified, + is the buffer number that was passed to the `run()` function. Runner runs the + appropriate handler based on this buffer's filetype. For using multiple handlers on the same filetype, see the [choice helper](#choice(handlers)).