Add annotation type autodetection

Creates a new generate() type, `any`, which contextually adds an
annotation by whichever matching type is first found in the tree around
the cursor.

So, if your cursor is in a function, it will annotate the function, if
in a class or struct definition, it'll annotate that, etc.

Co-authored-by: Sabu Siyad <hello@ssiyad.com>
Signed-off-by: Sabu Siyad <hello@ssiyad.com>
This commit is contained in:
Barak Michener
2022-03-02 14:49:10 -08:00
committed by Sabu Siyad
parent 91b093f11f
commit 2c454f7e68
2 changed files with 69 additions and 14 deletions

View File

@@ -150,8 +150,8 @@ Neogen will go until the start of the function and start annotating for you.
Parameters~
{opts} `(table)` Optional configs to change default behaviour of generation.
- {opts.type} `(string, default: "func")` Which type we are trying to use for generating annotations.
Currently supported: `func`, `class`, `type`, `file`
- {opts.type} `(string, default: "any")` Which type we are trying to use for generating annotations.
Currently supported: `any`, `func`, `class`, `type`, `file`
- {opts.annotation_convention} `(table)` convention to use for generating annotations.
This is language specific. For example, `generate({ annotation_convention = { python = 'numpydoc' } })`
If no convention is specified for a specific language, it'll use the default annotation convention for the language.
@@ -442,4 +442,4 @@ If not specified, will use this line for all types.
{required} `(string)` If specified, is used in if the first field of the table is a `table` (example above)
vim:tw=78:ts=8:noet:ft=help:norl:
vim:tw=78:ts=8:noet:ft=help:norl: