2021-08-12 13:12:30 +02:00
|
|
|
local u = require "utils"
|
|
|
|
|
|
|
|
-- Config Formatter
|
|
|
|
u.create_augroup(
|
|
|
|
{
|
2021-09-24 12:47:15 +02:00
|
|
|
--{"BufWritePost", "*.js,*.jsx,*.ts,*.tsx,*.rs,*.svelte", "OrganizeImports"},
|
2021-08-12 13:12:30 +02:00
|
|
|
{"BufWritePost", "*.js,*.jsx,*.ts,*.tsx,*.rs,*.lua", "FormatWrite"}
|
|
|
|
},
|
|
|
|
"FormatAutogroup"
|
|
|
|
)
|
|
|
|
|
|
|
|
require("formatter").setup(
|
|
|
|
{
|
|
|
|
logging = false,
|
|
|
|
filetype = {
|
|
|
|
typescript = {
|
|
|
|
-- prettier
|
|
|
|
function()
|
|
|
|
return {
|
|
|
|
exe = "prettier",
|
|
|
|
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote"},
|
|
|
|
stdin = true
|
|
|
|
}
|
|
|
|
end
|
|
|
|
},
|
|
|
|
javascript = {
|
|
|
|
-- prettier
|
|
|
|
function()
|
|
|
|
return {
|
|
|
|
exe = "prettier",
|
|
|
|
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote"},
|
|
|
|
stdin = true
|
|
|
|
}
|
|
|
|
end
|
|
|
|
},
|
|
|
|
svelte = {
|
|
|
|
-- prettier
|
|
|
|
function()
|
|
|
|
return {
|
|
|
|
exe = "prettier",
|
|
|
|
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote"},
|
|
|
|
stdin = true
|
|
|
|
}
|
|
|
|
end
|
|
|
|
},
|
|
|
|
lua = {
|
|
|
|
-- luafmt
|
|
|
|
function()
|
|
|
|
return {
|
|
|
|
exe = "luafmt",
|
|
|
|
args = {"--indent-count", 2, "--stdin"},
|
|
|
|
stdin = true
|
|
|
|
}
|
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|