fix(nvim): format files on save with null-ls

This commit is contained in:
Oliver Davies 2022-01-09 00:22:22 +00:00
parent 09f4e9092e
commit 7932fb1d55
2 changed files with 13 additions and 0 deletions

View file

@ -36,3 +36,5 @@ lspconfig.tailwindcss.setup {
}
require("opdavies.lsp.handlers").setup()
require "opdavies.lsp.null-ls"

View file

@ -14,4 +14,15 @@ null_ls.setup {
diagnostics.eslint,
completion.spell,
},
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,
}