chore: Auto install formatter and auto format luau with StyLua
This commit is contained in:
parent
57216b2013
commit
0ebbbee7f8
2 changed files with 29 additions and 0 deletions
|
@ -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,
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue