feat(snippets): Add snippy support (#93)
This commit is contained in:
@@ -100,7 +100,7 @@ And this is done via the `snippet_engine` option in neogen's setup:
|
|||||||
|
|
||||||
- `snippet_engine` option will use provided engine to place the annotations:
|
- `snippet_engine` option will use provided engine to place the annotations:
|
||||||
|
|
||||||
Currently supported: `luasnip`.
|
Currently supported: `luasnip`, `snippy`.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require('neogen').setup({ snippet_engine = "luasnip" })
|
require('neogen').setup({ snippet_engine = "luasnip" })
|
||||||
|
|||||||
@@ -180,12 +180,14 @@ Feel free to submit a PR, I will be happy to help you !
|
|||||||
We use semantic versioning ! (https://semver.org)
|
We use semantic versioning ! (https://semver.org)
|
||||||
Here is the current Neogen version:
|
Here is the current Neogen version:
|
||||||
>
|
>
|
||||||
neogen.version = "2.6.0"
|
neogen.version = "2.7.0"
|
||||||
<
|
<
|
||||||
# Changelog~
|
# Changelog~
|
||||||
|
|
||||||
Note: We will only document `major` and `minor` versions, not `patch` ones.
|
Note: We will only document `major` and `minor` versions, not `patch` ones.
|
||||||
|
|
||||||
|
## 2.7.0~
|
||||||
|
- Add support for `snippy` snippet engine ! (see |neogen-snippet-integration|)
|
||||||
## 2.6.0~
|
## 2.6.0~
|
||||||
- Add support for placeholders in snippet insertion !
|
- Add support for placeholders in snippet insertion !
|
||||||
None: placeholders are automatically set when using a bundled snippet engine.
|
None: placeholders are automatically set when using a bundled snippet engine.
|
||||||
@@ -235,6 +237,7 @@ To use a snippet engine, pass the option into neogen setup:
|
|||||||
<
|
<
|
||||||
Some snippet engines come out of the box bundled with neogen:
|
Some snippet engines come out of the box bundled with neogen:
|
||||||
- `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
|
- `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
|
||||||
|
- `"snippy"` (https://github.com/dcampos/nvim-snippy)
|
||||||
|
|
||||||
If you want to customize the placeholders, you can use `placeholders_text` option:
|
If you want to customize the placeholders, you can use `placeholders_text` option:
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ local conf = require("neogen.config").get()
|
|||||||
--- <
|
--- <
|
||||||
--- Some snippet engines come out of the box bundled with neogen:
|
--- Some snippet engines come out of the box bundled with neogen:
|
||||||
--- - `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
|
--- - `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
|
||||||
|
--- - `"snippy"` (https://github.com/dcampos/nvim-snippy)
|
||||||
---
|
---
|
||||||
--- If you want to customize the placeholders, you can use `placeholders_text` option:
|
--- If you want to customize the placeholders, you can use `placeholders_text` option:
|
||||||
--- >
|
--- >
|
||||||
@@ -94,4 +95,20 @@ snippet.engines.luasnip = function(snip, pos)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Expand snippet for snippy engine
|
||||||
|
---@param snip string the snippet to expand
|
||||||
|
---@param pos table a tuple of row, col
|
||||||
|
---@private
|
||||||
|
snippet.engines.snippy = function (snip, pos)
|
||||||
|
local ok, snippy = pcall(require, "snippy")
|
||||||
|
if not ok then
|
||||||
|
notify("Snippy not found, aborting...", vim.log.levels.ERROR)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local row, _ = unpack(pos)
|
||||||
|
vim.api.nvim_buf_set_lines(0, row, row, true, {''}) -- snippy will change `row`
|
||||||
|
vim.api.nvim_win_set_cursor(0, {row + 1, 0}) -- `snip` already has indent so we should ignore `col`
|
||||||
|
snippy.expand_snippet({body = snip})
|
||||||
|
end
|
||||||
|
|
||||||
return snippet
|
return snippet
|
||||||
|
|||||||
Reference in New Issue
Block a user