add formatting on save

This commit is contained in:
vincent 2022-01-30 16:23:27 +01:00
parent be8153969b
commit 52c2852aa9

View File

@ -169,6 +169,16 @@ return require('packer').startup {
use({'jose-elias-alvarez/null-ls.nvim',
config= function()
require("null-ls").setup({
on_attach = function(client)
if client.resolved_capabilities.document_formatting then
vim.cmd([[
augroup LspFormatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
augroup END
]])
end
end,
sources = {
require("null-ls").builtins.formatting.prettier,
require("null-ls").builtins.formatting.trim_whitespace,