Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit b774408

Browse files
committed
feat: integration with vsnip
feat: integration with vsnip
1 parent 69a8da6 commit b774408

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,20 @@ inoremap <silent><expr> <TAB>
101101
- By default other snippets source support are disabled, turn them on by
102102

103103
```vim
104+
" possible value: 'UltiSnips', 'Neosnippet'
104105
let g:completion_enable_snippet = 'UltiSnips'
105106
```
106107
- Support `UltiSnips` and `Neosnippet`
107108

109+
### LSP Based Snippet parsing
110+
111+
- Some language server have snippet support but neovim couldn't handle that for now, `completion-nvim` can integrate
112+
with other LSP snippet parsing plugin for this support.
113+
114+
- Right now only support `vim-vsnip`(require `vim-vsnip-integ`), it should
115+
work out of the box if you have ![vim-vsnip](https://github.com/hrsh7th/vim-vsnip) and
116+
![vim-vsnip-integ](https://github.com/hrsh7th/vim-vsnip-integ) installed.
117+
108118
### Chain Completion Support
109119

110120
- completion-nvim supports chain completion, which use other completion sources

lua/completion.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ local api = vim.api
33
local source = require 'source'
44
local signature = require'completion.signature_help'
55
local hover = require'completion.hover'
6-
if vim.env.SNIPPETS then
7-
vim.snippet = require 'snippet'
8-
end
96
local M = {}
107

118
------------------------------------------------------------------------
@@ -65,14 +62,15 @@ function M.confirmCompletion()
6562
)
6663
vim.lsp.util.apply_text_edits(edits, bufnr)
6764
end
65+
if vim.fn.exists('g:loaded_vsnip_integ') then
66+
api.nvim_call_function('vsnip_integ#on_complete_done_for_lsp',
67+
{ { completed_item = complete_item, completion_item = item } })
68+
end
6869
end
6970

7071
if vim.g.completion_enable_auto_paren == 1 then
7172
M.autoAddParens(complete_item)
7273
end
73-
if complete_item.kind == 'Snippet' and vim.snippet ~= nil then
74-
vim.snippet.expand_at_cursor(complete_item.word)
75-
end
7674
if complete_item.kind == 'UltiSnips' then
7775
api.nvim_call_function('UltiSnips#ExpandSnippet', {})
7876
elseif complete_item.kind == 'Neosnippet' then

lua/completion/util.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function M.text_document_completion_list_to_complete_items(result, prefix, score
5353

5454
for _, completion_item in ipairs(items) do
5555
-- skip snippets items if snippet source are enabled
56-
if vim.g.completion_enable_snippet == nil or
56+
if vim.fn.exists('g:loaded_vsnip_integ') or
5757
protocol.CompletionItemKind[completion_item.kind] ~= 'Snippet' then
5858
local info = ' '
5959
local documentation = completion_item.documentation

0 commit comments

Comments
 (0)