Add support for multiple types, see Readme:Usage

This commit is contained in:
Daniel Mathiot
2021-08-25 13:39:55 +02:00
parent f5390e1c1f
commit 1002ae5948
5 changed files with 174 additions and 117 deletions

View File

@@ -44,14 +44,34 @@ use {
## Usage
I exposed a command `:Neogen` to generate the annotations.
I exposed a function to generate the annotations.
```lua
require('neogen').generate()
```
You can bind it to your keybind of choice, like so:
```lua
vim.api.nvim_set_keymap("n", "<Leader>ng", ":Neogen<CR>", {})
vim.api.nvim_set_keymap("n", "<Leader>ng", ":lua require('neogen').generate()<CR>", {})
```
Calling the `generate` function without any parameters will try to generate annotations for the current function.
You can provide some options for the generate, like so:
```lua
require('neogen').generate({
type = "func" -- the annotation type to generate. Currently supported: func, class
})
```
For example, I can add an other keybind to generate class annotations:
```lua
vim.api.nvim_set_keymap("n", "<Leader>nc", ":lua require('neogen').generate({ type = 'class' })<CR>", {})
```
It'll generate the annotations provided by neogen.
## Configuration