Added prettier back and limited it
This commit is contained in:
@@ -9,9 +9,29 @@ return {
|
||||
local formatting = null_ls.builtins.formatting
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
|
||||
local root_has_file = function(files)
|
||||
return function(utils)
|
||||
return utils.root_has_file(files)
|
||||
end
|
||||
end
|
||||
local prettier_root_files = {
|
||||
".prettierrc",
|
||||
".prettierrc.json",
|
||||
".prettierrc.js",
|
||||
".prettierrc.mjs",
|
||||
".prettierrc.cjs",
|
||||
"prettier.config.cjs",
|
||||
"prettier.config.js",
|
||||
"prettier.config.mjs",
|
||||
}
|
||||
local formatting_with_prettier = formatting.prettier.with({
|
||||
condition = root_has_file(prettier_root_files),
|
||||
})
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
formatting.stylua,
|
||||
formatting.prettier.with(formatting_with_prettier),
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
|
||||
Reference in New Issue
Block a user