formatting configs

This commit is contained in:
Christoph J. Scherr 2023-10-01 16:46:42 +02:00
parent dac783e403
commit c66b3f00bd
1 changed files with 21 additions and 2 deletions

View File

@ -1,6 +1,9 @@
-- This is part of LazyVim's code, with my modifications.
-- See: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/formatting/prettier.lua
local util = require("formatter.util")
local defaults = require("formatter.defaults")
return {
{
@ -21,8 +24,6 @@ return {
opts = function(_, opts)
opts = opts or {}
local filetypes = {
-- FIXME:add more filetypes
json = { require("formatter.defaults.prettierd") },
rust = {
rustfmt = function()
return {
@ -32,10 +33,28 @@ return {
}
end,
},
cpp = { require("formatter.filetypes.cpp").clangformat },
css = { require("formatter.filetypes.css").prettierd },
html = { require("formatter.filetypes.html").prettierd },
java = { require("formatter.filetypes.java").clangformat() },
javascript = { require("formatter.filetypes.javascript").prettierd },
json = { require("formatter.filetypes.json").prettierd },
cmake = { require("formatter.filetypes.cmake") },
latex = { require("formatter.filetypes.latex").latexindent },
markdown = { require("formatter.filetypes.markdown").prettierd },
php = { require("formatter.filetypes.php").phpcbf },
python = { require("formatter.filetypes.python").autopep8() },
sh = { require("formatter.filetypes.sh").shfmt() },
sql = { require("formatter.filetypes.sql").pgformat() },
toml = { require("formatter.filetypes.toml").taplo() },
go = { require("formatter.filetypes.go").gofmt() },
yaml = { require("formatter.filetypes.yaml").prettierd },
c = { require("formatter.filetypes.c").clangformat },
["*"] = {
-- "formatter.filetypes.any" defines default configurations for any
-- filetype
require("formatter.filetypes.any").remove_trailing_whitespace,
require("formatter.defaults.prettierd")
},
}
opts.filetype = vim.tbl_extend("keep", opts.filetype or {}, filetypes)