Snippet support (#72)

To know more about snippet integration, please visit `:h snippet-integration`, or https://github.com/danymat/neogen#snippet-support !

Co-authored-by: danymat <d.danymat@gmail.com>
This commit is contained in:
mg979
2022-02-26 12:48:11 +01:00
committed by GitHub
parent cd10ee6f55
commit d5f447e5cc
6 changed files with 182 additions and 29 deletions

View File

@@ -8,6 +8,7 @@ Table of contents:
Generate annotations.....................................|neogen.generate()|
Contributing................................................|neogen-develop|
Changes in neogen plugin..................................|neogen-changelog|
Use popular snippet engines............................|snippet-integration|
Configurations for the template table........|neogen-template-configuration|
How to create/customize an annotation....................|neogen-annotation|
@@ -97,18 +98,24 @@ Neogen provides those defaults, and you can change them to suit your needs
-- Configuration for default languages
languages = {},
-- Use a snippet engine to generate annotations.
snippet_engine = nil,
}
<
# Notes~
- to configure a language, just add your configurations in the `languages` table.
For example, for the `lua` lang:
>
>
languages = {
lua = { -- Configuration here }
}
<
Default configurations for a languages can be found in `lua/neogen/configurations/<you_language>.lua`
<
Default configurations for a languages can be found in `lua/neogen/configurations/<your_language>.lua`
- To know which snippet engines are supported, take a look at |snippet-integration|.
Example: `snippet_engine = "luasnip"`
------------------------------------------------------------------------------
@@ -121,9 +128,15 @@ For example, if you are inside a function, and called `generate({ type = "func"
Neogen will go until the start of the function and start annotating for you.
Parameters~
{opts} `(table)` Options to change default behaviour of generation.
- {opts.type} `(string?, default: "func")` Which type we are trying to use for generating annotations.
{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.return_snippet} `boolean` if true, will return 3 values from the function call.
This option is useful if you want to get the snippet to use with a unsupported snippet engine
Below are the returned values:
- 1: (type: `string[]`) the resulting lsp snippet
- 2: (type: `number`) the `row` to insert the annotations
- 3: (type: `number`) the `col` to insert the annotations
------------------------------------------------------------------------------
*neogen-develop*
@@ -152,6 +165,10 @@ Here is the current Neogen version:
Note: We will only document `major` and `minor` versions, not `patch` ones.
## 2.3.0~
- Added bundled support with snippet engines !
Check out |snippet-integration| for basic setup
For more information of possible options, check out |neogen.generate()|
## 2.2.0~
### Python~
- Add support for `*args` and `**kwargs`
@@ -167,6 +184,22 @@ Note: We will only document `major` and `minor` versions, not `patch` ones.
with multiple annotation conventions.
==============================================================================
------------------------------------------------------------------------------
*snippet-integration*
`snippet`
To use a snippet engine, pass the option into neogen setup:
>
require('neogen').setup({
snippet_engine = "luasnip",
...
})
<
Some snippet engines come out of the box bundled with neogen:
- `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
==============================================================================
------------------------------------------------------------------------------
*neogen-template-configuration*