null-ls.nvim
null-ls.nvim copied to clipboard
Add an option to activate source only if a configuration is found in the project
Issues
- [X] I have checked existing issues and there are no existing ones with the same request.
Feature description
My current use case would be the prettier
linter. I am using eslint
in a project and prettier is overriding it.
So I tried doing only_local
, but prettier is actually being installed in node_modules by a dependency of my project.
As a workaround I tried adding a condition:
condition = function(utils)
return utils.root_has_file({
'.prettierrc',
'.prettierrc.json',
'.prettierrc.yml',
'.prettierrc.yaml',
'.prettierrc.json5',
'.prettierrc.js',
'.prettierrc.cjs',
'.prettierrc.toml',
'prettier.config.js',
'prettier.config.cjs',
})
end,
And this works 99% of the cases. Thing is that prettier also recognizes an entry inside package.json... So I feel like this would be a common thing to happen, maybe there should be an option to let the source decide whether it finds a configuration and activate it accordingly. Perhaps that's not possible, if that's the case then it would be nice to have a condition that allows me to check inside package.json for prettier (some util that let's us check inside files perhaps)