feature request: Flag to prioritize locally installed formatter
Did you check existing requests?
- [X] I have searched the existing issues
Describe the feature
It would be nice to have a flag for the config that made conform prioritize locally installed formatters, instead of those installed by Mason
Provide background
Often we may find ourselves working in a project where we need to abide to certain formatting guidelines, and the tools used are not the same that we may personally use, for example:
In a Typescript project, we might personally choose to use BiomeJS, but we may find ourselves working in a project that expects us to run Prettier.
Right now, if we configured Conform like so:
typescript = { "biome", "prettier" }
We would always run BiomeJS on the file, regardless of whether the project that we're working on already has a configuration file for Prettier, and has its binary installed as a dependency
What is the significance of this feature?
nice to have
Additional details
No response
I just found out the following snippet :
formatters_by_ft = {
python = function(bufnr)
if require("conform").get_formatter_info("ruff_format", bufnr).available then
return { "ruff_format" }
else
return { "isort", "black" }
end
end,
see https://github.com/stevearc/conform.nvim/blob/master/README.md#options
Haven't tried it on my own, but it looks like you could do similar to pick prettier if it's available + fallback to biome.
This is correct way to get that behavior. All the tools are available, you just have to write the glue code yourself.
@stevearc I have a similar question but about local vs global installs of the same tool.
If I have prettier installed globally, but it's also set up locally in the project with some extra plugins that I don't have installed globally, is there a way to prioritize using the local install rather than the global one?
EDIT: Nevermind! It seems as though this is just the default behavior of Conform! (I love this plugin)