nvim/autocmd: remove polyfill for <0.7 versions

This needlessly complicates the code, and is no longer needed, as nvim
0.7 is fairly common now.
This commit is contained in:
Paul Stemmet 2022-10-01 16:11:19 +00:00
parent ee4fac3834
commit a4410d681f
Signed by: Paul Stemmet
GPG Key ID: EDEA539F594E7E75
2 changed files with 3 additions and 34 deletions

View File

@ -4,15 +4,13 @@ local Groups = {}
local Group = { mt = {} }
local AutoCmd = { mt = {} }
local __builtin_support = vim.fn.has('nvim-0.7') == 1
-- Use the recent builtin APIs provided by neovim itself
local function builtin(group, autos)
vim.api.nvim_create_augroup(group, {})
local gid = vim.api.nvim_create_augroup(group, { clear = true })
for _, auto in ipairs(autos) do
local opts = auto.opts or {}
opts.group = group
opts.group = gid
opts.pattern = auto.pattern
if type(auto.command) == "string" then
@ -25,31 +23,7 @@ local function builtin(group, autos)
end
end
-- Use an old library to make the autos
-- Note that relies on the local package manager to ensure this plugin is available
local function polyfill(group, autos)
local poly = require 'autocmd-lua'
local autocmds = {}
for _, auto in ipairs(autos) do
local events = auto.event
if type(auto.event) == "string" then
events = { auto.event }
end
for _, e in ipairs(events) do
table.insert(autocmds, { event = e, pattern = auto.pattern, cmd = auto.command })
end
end
poly.augroup {
group = group,
autocmds = autocmds,
}
end
local autocmd = __builtin_support and builtin or polyfill
local autocmd = builtin
function M.new()
local m = {}

View File

@ -18,11 +18,6 @@ local plugins = {
as = 'vimp'
},
-- Used for autocmds if we're not using a late enough version of neovim
{ 'jakelinnzy/autocmd-lua',
disable = vim.fn.has('nvim-0.7') == 1
},
-- Text alignment
{ 'junegunn/vim-easy-align' },
{ 'tmsvg/pear-tree',