Add support for nvim snippet engine (vim.snippet) (#164)
* doc: Add reference to `:h vim.snippet` * doc: Update docs --------- Co-authored-by: danymat <d.danymat@gmail.com>
This commit is contained in:
@@ -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)
|
--- 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~
|
--- ## 2.15.0~
|
||||||
--- - Google docstrings now include "Yields:", whenever possible
|
--- - Google docstrings now include "Yields:", whenever possible
|
||||||
--- ## 2.14.0~
|
--- ## 2.14.0~
|
||||||
@@ -299,7 +301,7 @@ end
|
|||||||
--- with multiple annotation conventions.
|
--- with multiple annotation conventions.
|
||||||
---@tag neogen-changelog
|
---@tag neogen-changelog
|
||||||
---@toc_entry Changes in neogen plugin
|
---@toc_entry Changes in neogen plugin
|
||||||
neogen.version = "2.15.3"
|
neogen.version = "2.16.0"
|
||||||
--minidoc_afterlines_end
|
--minidoc_afterlines_end
|
||||||
|
|
||||||
return neogen
|
return neogen
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ local conf = require("neogen.config").get()
|
|||||||
--- - `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
|
--- - `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
|
||||||
--- - `"snippy"` (https://github.com/dcampos/nvim-snippy)
|
--- - `"snippy"` (https://github.com/dcampos/nvim-snippy)
|
||||||
--- - `"vsnip"` (https://github.com/hrsh7th/vim-vsnip)
|
--- - `"vsnip"` (https://github.com/hrsh7th/vim-vsnip)
|
||||||
|
--- - `"nvim"` (`:h vim.snippet`)
|
||||||
---
|
---
|
||||||
--- 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:
|
||||||
--- >
|
--- >
|
||||||
@@ -130,4 +131,16 @@ snippet.engines.vsnip = function(snip, pos)
|
|||||||
vim.fn["vsnip#anonymous"](snip)
|
vim.fn["vsnip#anonymous"](snip)
|
||||||
end
|
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
|
return snippet
|
||||||
|
|||||||
Reference in New Issue
Block a user