plugins.conform-nvim.settings
Options provided to the require('conform').setup
function.
Type: attribute set of anything
Default:
{ }
Example:
{
formatters_by_ft = {
bash = [
"shellcheck"
"shellharden"
"shfmt"
];
cpp = [ "clang_format" ];
javascript = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
timeout_ms = 2000;
stop_after_first = true;
};
"_" = [
"squeeze_blanks"
"trim_whitespace"
"trim_newlines"
];
};
format_on_save = # Lua
''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
if slow_format_filetypes[vim.bo[bufnr].filetype] then
return
end
local function on_format(err)
if err and err:match("timeout$") then
slow_format_filetypes[vim.bo[bufnr].filetype] = true
end
end
return { timeout_ms = 200, lsp_fallback = true }, on_format
end
'';
format_after_save = # Lua
''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
if not slow_format_filetypes[vim.bo[bufnr].filetype] then
return
end
return { lsp_fallback = true }
end
'';
log_level = "warn";
notify_on_error = false;
notify_no_formatters = false;
formatters = {
shellcheck = {
command = lib.getExe pkgs.shellcheck;
};
shfmt = {
command = lib.getExe pkgs.shfmt;
};
shellharden = {
command = lib.getExe pkgs.shellharden;
};
squeeze_blanks = {
command = lib.getExe' pkgs.coreutils "cat";
};
};
}
Declared by:
plugins.conform-nvim.settings.format_after_save
If this is set, Conform will run the formatter asynchronously after save.
Conform will pass the table from format_after_save
to conform.format()
.
This can also be a function that returns the table.
See :help conform.format
for details.
Type: null or lua function string or (attribute set of anything)
Default:
null
Plugin default: { }
Declared by:
plugins.conform-nvim.settings.format_on_save
If this is set, Conform will run the formatter asynchronously on save.
Conform will pass the table from format_on_save
to conform.format()
.
This can also be a function that returns the table.
See :help conform.format
for details.
Type: null or lua function string or (attribute set of anything)
Default:
null
Plugin default: { }
Declared by:
plugins.conform-nvim.settings.formatters
Custom formatters and changes to built-in formatters.
Type: null or (attribute set of (anything or raw lua code))
Default:
null
Plugin default: { }
Declared by:
plugins.conform-nvim.settings.formatters_by_ft
Creates a table mapping filetypes to formatters.
You can run multiple formatters in a row by adding them in a list.
If you’d like to stop after the first successful formatter, set stop_after_first
.
# Map of filetype to formatters
formatters_by_ft =
{
lua = [ "stylua" ];
# Conform will run multiple formatters sequentially
python = [ "isort" "black" ];
# Use stop_after_first to run only the first available formatter
javascript = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
# Use the "*" filetype to run formatters on all filetypes.
"*" = [ "codespell" ];
# Use the "_" filetype to run formatters on filetypes that don't
# have other formatters configured.
"_" = [ "trim_whitespace" ];
};
Type: null or (attribute set of (anything or raw lua code))
Default:
null
Plugin default: { }
Declared by:
plugins.conform-nvim.settings.log_level
Set the log level. Use :ConformInfo
to see the location of the log file.
Type: null or unsigned integer, meaning >=0, or one of “off”, “error”, “warn”, “info”, “debug”, “trace”
Default:
null
Plugin default: "error"
Declared by:
plugins.conform-nvim.settings.notify_no_formatters
Conform will notify you when no formatters are available for the buffer.
Type: null or boolean or raw lua code
Default:
null
Plugin default: true
Declared by:
plugins.conform-nvim.settings.notify_on_error
Conform will notify you when a formatter errors.
Type: null or boolean or raw lua code
Default:
null
Plugin default: true
Declared by: