55 lines
1.3 KiB
Lua
55 lines
1.3 KiB
Lua
require('formatter').setup({
|
|
logging = false,
|
|
filetype = {
|
|
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
|
|
},
|
|
rust = {
|
|
-- Rustfmt
|
|
function()
|
|
return {
|
|
exe = "rustfmt",
|
|
args = {"--emit=stdout"},
|
|
stdin = true
|
|
}
|
|
end
|
|
},
|
|
lua = {
|
|
-- luafmt
|
|
function()
|
|
return {
|
|
exe = "luafmt",
|
|
args = {"--indent-count", 2, "--stdin"},
|
|
stdin = true
|
|
}
|
|
end
|
|
},
|
|
}
|
|
})
|
|
|
|
vim.api.nvim_exec([[
|
|
augroup FormatAutogroup
|
|
autocmd!
|
|
autocmd BufWritePost *.svelte,*.js,*.rs,*.lua FormatWrite
|
|
augroup END
|
|
]], true)
|