1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-15 08:09:11 +08:00

feat(snippet): add bundle cmp-neosnippet

This commit is contained in:
wsdjeg 2022-04-13 11:16:04 +08:00
parent 207aa46f1d
commit 52ad8ca22a
6 changed files with 74 additions and 0 deletions

View File

@ -102,6 +102,11 @@ function! SpaceVim#layers#autocomplete#plugins() abort
\ 'merged' : 0,
\ 'loadconf' : 1,
\ }])
if g:spacevim_snippet_engine ==# 'neocomplete'
call add(plugins, [g:_spacevim_root_dir . 'bundle/cmp-neosnippet', {
\ 'merged' : 0,
\ }])
endif
elseif g:spacevim_autocomplete_method ==# 'asyncomplete'
call add(plugins, ['prabirshrestha/asyncomplete.vim', {
\ 'loadconf' : 1,

View File

@ -20,3 +20,4 @@ In `bundle/` directory, there are two kinds of plugins: forked plugins without c
- [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/tree/507f8a570ac2b8b8dabdd0f62da3b3194bf822f8)
- [deoplete-lsp](https://github.com/deoplete-plugins/deoplete-lsp/tree/6299a22bedfb4f814d95cb0010291501472f8fd0)
- [nvim-cmp](https://github.com/hrsh7th/nvim-cmp/tree/3192a0c57837c1ec5bf298e4f3ec984c7d2d60c0)
- [coc-neosnippet](https://github.com/notomo/cmp-neosnippet/tree/2d14526af3f02dcea738b4cea520e6ce55c09979)

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 notomo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,16 @@
# cmp-neosnippet
nvim-cmp source for neosnippet.
# Setup
```lua
require("cmp").setup({
snippet = {
expand = function(_)
-- unused
end,
},
sources = {{name = "neosnippet"}},
})
```

View File

@ -0,0 +1 @@
require("cmp").register_source("neosnippet", require("cmp_neosnippet").Source.new())

View File

@ -0,0 +1,30 @@
local kind = require("cmp").lsp.CompletionItemKind.Snippet
local fn = vim.fn
local M = {}
local Source = {}
M.Source = Source
function Source.new()
return setmetatable({}, { __index = Source })
end
function Source:is_available()
return vim.g.loaded_neosnippet
end
function Source:get_debug_name()
return "neosnippet"
end
function Source:complete(_, callback)
-- not impl cache for filetype
local snippets = fn["neosnippet#helpers#get_completion_snippets"]()
local items = vim.tbl_map(function(s)
return { label = s.word, kind = kind }
end, snippets)
callback(items)
end
return M