diff options
author | christianchiarulli <[email protected]> | 2021-07-06 22:55:11 -0400 |
---|---|---|
committer | christianchiarulli <[email protected]> | 2021-07-06 22:55:11 -0400 |
commit | 0c6771a385e3f2e4a9f1e5ae80eb7615e4fa99e0 (patch) | |
tree | 2761d81b58aaeb73870ba86b2edcf45c9eba2cfc | |
parent | 52b4476509a0eea70672289b02e21d2a84e66b17 (diff) |
you can now toggle format on and off on the fly!
-rw-r--r-- | init.lua | 14 | ||||
-rw-r--r-- | lua/lv-neoformat/init.lua | 16 | ||||
-rw-r--r-- | lua/lv-utils/init.lua | 1 |
3 files changed, 18 insertions, 13 deletions
@@ -7,6 +7,7 @@ require "lv-utils" require "lv-galaxyline" require "lv-treesitter" require "lv-which-key" +require "lv-neoformat" require "lsp" if O.lang.emmet.active then require "lsp.emmet-ls" @@ -14,16 +15,3 @@ end if O.lang.tailwindcss.active then require "lsp.tailwindcss-ls" end - --- 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]], - }, - }, - } -end diff --git a/lua/lv-neoformat/init.lua b/lua/lv-neoformat/init.lua new file mode 100644 index 00000000..a1540370 --- /dev/null +++ b/lua/lv-neoformat/init.lua @@ -0,0 +1,16 @@ +-- 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]], + }, + }, + } +end + +if not O.format_on_save then + vim.cmd ":autocmd! autoformat" +end diff --git a/lua/lv-utils/init.lua b/lua/lv-utils/init.lua index 656905f2..9caccd82 100644 --- a/lua/lv-utils/init.lua +++ b/lua/lv-utils/init.lua @@ -3,6 +3,7 @@ local lv_utils = {} function lv_utils.reload_lv_config() vim.cmd "source ~/.config/nvim/lv-config.lua" vim.cmd "source ~/.config/nvim/lua/plugins.lua" + vim.cmd "source ~/.config/nvim/lua/lv-neoformat/init.lua" vim.cmd ":PackerCompile" vim.cmd ":PackerInstall" end |