Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

How do I configure null-ls.nvim to ignore a formatter's output if it returns an error exit code? #1492

Discussion options

You must be logged in to vote

Given the following null-ls source:

local bad_formatter = {
    name = "bad_formatter",
    method = null_ls.methods.FORMATTING,
    filetypes = {},
    generator = null_ls.formatter({
        -- by default, we assume that non-zero exit codes are bad
        command = vim.loop.cwd() .. "/bad_formatter.sh",
    }),
}

And the following script in bad_formatter.sh:

#!/bin/bash

echo "stdout"
exit 1

null-ls will correctly handle this case, as well as the more common stderr case:

#!/bin/bash

>&2 echo "stderr"
exit 1

If your formatter outputs to both stdout and stderr, that is indeed an edge case:

#!/bin/bash

# will replace file's content with stdout
echo "stdout"
>&2 echo "stderr"
exit 1

But …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@gregorias
Comment options

@jose-elias-alvarez
Comment options

Answer selected by gregorias
@gregorias
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants