mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-02 05:24:35 +02:00
refactor: move 0.9 stuff to a compat layer. Cleaner this way
This commit is contained in:
parent
595069d501
commit
8024201e75
5 changed files with 61 additions and 48 deletions
|
@ -95,48 +95,46 @@ return {
|
||||||
},
|
},
|
||||||
|
|
||||||
-- snippets
|
-- snippets
|
||||||
vim.fn.has("nvim-0.10") == 1
|
{
|
||||||
and {
|
"nvim-cmp",
|
||||||
"nvim-cmp",
|
dependencies = {
|
||||||
dependencies = {
|
{
|
||||||
{
|
"garymjr/nvim-snippets",
|
||||||
"garymjr/nvim-snippets",
|
opts = {
|
||||||
opts = {
|
friendly_snippets = true,
|
||||||
friendly_snippets = true,
|
|
||||||
},
|
|
||||||
dependencies = { "rafamadriz/friendly-snippets" },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
opts = function(_, opts)
|
dependencies = { "rafamadriz/friendly-snippets" },
|
||||||
opts.snippet = {
|
},
|
||||||
expand = function(item)
|
},
|
||||||
return LazyVim.cmp.expand(item.body)
|
opts = function(_, opts)
|
||||||
end,
|
opts.snippet = {
|
||||||
}
|
expand = function(item)
|
||||||
table.insert(opts.sources, { name = "snippets" })
|
return LazyVim.cmp.expand(item.body)
|
||||||
end,
|
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
|
-- auto pairs
|
||||||
{
|
{
|
||||||
|
@ -168,11 +166,6 @@ return {
|
||||||
"folke/ts-comments.nvim",
|
"folke/ts-comments.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = {},
|
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
|
-- Better text-objects
|
||||||
|
|
8
lua/lazyvim/plugins/compat/nvim-0_9.lua
Normal file
8
lua/lazyvim/plugins/compat/nvim-0_9.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
return {
|
||||||
|
{ import = "lazyvim.plugins.extras.coding.luasnip" },
|
||||||
|
{
|
||||||
|
"folke/ts-comments.nvim",
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
{ import = "lazyvim.plugins.extras.coding.mini-comment" },
|
||||||
|
}
|
|
@ -75,7 +75,7 @@ return {
|
||||||
-- mason = false, -- set to false if you don't want this server to be installed with mason
|
-- mason = false, -- set to false if you don't want this server to be installed with mason
|
||||||
-- Use this to add any additional keymaps
|
-- Use this to add any additional keymaps
|
||||||
-- for specific lsp servers
|
-- for specific lsp servers
|
||||||
---@type LazyKeysSpec[]
|
-- ---@type LazyKeysSpec[]
|
||||||
-- keys = {},
|
-- keys = {},
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
|
|
|
@ -12,9 +12,18 @@ local prios = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type string[]
|
---@type string[]
|
||||||
Config.json.data.extras = LazyVim.dedup(Config.json.data.extras)
|
local extras = LazyVim.dedup(Config.json.data.extras)
|
||||||
|
|
||||||
table.sort(Config.json.data.extras, function(a, b)
|
local version = vim.version()
|
||||||
|
local v = version.major .. "_" .. version.minor
|
||||||
|
|
||||||
|
local compat = { "0_9" }
|
||||||
|
|
||||||
|
if vim.tbl_contains(compat, v) then
|
||||||
|
extras[#extras + 1] = "lazyvim.plugins.compat.nvim-" .. v
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(extras, function(a, b)
|
||||||
local pa = prios[a] or 10
|
local pa = prios[a] or 10
|
||||||
local pb = prios[b] or 10
|
local pb = prios[b] or 10
|
||||||
if pa == pb then
|
if pa == pb then
|
||||||
|
@ -26,4 +35,4 @@ end)
|
||||||
---@param extra string
|
---@param extra string
|
||||||
return vim.tbl_map(function(extra)
|
return vim.tbl_map(function(extra)
|
||||||
return { import = extra }
|
return { import = extra }
|
||||||
end, Config.json.data.extras)
|
end, extras)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
---@meta
|
||||||
|
|
||||||
---@class LazyVimGlobals
|
---@class LazyVimGlobals
|
||||||
vim.g = {}
|
vim.g = {}
|
||||||
|
|
||||||
_G.lazyvim_docs = true
|
_G.lazyvim_docs = true
|
||||||
|
_G.LazyVim = require("lazyvim.util")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue