stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
2.91k stars 152 forks source link

feature request: #504

Open beaumccartney opened 1 month ago

beaumccartney commented 1 month ago

Did you check existing requests?

Describe the feature

in the old syntax, I could list a few formatters to try in order, and stop at the first just in the setup call i.e. per filetype

conform.setup({
    formatters_by_ft = {
        javascript = { { "prettierd", "prettier" } },
    },
})

for js files, this would use prettierd if available, and prettier otherwise.

afaik that api's deprecated (message everytime I use it), but from my reading and code spelunking, its not actually possible to specify stop_after_first in the table

is it possible to use the old functionality without using the deprecated api?

Provide background

provided above

What is the significance of this feature?

strongly desired

Additional details

was an old feature, was removed(??)

shubham-cpp commented 1 month ago

My question is, how to now run multiple formatters + conditionally run first available? In my config I had the following tldr; for go files run goimports + gofumpt (if available) or gofmt

require('conform').setup({
  formatters_by_ft = {
    go = { 'goimports', { 'gofumpt', 'gofmt' } },
    javascript = { { 'prettierd', 'prettier' }, 'eslint_d' },
    javascriptreact = { { 'prettierd', 'prettier' }, 'eslint_d' },
})

How can I now achieve this in stop_after_first ?

bpinto commented 1 month ago

https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#run-the-first-available-formatter-followed-by-more-formatters