refactor: move 0.9 stuff to a compat layer. Cleaner this way

This commit is contained in:
Folke Lemaitre 2024-06-01 20:46:56 +02:00
parent 595069d501
commit 8024201e75
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
5 changed files with 61 additions and 48 deletions

View file

@ -95,48 +95,46 @@ return {
},
-- snippets
vim.fn.has("nvim-0.10") == 1
and {
"nvim-cmp",
dependencies = {
{
"garymjr/nvim-snippets",
opts = {
friendly_snippets = true,
},
dependencies = { "rafamadriz/friendly-snippets" },
},
{
"nvim-cmp",
dependencies = {
{
"garymjr/nvim-snippets",
opts = {
friendly_snippets = true,
},
opts = function(_, opts)
opts.snippet = {
expand = function(item)
return LazyVim.cmp.expand(item.body)
end,
}
table.insert(opts.sources, { name = "snippets" })
dependencies = { "rafamadriz/friendly-snippets" },
},
},
opts = function(_, opts)
opts.snippet = {
expand = function(item)
return LazyVim.cmp.expand(item.body)
end,
keys = {
{
"<Tab>",
function()
return vim.snippet.active({ direction = 1 }) and "<cmd>lua vim.snippet.jump(1)<cr>" or "<Tab>"
end,
expr = true,
silent = true,
mode = { "i", "s" },
},
{
"<S-Tab>",
function()
return vim.snippet.active({ direction = -1 }) and "<cmd>lua vim.snippet.jump(-1)<cr>" or "<Tab>"
end,
expr = true,
silent = true,
mode = { "i", "s" },
},
},
}
or { import = "lazyvim.plugins.extras.coding.luasnip", enabled = vim.fn.has("nvim-0.10") == 0 },
table.insert(opts.sources, { name = "snippets" })
end,
keys = {
{
"<Tab>",
function()
return vim.snippet.active({ direction = 1 }) and "<cmd>lua vim.snippet.jump(1)<cr>" or "<Tab>"
end,
expr = true,
silent = true,
mode = { "i", "s" },
},
{
"<S-Tab>",
function()
return vim.snippet.active({ direction = -1 }) and "<cmd>lua vim.snippet.jump(-1)<cr>" or "<Tab>"
end,
expr = true,
silent = true,
mode = { "i", "s" },
},
},
},
-- auto pairs
{
@ -168,11 +166,6 @@ return {
"folke/ts-comments.nvim",
event = "VeryLazy",
opts = {},
enabled = vim.fn.has("nvim-0.10") == 1,
},
{
import = "lazyvim.plugins.extras.coding.mini-comment",
enabled = vim.fn.has("nvim-0.10") == 0,
},
-- Better text-objects