diff --git a/lua/neogen/init.lua b/lua/neogen/init.lua index 5c13874..a3eb079 100644 --- a/lua/neogen/init.lua +++ b/lua/neogen/init.lua @@ -241,6 +241,8 @@ end --- --- Note: We will only document `major` and `minor` versions, not `patch` ones. (only X and Y in X.Y.z) --- +--- ## 2.16.0~ +--- - Add support for `nvim` snippet engine (default nvim snippet engine) ! (see |neogen-snippet-integration|) --- ## 2.15.0~ --- - Google docstrings now include "Yields:", whenever possible --- ## 2.14.0~ @@ -299,7 +301,7 @@ end --- with multiple annotation conventions. ---@tag neogen-changelog ---@toc_entry Changes in neogen plugin -neogen.version = "2.15.3" +neogen.version = "2.16.0" --minidoc_afterlines_end return neogen diff --git a/lua/neogen/snippet.lua b/lua/neogen/snippet.lua index 60d92c0..1633cfc 100644 --- a/lua/neogen/snippet.lua +++ b/lua/neogen/snippet.lua @@ -13,6 +13,7 @@ local conf = require("neogen.config").get() --- - `"luasnip"` (https://github.com/L3MON4D3/LuaSnip) --- - `"snippy"` (https://github.com/dcampos/nvim-snippy) --- - `"vsnip"` (https://github.com/hrsh7th/vim-vsnip) +--- - `"nvim"` (`:h vim.snippet`) --- --- If you want to customize the placeholders, you can use `placeholders_text` option: --- > @@ -130,4 +131,16 @@ snippet.engines.vsnip = function(snip, pos) vim.fn["vsnip#anonymous"](snip) end +--- Expand snippet for vim.snippet engine +---@param snip string the snippet to expand +---@param pos table a tuple of row, col +---@private +snippet.engines.nvim = function(snip, pos) + local row, _ = unpack(pos) + vim.api.nvim_buf_set_lines(0, row, row, true, { "" }) + vim.api.nvim_win_set_cursor(0, { row + 1, 0 }) + snip = table.concat(snip, "\n") + vim.snippet.expand(snip) +end + return snippet