nvim formatting

This commit is contained in:
2025-05-06 20:51:04 +02:00
parent 226f80e197
commit 5529de45a9

View File

@@ -619,12 +619,7 @@ require('lazy').setup({
vue = { hybridMode = true }, vue = { hybridMode = true },
}, },
}, },
eslint = { eslint = {},
init_options = {
filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'vue' },
format = { enable = true },
},
},
--prettierd = {}, --prettierd = {},
-- TODO: end -- TODO: end
html = {}, html = {},
@@ -699,31 +694,44 @@ require('lazy').setup({
desc = '[F]ormat buffer', desc = '[F]ormat buffer',
}, },
}, },
opts = { config = function()
notify_on_error = false, local conform = require('conform').setup {
format_on_save = function(bufnr) notify_on_error = false,
-- Disable "format_on_save lsp_fallback" for languages that don't format_on_save = function(bufnr)
-- have a well standardized coding style. You can add additional -- Disable "format_on_save lsp_fallback" for languages that don't
-- languages here or re-enable it for the disabled ones. -- have a well standardized coding style. You can add additional
local disable_filetypes = { c = true, cpp = true } -- languages here or re-enable it for the disabled ones.
if disable_filetypes[vim.bo[bufnr].filetype] then local disable_filetypes = { c = true, cpp = true }
return nil if disable_filetypes[vim.bo[bufnr].filetype] then
else return nil
return { else
timeout_ms = 500, return {
lsp_format = 'fallback', timeout_ms = 500,
} lsp_format = 'fallback',
end }
end, end
formatters_by_ft = { end,
lua = { 'stylua' }, formatters_by_ft = {
-- Conform can also run multiple formatters sequentially lua = { 'stylua' },
-- python = { "isort", "black" }, -- 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' }, -- You can use 'stop_after_first' to run the first available formatter from the list
}, javascript = {},
}, typescript = {},
vue = {},
typescriptreact = {},
javascriptreact = {},
},
}
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*',
callback = function(args)
require('conform').format { bufnr = args.buf, lsp_fallback = true }
end,
})
end,
}, },
{ -- Autocompletion { -- Autocompletion