From 2a16537216ffbf30759d01cd8ca70f606aed3a47 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 7 Jul 2021 11:44:10 -0400 Subject: check if group exists before removing --- lua/lv-neoformat/init.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'lua') diff --git a/lua/lv-neoformat/init.lua b/lua/lv-neoformat/init.lua index 4f3bab60..ea3ff43c 100644 --- a/lua/lv-neoformat/init.lua +++ b/lua/lv-neoformat/init.lua @@ -1,12 +1,18 @@ -- autoformat if O.format_on_save then - require("lv-utils").define_augroups { - autoformat = { - { - "BufWritePre", - "*", - [[try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry]], - }, - }, - } + require("lv-utils").define_augroups({ + autoformat = { + { + "BufWritePre", + "*", + [[try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry]], + }, + }, + }) +end + +if not O.format_on_save then + vim.cmd([[if exists('#autoformat#BufWritePre') + :autocmd! autoformat + endif]]) end -- cgit v1.2.3