Placeholder support for snippet engines (#76)

- Add support for placeholders in snippet insertion !
  None: placeholders are automatically set when using a bundled snippet engine.
  - Add `enable_placeholders` option (see |neogen-configuration|)
  - Add `placeholders_text` option (see |neogen-configuration|)

Co-authored-by: danymat <d.danymat@gmail.com>
This commit is contained in:
mg979
2022-03-13 16:05:04 +01:00
committed by GitHub
parent 4e3dca63c6
commit c9ac5a6fd8
6 changed files with 155 additions and 17 deletions

View File

@@ -101,6 +101,27 @@ Neogen provides those defaults, and you can change them to suit your needs
-- Use a snippet engine to generate annotations.
snippet_engine = nil,
-- Enables placeholders when inserting annotation
enable_placeholders = true,
-- Placeholders used during annotation expansion
placeholders_text = {
["description"] = "[TODO:description]",
["tparam"] = "[TODO:tparam]",
["parameter"] = "[TODO:parameter]",
["return"] = "[TODO:return]",
["class"] = "[TODO:class]",
["throw"] = "[TODO:throw]",
["varargs"] = "[TODO:varargs]",
["type"] = "[TODO:type]",
["attribute"] = "[TODO:attribute]",
["args"] = "[TODO:args]",
["kwargs"] = "[TODO:kwargs]",
},
-- Placeholders highlights to use. If you don't want custom highlight, pass "None"
placeholders_hl = "DiagnosticHint",
}
<
# Notes~
@@ -159,12 +180,23 @@ Feel free to submit a PR, I will be happy to help you !
We use semantic versioning ! (https://semver.org)
Here is the current Neogen version:
>
neogen.version = "2.5.0"
neogen.version = "2.6.0"
<
# Changelog~
Note: We will only document `major` and `minor` versions, not `patch` ones.
## 2.6.0~
- Add support for placeholders in snippet insertion !
- Add `enable_placeholders` option (see |neogen-configuration|)
- Add `placeholders_text` option (see |neogen-configuration|)
Example placeholders:
>
--- [TODO:description]
---@param param1 [TODO:parameter] [TODO:description]
function test(param1) end
<
## 2.5.0~
- Ruby: Add support for `tomdoc` (http://tomdoc.org)
## 2.4.0~
@@ -202,6 +234,15 @@ To use a snippet engine, pass the option into neogen setup:
Some snippet engines come out of the box bundled with neogen:
- `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
If you want to customize the placeholders, you can use `placeholders_text` option:
>
require('neogen').setup({
placeholders_text = {
['description'] = "[description]",
}
})
<
# Add support for snippet engines~
To add support to a snippet engine, go to `lua/neogen/snippet.lua`.