Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abeldekat/cmp-mini-snippets
mini.snippets completion source for nvim-cmp
https://github.com/abeldekat/cmp-mini-snippets
lua mini-nvim neovim nvim-cmp
Last synced: 19 days ago
JSON representation
mini.snippets completion source for nvim-cmp
- Host: GitHub
- URL: https://github.com/abeldekat/cmp-mini-snippets
- Owner: abeldekat
- License: mit
- Created: 2024-12-31T08:22:17.000Z (20 days ago)
- Default Branch: main
- Last Pushed: 2024-12-31T10:03:52.000Z (20 days ago)
- Last Synced: 2024-12-31T11:18:26.129Z (20 days ago)
- Topics: lua, mini-nvim, neovim, nvim-cmp
- Language: Lua
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmp_mini_snippets
This plugin is a completion source for [nvim-cmp],
providing the snippets produced by [mini.snippets].[mini.snippets] is a plugin to manage and expand snippets.
Currently, [mini.snippets] is in [beta].
## Installation
mini.deps
```lua
local add, later = MiniDeps.add, MiniDeps.laterlater(function()
add({ -- Do read the installation section in the readme of mini.snippets!
source = "echasnovski/mini.snippets",
depends = { "rafamadriz/friendly-snippets" }
})
local snippets = require("mini.snippets")
-- :h MiniSnippets-examples:
snippets.setup({ snippets = { snippets.gen_loader.from_lang() }})add({ -- Do read the installation section in the readme of nvim-cmp!
source = "hrsh7th/nvim-cmp",
depends = { "abeldekat/cmp-mini-snippets" }, -- this plugin
})
local cmp = require("cmp")
require'cmp'.setup({
snippet = {
expand = function(args) -- mini.snippets expands snippets from lsp...
---@diagnostic disable-next-line: undefined-global
local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert
insert({ body = args.body }) -- Insert at cursor
end,
},
sources = cmp.config.sources({ { name = "mini_snippets" } }),
mapping = cmp.mapping.preset.insert(), -- more opts...
})
end)
```lazy.nvim
```lua
return {
{ -- Do read the installation section in the readme of mini.snippets!
"echasnovski/mini.snippets",
dependencies = "rafamadriz/friendly-snippets",
-- :h MiniSnippets-examples:
opts = function()
local snippets = require("mini.snippets")
return { snippets = { snippets.gen_loader.from_lang() }}
end,
},{ -- Do read the installation section in the readme of nvim-cmp!
"hrsh7th/nvim-cmp",
main = "cmp",
dependencies = { "abeldekat/cmp-mini-snippets" }, -- this plugin
event = "InsertEnter",
opts = function()
local cmp = require("cmp")
return {
snippet = {
expand = function(args) -- mini.snippets expands snippets from lsp...
---@diagnostic disable-next-line: undefined-global
local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert
insert({ body = args.body }) -- Insert at cursor
end,
},
sources = cmp.config.sources({ { name = "mini_snippets" } }),
mapping = cmp.mapping.preset.insert(), -- more opts...
}
end,
},
}
```## LazyVim and mini.snippets
See this [LazyVim-PR] proposal for a mini.snippets "extra"...
## Acknowledgments
- [cmp_luasnip] by @saadparwaiz1 (especially for function `get_documentation`)
- [nvim-cmp] and sources by @hrsh7th
- [mini.snippets] by @echasnovski[mini.snippets]: https://github.com/echasnovski/mini.snippets
[nvim-cmp]: https://github.com/hrsh7th/nvim-cmp
[cmp_luasnip]: https://github.com/saadparwaiz1/cmp_luasnip
[LazyVim-PR]: https://github.com/LazyVim/LazyVim/pull/5274
[beta]: https://github.com/echasnovski/mini.nvim/issues/1428