-
Lets say that I have a few formatters setup for
I want to be able to choose which "set" I use; sometimes I want to format the entire file, otherwise I want to format only the changed sections. Now I understand there is a Ideally, I'd be able to do something like map local function format_full()
vim.g._null_format_diff = false
vim.lsp.buf.formatting_sync()
end and then map local function format_diff()
vim.g._null_format_diff = true
vim.lsp.buf.formatting_sync()
end such that I can later use a function with local n = require("null-ls")
local diff_fmt = function()
return vim.g._null_format_diff
end
local full_fmt = function()
return not vim.g._null_format_diff
end
n.config({
sources = {
n.builtins.formatting.isort.with({
format_condition = diff_fmt,
}),
n.builtins.formatting.black.with({
format_condition = full_fmt,
}),
custom.darker.with({
format_condition = full_fmt,
}),
},
}) so that I can choose which set of formatters run. I'm happy to make a PR for something like this, but was curious if there was already a way to do it such that I don't waste my time. Curious on your thoughts @jose-elias-alvarez. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
See #203 |
Beta Was this translation helpful? Give feedback.
See #203