nvim-config/lua/configs/null-ls.lua

37 lines
871 B
Lua
Raw Normal View History

2022-03-01 02:58:43 +00:00
local M = {}
2022-05-01 17:43:11 +00:00
2022-03-01 02:58:43 +00:00
function M.config()
local status_ok, null_ls = pcall(require, "null-ls")
if not status_ok then
return
end
-- Check supported formatters
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
local formatting = null_ls.builtins.formatting
-- Check supported linters
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
local diagnostics = null_ls.builtins.diagnostics
null_ls.setup {
debug = false,
sources = {
-- Set a formatter
formatting.prettierd,
2022-09-19 18:56:07 +00:00
--formatting.black,
2022-05-01 17:43:11 +00:00
2022-03-01 02:58:43 +00:00
-- Set a linter
diagnostics.eslint_d,
},
-- Format before save
on_attach = function(client)
if client.resolved_capabilities.document_formatting then
vim.cmd "autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()"
end
end,
}
end
return M