Explorar o código

check if group exists before removing

Chris %!s(int64=4) %!d(string=hai) anos
pai
achega
2a16537216
Modificáronse 1 ficheiros con 15 adicións e 9 borrados
  1. 15 9
      lua/lv-neoformat/init.lua

+ 15 - 9
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