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

@ -9,6 +9,7 @@
"lualine.nvim": { "branch": "master", "commit": "0c6cca9f2c63dadeb9225c45bc92bb95a151d4af" },
"luau-lsp.nvim": { "branch": "main", "commit": "f81c6c713e4598abc484cbeabca918475d176c54" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "87888865fa1ce1928a25b9abbea8c8f7839bf522" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" },
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" },
"nui.nvim": { "branch": "main", "commit": "7cd18e73cfbd70e1546931b7268b3eebaeff9391" },

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,
},
{