Formatting

This commit is contained in:
Chris
2026-07-03 13:48:02 +01:00
parent 12b0d3d8b8
commit fbcdd3af0c
7 changed files with 114 additions and 65 deletions
-45
View File
@@ -1,45 +0,0 @@
return { -- Autoformat
'stevearc/conform.nvim',
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
keys = {
{
'<leader>f',
function()
require('conform').format { async = true, lsp_format = 'fallback' }
end,
mode = '',
desc = '[F]ormat buffer',
},
},
config = function()
require('conform').setup({
notify_on_error = false,
format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true, vue = true, js = true }
if disable_filetypes[vim.bo[bufnr].filetype] then
return nil
else
return {
timeout_ms = 500,
lsp_format = 'fallback',
}
end
end,
formatters_by_ft = {
lua = { 'stylua' },
php = { 'pint' },
blade = { 'blade-formatter' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
},
log_level = vim.log.levels.DEBUG
})
end
}
+2
View File
@@ -207,6 +207,8 @@ return {
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
'blade-formatter',
'eslint_d',
'pint',
})
-- LSP servers and clients are able to communicate to each other what features they support.