39 lines
1.0 KiB
Lua
39 lines
1.0 KiB
Lua
---@module 'lazy'
|
|
---@type LazySpec
|
|
return { {
|
|
'stevearc/conform.nvim', -- allows you to format a buffer
|
|
event = { 'BufWritePre' },
|
|
cmd = { 'ConformInfo' },
|
|
keys = {
|
|
{
|
|
'<leader>f',
|
|
function()
|
|
require('conform').format { async = true, lsp_format = 'fallback' } -- execute the formatter
|
|
-- vim.cmd [[keepjumps keeppatterns %s/\s\+$//e]] -- removes trailing whitespace
|
|
end,
|
|
mode = 'n',
|
|
desc = '[f]ormat buffer',
|
|
},
|
|
},
|
|
---@type conform.setupOpts
|
|
opts = {
|
|
notify_on_error = true,
|
|
formatters_by_ft = {
|
|
c = { 'clang-format' },
|
|
h = { 'clang-format' },
|
|
cpp = { 'clang-format' },
|
|
hpp = { 'clang-format' },
|
|
glsl = { 'clang-format', lsp_format = "first" },
|
|
typescript = { 'clang-format', lsp_format = "first" },
|
|
css = { 'clang-format' },
|
|
rust = { 'rustfmt' },
|
|
sh = { 'shfmt' },
|
|
python = { 'isort' },
|
|
-- json = { 'jq' },
|
|
-- yaml = { 'yq' },
|
|
toml = { 'yq' },
|
|
xml = { 'yq' },
|
|
},
|
|
}
|
|
} }
|