Fix null-ls formatter conflict

This commit is contained in:
ViViDboarder 2022-01-21 21:21:54 -08:00
parent 1e0ae56e92
commit da77afdfb3

View File

@ -15,16 +15,19 @@ local function disable_formatter_filetypes_for_existing_servers(sources, preserv
return not vim.tbl_contains(preserve or {}, ft) return not vim.tbl_contains(preserve or {}, ft)
end, server_filetypes) end, server_filetypes)
-- Map disabled filetypes onto list of sources local NULL_LS_FORMATTING = require("null-ls").methods.FORMATTING
local NULL_LS_FORMATTING = require("null-ls.methods").FORMATTING
local formatters = vim.tbl_filter(function(builtin)
return builtin.METHOD == NULL_LS_FORMATTING
end, sources)
-- Apply with statement to all filtered formatters to disable filetypes -- Apply with statement to all filtered formatters to disable filetypes
vim.tbl_map(function(builtin) sources = vim.tbl_map(function(builtin)
if
builtin.method == NULL_LS_FORMATTING
or (type(builtin.method) == "table" and utils.list_contains(builtin.method, NULL_LS_FORMATTING))
then
return builtin.with({ disabled_filetypes = server_filetypes }) return builtin.with({ disabled_filetypes = server_filetypes })
end, formatters) end
return builtin
end, sources)
return sources return sources
end end
@ -60,7 +63,7 @@ function M.configure(options)
null_ls.builtins.diagnostics.hadolint, null_ls.builtins.diagnostics.hadolint,
} }
disable_formatter_filetypes_for_existing_servers(sources, { "python" }) sources = disable_formatter_filetypes_for_existing_servers(sources, { "python" })
-- Add custom or modified sources -- Add custom or modified sources
vim.list_extend(sources, { vim.list_extend(sources, {