new config using vim.pack
This commit is contained in:
parent
e685165044
commit
17fda33a90
52 changed files with 629 additions and 659 deletions
47
lua/plugins/formatter.lua
Normal file
47
lua/plugins/formatter.lua
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
---@module "utils.plugins"
|
||||
---@type Plugin
|
||||
return {
|
||||
after = "mason-bridge",
|
||||
configure = function(load)
|
||||
load("stevearc/conform.nvim")
|
||||
|
||||
require("conform").setup({
|
||||
formatters_by_ft = require("mason-bridge").get_formatters(),
|
||||
|
||||
format_on_save = function(bufnr)
|
||||
require("conform").formatters_by_ft = require("mason-bridge").get_formatters()
|
||||
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
else
|
||||
return { timeout_ms = 500, lsp_format = "fallback" }
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("FormatDisable", function(args)
|
||||
if args.bang then
|
||||
-- FormatDisable! will disable formatting globally
|
||||
vim.g.disable_autoformat = true
|
||||
else
|
||||
vim.b.disable_autoformat = true
|
||||
end
|
||||
end, {
|
||||
desc = "Disable autoformat-on-save",
|
||||
bang = true,
|
||||
})
|
||||
vim.api.nvim_create_user_command("FormatEnable", function(args)
|
||||
if args.bang then
|
||||
-- FormatDisable! will disable formatting globally
|
||||
vim.g.disable_autoformat = false
|
||||
else
|
||||
vim.b.disable_autoformat = false
|
||||
end
|
||||
end, {
|
||||
desc = "Enable autoformat-on-save",
|
||||
bang = true,
|
||||
})
|
||||
|
||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||||
end,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue