nvim: properly handle formatting
This commit is contained in:
parent
5056f3efec
commit
0a0f43438b
@ -1,6 +1,23 @@
|
|||||||
vim.api.nvim_create_autocmd('BufWrite', {
|
vim.api.nvim_create_autocmd('BufWrite', {
|
||||||
pattern = '*',
|
pattern = '*',
|
||||||
callback = function()
|
callback = function()
|
||||||
|
local filetype = vim.bo.filetype
|
||||||
|
local neoformat_types = { 'sh' }
|
||||||
|
local ignore_types = {}
|
||||||
|
|
||||||
|
for _, ig_type in ipairs(ignore_types) do
|
||||||
|
if filetype == ig_type then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, nf_type in ipairs(neoformat_types) do
|
||||||
|
if filetype == nf_type then
|
||||||
|
vim.cmd('Neoformat')
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
vim.cmd('lua vim.lsp.buf.format({ async = true })')
|
vim.cmd('lua vim.lsp.buf.format({ async = true })')
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user