diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index d143852f..a3c91c3d 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -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 = { - { - "", - function() - return vim.snippet.active({ direction = 1 }) and "lua vim.snippet.jump(1)" or "" - end, - expr = true, - silent = true, - mode = { "i", "s" }, - }, - { - "", - function() - return vim.snippet.active({ direction = -1 }) and "lua vim.snippet.jump(-1)" or "" - 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 = { + { + "", + function() + return vim.snippet.active({ direction = 1 }) and "lua vim.snippet.jump(1)" or "" + end, + expr = true, + silent = true, + mode = { "i", "s" }, + }, + { + "", + function() + return vim.snippet.active({ direction = -1 }) and "lua vim.snippet.jump(-1)" or "" + 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 diff --git a/lua/lazyvim/plugins/compat/nvim-0_9.lua b/lua/lazyvim/plugins/compat/nvim-0_9.lua new file mode 100644 index 00000000..2962c97c --- /dev/null +++ b/lua/lazyvim/plugins/compat/nvim-0_9.lua @@ -0,0 +1,8 @@ +return { + { import = "lazyvim.plugins.extras.coding.luasnip" }, + { + "folke/ts-comments.nvim", + enabled = false, + }, + { import = "lazyvim.plugins.extras.coding.mini-comment" }, +} diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index ac84b743..207fd7fa 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -75,7 +75,7 @@ return { -- mason = false, -- set to false if you don't want this server to be installed with mason -- Use this to add any additional keymaps -- for specific lsp servers - ---@type LazyKeysSpec[] + -- ---@type LazyKeysSpec[] -- keys = {}, settings = { Lua = { diff --git a/lua/lazyvim/plugins/xtras.lua b/lua/lazyvim/plugins/xtras.lua index 87b11fb7..8b4b2ec9 100644 --- a/lua/lazyvim/plugins/xtras.lua +++ b/lua/lazyvim/plugins/xtras.lua @@ -12,9 +12,18 @@ local prios = { } ---@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 pb = prios[b] or 10 if pa == pb then @@ -26,4 +35,4 @@ end) ---@param extra string return vim.tbl_map(function(extra) return { import = extra } -end, Config.json.data.extras) +end, extras) diff --git a/lua/lazyvim/types.lua b/lua/lazyvim/types.lua index 73a5fe7b..52a340c9 100644 --- a/lua/lazyvim/types.lua +++ b/lua/lazyvim/types.lua @@ -1,4 +1,7 @@ +---@meta + ---@class LazyVimGlobals vim.g = {} _G.lazyvim_docs = true +_G.LazyVim = require("lazyvim.util")