44 lines
934 B
Lua
44 lines
934 B
Lua
|
return {
|
||
|
'conform.nvim',
|
||
|
event = { 'BufWritePre' },
|
||
|
cmd = { 'ConformInfo' },
|
||
|
keys = {
|
||
|
{
|
||
|
'<LEADER>cf',
|
||
|
function()
|
||
|
require('conform').format()
|
||
|
end,
|
||
|
desc = 'format',
|
||
|
},
|
||
|
{
|
||
|
'<LEADER>cF',
|
||
|
function()
|
||
|
require('conform').format({
|
||
|
formatters = { 'injected' },
|
||
|
timeout_ms = 3000,
|
||
|
})
|
||
|
end,
|
||
|
mode = { 'n', 'v' },
|
||
|
desc = 'format injected langs',
|
||
|
},
|
||
|
},
|
||
|
after = function()
|
||
|
require('conform').setup({
|
||
|
format_on_save = function(buf)
|
||
|
if (vim.g.autoformat == false) or (vim.b[buf].autoformat == false) then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
return { timeout_ms = 3000, lsp_format = 'fallback' }
|
||
|
end,
|
||
|
formatters_by_ft = {
|
||
|
lua = { 'stylua' },
|
||
|
fish = { 'fish_indent' },
|
||
|
sh = { 'shfmt' },
|
||
|
},
|
||
|
})
|
||
|
|
||
|
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||
|
end,
|
||
|
}
|