瀏覽代碼

check if group exists before removing

Chris 4 年之前
父節點
當前提交
2a16537216
共有 1 個文件被更改,包括 15 次插入9 次删除
  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