replace luasnip with vsnip

This commit is contained in:
Dietrich Rink
2023-06-10 15:18:53 +02:00
parent 06d8ff3713
commit bd11cd4ed2
9 changed files with 38 additions and 64 deletions

View File

@@ -11,9 +11,9 @@ RUN printf '%s\n' \
christoomey/vim-tmux-navigator benmills/vimux ap/vim-buftabline \
nvim-tree/nvim-tree.lua nvim-tree/nvim-web-devicons ctrlpvim/ctrlp.vim \
hrsh7th/nvim-cmp ray-x/lsp_signature.nvim hrsh7th/cmp-buffer \
hrsh7th/cmp-nvim-lsp neovim/nvim-lspconfig saadparwaiz1/cmp_luasnip \
L3MON4D3/LuaSnip jiangmiao/auto-pairs tpope/vim-surround tpope/vim-repeat \
hrsh7th/cmp-path hrsh7th/cmp-nvim-lua \
hrsh7th/cmp-path hrsh7th/cmp-nvim-lua hrsh7th/cmp-nvim-lsp \
neovim/nvim-lspconfig hrsh7th/vim-vsnip hrsh7th/cmp-vsnip \
jiangmiao/auto-pairs tpope/vim-surround tpope/vim-repeat \
rebelot/kanagawa.nvim \
| xargs -n1 -P0 -I'{}' git clone --depth 1 'https://github.com/{}'
RUN printf 'helptags %s\n' */doc | nvim --noplugin -es

View File

@@ -11,15 +11,15 @@ pack 'ctrlp.vim'
-- Language servers and snippets
pack 'nvim-lspconfig'
pack 'LuaSnip'
pack 'lsp_signature.nvim'
pack 'vim-vsnip'
-- Completion
pack 'cmp-buffer'
pack 'cmp-path'
pack 'cmp-nvim-lua'
pack 'cmp-nvim-lsp'
pack 'cmp_luasnip'
pack 'cmp-vsnip'
pack 'nvim-cmp'
-- Editing

View File

@@ -1,25 +0,0 @@
return {
parse(
{ trig = 'lorem', name = 'Lorem ipsum sentence' },
table.concat({
'Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint',
'cillum sint consectetur cupidatat.',
}, " ")
),
parse(
{ trig = 'loremipsum', name = "Lorem ipsum paragraph" },
table.concat({
'Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit',
'enim labore culpa sint ad nisi Lorem pariatur mollit ex esse',
'exercitation amet. Nisi anim cupidatat excepteur officia.',
'Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate',
'voluptate dolor minim nulla est proident. Nostrud officia pariatur ut',
'officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit',
'commodo officia dolor Lorem duis laboris cupidatat officia voluptate.',
'Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis',
'officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis',
'sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea',
'consectetur et est culpa et culpa duis.',
}, ' ')
),
}

View File

@@ -1,13 +0,0 @@
local luasnip = require 'luasnip'
local loader = require 'luasnip.loaders.from_lua'
luasnip.setup {
-- Enable live updates
update_events = { 'TextChanged', 'TextChangedI' },
-- Stop jumping when deleted
delete_check_events = { 'TextChanged' },
}
-- Automatically load lua snippets
loader.lazy_load()

View File

@@ -1,13 +1,18 @@
local cmp = require 'cmp'
local context = require 'cmp.config.context'
local luasnip = require 'luasnip'
vim.o.completeopt = nil
-- Plugin helper
local feedkey = function(key, mode)
key = vim.api.nvim_replace_termcodes(key, true, true, true)
vim.api.nvim_feedkeys(key, mode, true)
end
-- General setup
cmp.setup {
snippet = {
expand = function(args) luasnip.lsp_expand(args.body) end,
expand = function(args) vim.fn['vsnip#anonymous'](args.body) end,
},
window = {
documentation = { border = 'rounded' },
@@ -17,7 +22,7 @@ cmp.setup {
format = function(entry, item)
item.menu = ({
nvim_lsp = 'λ',
luasnip = '',
vsnip = '',
buffer = 'Ω',
path = '🖫',
})[entry.source.name]
@@ -30,10 +35,10 @@ cmp.setup {
['<tab>'] = cmp.mapping(function(fallback)
if cmp.get_selected_entry() then
cmp.confirm()
elseif luasnip.jumpable(1) then
luasnip.jump(1)
elseif luasnip.expandable() then
luasnip.expand()
elseif vim.fn['vsnip#jumpable'](1) == 1 then
feedkey('<plug>(vsnip-jump-next)', '')
elseif vim.fn['vsnip#expandable']() == 1 then
feedkey('<plug>(vsnip-expand)', '')
elseif cmp.visible() then
cmp.select_next_item()
else
@@ -42,8 +47,8 @@ cmp.setup {
end, { 'i', 's' }),
-- Jump back with shift tab
['<s-tab>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
if vim.fn['vsnip#jumpable'](-1) == 1 then
feedkey('<plug>(vsnip-jump-prev)', '')
else
fallback()
end
@@ -57,12 +62,16 @@ cmp.setup {
end
end),
['<c-p>'] = cmp.mapping(function(fallback)
if cmp.visible() then cmp.select_prev_item() else fallback() end
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'vsnip' },
{ name = 'nvim_lua' },
}, {
{ name = 'buffer', keyword_length = 5 },

View File

@@ -0,0 +1,3 @@
vim.g.vsnip_snippet_dir = '/etc/xdg/nvim/snippets'
vim.g.vsnip_deactivate_on = 2

View File

@@ -0,0 +1,4 @@
snippet lorem
Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.
snippet loremipsum
Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet. Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate voluptate dolor minim nulla est proident. Nostrud officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit commodo officia dolor Lorem duis laboris cupidatat officia voluptate. Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea consectetur et est culpa et culpa duis.