chore: Auto install formatter and auto format luau with StyLua

This commit is contained in:
Ahmad Ansori Palembani 2025-06-12 18:32:50 +07:00
parent 57216b2013
commit 0ebbbee7f8
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 29 additions and 0 deletions

View file

@ -45,6 +45,24 @@ return {
require("mason-lspconfig").setup(opts)
end,
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
lazy = true,
dependencies = {
"mason-org/mason.nvim",
},
opts = {
ensure_installed = {
-- >> Lua(u)
"stylua",
"selene",
-- << Lua(u)
},
},
config = function(_, opts)
require("mason-tool-installer").setup(opts)
end,
},
{
"lopi-py/luau-lsp.nvim",
lazy = true,
@ -226,6 +244,16 @@ return {
-- vim.diagnostic.disable()
end,
})
local autoformat_group = vim.api.nvim_create_augroup("Auto format", { clear = true })
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
pattern = { "*.luau" },
desc = "Auto-format Luau files after saving",
callback = function()
local fileName = vim.api.nvim_buf_get_name(0)
vim.cmd(":silent !stylua " .. fileName)
end,
group = autoformat_group,
})
end,
},
{