formatting top

This commit is contained in:
Christoph J. Scherr 2023-10-01 22:41:11 +02:00
parent 479b600626
commit 5ad5c9aea4
2 changed files with 32 additions and 14 deletions

View File

@ -24,6 +24,15 @@ return {
opts = function(_, opts)
opts = opts or {}
local filetypes = {
-- NOTE: If using this config, you need to install prettierd.
-- At the time of writing that is done with:
-- `sudo npm install -g @fsouza/prettierd`
["*"] = {
-- NOTE: This is not a fallback! It seems to overwrite any other
-- configs.
require("formatter.filetypes.any").remove_trailing_whitespace,
},
text = { require("formatter.defaults.prettierd") },
rust = {
rustfmt = function()
return {
@ -33,19 +42,14 @@ return {
}
end,
},
-- NOTE: If using this config, you need to install prettierd.
-- At the time of writing that is done with:
-- `sudo npm install -g @fsouza/prettierd`
cpp = { require("formatter.filetypes.cpp").clangformat },
css = { require("formatter.filetypes.css").prettierd },
-- NOTE: If you don't care about django templates,
-- you can use one of the formatters provided by default.
-- html = { require("formatter.filetypes.html").prettierd },
html = {
html = { require("formatter.filetypes.html").prettierd },
htmldjango = {
function()
return {
exe = "djlint",
args = { "-" },
args = { "-", "--reformat" },
stdin = 1,
}
end,
@ -72,14 +76,27 @@ return {
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)
local highlight = {
"L0",
"L1",
"L2",
"L3",
}
local hooks = require("ibl.hooks")
-- create the highlight groups in the highlight setup hook, so they are reset
-- every time the colorscheme changes
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl(0, "L0", { fg = "#cc0000" })
vim.api.nvim_set_hl(0, "L1", { fg = "#b30080" })
vim.api.nvim_set_hl(0, "L2", { fg = "#cc0000" })
vim.api.nvim_set_hl(0, "L3", { fg = "#b30080" })
end)
require("ibl").setup({ indent = { highlight = highlight } })
end,
},

View File

@ -337,6 +337,7 @@ return {
-----------------------------------------------------------------------------
{
'uga-rosa/ccc.nvim',
lazy = false,
event = 'FileType',
keys = {
{ '<Leader>cp', '<cmd>CccPick<CR>', desc = 'Color-picker' },