128 lines
3.8 KiB
Lua
128 lines
3.8 KiB
Lua
return {
|
|
{
|
|
'sbdchd/neoformat',
|
|
event = {
|
|
"BufReadPost",
|
|
"BufNewFile"
|
|
},
|
|
init = function()
|
|
----------------
|
|
-- Formatters
|
|
----------------
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "python",
|
|
callback = function()
|
|
-- vim.g.neoformat_python_autopep8 = {
|
|
-- exe = 'autopep8',
|
|
-- args = {'--max-line-length', '79', '--experimental'},
|
|
-- -- replace = 1
|
|
-- }
|
|
-- vim.g.neoformat_enabled_python = {
|
|
-- 'autopep8'
|
|
-- }
|
|
vim.g.neoformat_enabled_python = {
|
|
'ruff'
|
|
}
|
|
end
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = {
|
|
"cpp",
|
|
"c"
|
|
},
|
|
callback = function()
|
|
vim.g.neoformat_enabled_cpp = {
|
|
'clangformat'
|
|
}
|
|
vim.g.neoformat_enabled_c = {
|
|
'clangformat'
|
|
}
|
|
end
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "lua",
|
|
callback = function()
|
|
vim.g.neoformat_enable_lua = {
|
|
'luaformatter'
|
|
}
|
|
end
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "cmake",
|
|
callback = function()
|
|
vim.g.neoformat_enabled_cmake = {
|
|
'cmake-format'
|
|
}
|
|
end
|
|
})
|
|
|
|
-- Commented out rust formatter
|
|
-- vim.api.nvim_create_autocmd("FileType", {
|
|
-- pattern = "rust",
|
|
-- callback = function()
|
|
-- vim.g.neoformat_enabled_rust = {'rustfmt'}
|
|
-- end
|
|
-- })
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "markdown",
|
|
callback = function()
|
|
vim.g.neoformat_markdown_mdformat = {
|
|
exe = 'mdformat',
|
|
args = {
|
|
'--wrap=79',
|
|
'--number'
|
|
},
|
|
replace = 1
|
|
}
|
|
vim.g.neoformat_enabled_markdown = {
|
|
'mdformat'
|
|
}
|
|
end
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "tex",
|
|
callback = function()
|
|
vim.g.neoformat_tex_texfmt = {
|
|
exe = "tex-fmt",
|
|
args = {
|
|
"--stdin",
|
|
"--tabsize",
|
|
"4"
|
|
},
|
|
stdin = 1
|
|
}
|
|
vim.g.neoformat_enabled_tex = {
|
|
"texfmt"
|
|
}
|
|
end
|
|
})
|
|
|
|
----------------
|
|
-- Other
|
|
----------------
|
|
|
|
-- vim.cmd([[
|
|
-- augroup Neoformat
|
|
-- autocmd!
|
|
-- autocmd BufWritePre * undojoin | Neoformat
|
|
-- augroup END
|
|
-- ]])
|
|
|
|
vim.api.nvim_set_keymap('n', '<M-L>', '<cmd>Neoformat<cr>', {
|
|
noremap = true,
|
|
silent = true
|
|
})
|
|
vim.api.nvim_set_keymap('i', '<M-L>', '<cmd>Neoformat<cr>', {
|
|
noremap = true,
|
|
silent = true
|
|
})
|
|
end
|
|
}
|
|
}
|