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

View File

@@ -11,15 +11,15 @@ pack 'ctrlp.vim'
-- Language servers and snippets -- Language servers and snippets
pack 'nvim-lspconfig' pack 'nvim-lspconfig'
pack 'LuaSnip'
pack 'lsp_signature.nvim' pack 'lsp_signature.nvim'
pack 'vim-vsnip'
-- Completion -- Completion
pack 'cmp-buffer' pack 'cmp-buffer'
pack 'cmp-path' pack 'cmp-path'
pack 'cmp-nvim-lua' pack 'cmp-nvim-lua'
pack 'cmp-nvim-lsp' pack 'cmp-nvim-lsp'
pack 'cmp_luasnip' pack 'cmp-vsnip'
pack 'nvim-cmp' pack 'nvim-cmp'
-- Editing -- 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 cmp = require 'cmp'
local context = require 'cmp.config.context' local context = require 'cmp.config.context'
local luasnip = require 'luasnip'
vim.o.completeopt = nil 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 -- General setup
cmp.setup { cmp.setup {
snippet = { snippet = {
expand = function(args) luasnip.lsp_expand(args.body) end, expand = function(args) vim.fn['vsnip#anonymous'](args.body) end,
}, },
window = { window = {
documentation = { border = 'rounded' }, documentation = { border = 'rounded' },
@@ -17,7 +22,7 @@ cmp.setup {
format = function(entry, item) format = function(entry, item)
item.menu = ({ item.menu = ({
nvim_lsp = 'λ', nvim_lsp = 'λ',
luasnip = '', vsnip = '',
buffer = 'Ω', buffer = 'Ω',
path = '🖫', path = '🖫',
})[entry.source.name] })[entry.source.name]
@@ -30,10 +35,10 @@ cmp.setup {
['<tab>'] = cmp.mapping(function(fallback) ['<tab>'] = cmp.mapping(function(fallback)
if cmp.get_selected_entry() then if cmp.get_selected_entry() then
cmp.confirm() cmp.confirm()
elseif luasnip.jumpable(1) then elseif vim.fn['vsnip#jumpable'](1) == 1 then
luasnip.jump(1) feedkey('<plug>(vsnip-jump-next)', '')
elseif luasnip.expandable() then elseif vim.fn['vsnip#expandable']() == 1 then
luasnip.expand() feedkey('<plug>(vsnip-expand)', '')
elseif cmp.visible() then elseif cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
else else
@@ -42,8 +47,8 @@ cmp.setup {
end, { 'i', 's' }), end, { 'i', 's' }),
-- Jump back with shift tab -- Jump back with shift tab
['<s-tab>'] = cmp.mapping(function(fallback) ['<s-tab>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then if vim.fn['vsnip#jumpable'](-1) == 1 then
luasnip.jump(-1) feedkey('<plug>(vsnip-jump-prev)', '')
else else
fallback() fallback()
end end
@@ -57,12 +62,16 @@ cmp.setup {
end end
end), end),
['<c-p>'] = cmp.mapping(function(fallback) ['<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), end),
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
{ name = 'luasnip' }, { name = 'vsnip' },
{ name = 'nvim_lua' }, { name = 'nvim_lua' },
}, { }, {
{ name = 'buffer', keyword_length = 5 }, { 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.

View File

@@ -1,10 +0,0 @@
return {
parse(
{ trig = 'func', name = 'Function' },
'func ${1:name}($2) $3{\n\t$4\n}'
),
parse(
{ trig = 'err', name = 'Handle error' },
'if ${2:err} != nil { return ${1}${2} }'
),
}

View File

@@ -0,0 +1,6 @@
snippet func
func ${1:name}(${2}) ${3}{
${0}
}
snippet err
if ${2:err} != nil { return ${1}${2} }