mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-01 00:24:54 +02:00
you can now toggle format on and off on the fly!
This commit is contained in:
parent
52b4476509
commit
0c6771a385
3 changed files with 18 additions and 13 deletions
14
init.lua
14
init.lua
|
@ -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
|
||||
|
|
16
lua/lv-neoformat/init.lua
Normal file
16
lua/lv-neoformat/init.lua
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue