Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(isort): explicitly pass line endings #395

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions lua/conform/formatters/isort.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@ return {
description = "Python utility / library to sort imports alphabetically and automatically separate them into sections and by type.",
},
command = "isort",
args = {
"--stdout",
"--filename",
"$FILENAME",
"-",
},
args = function(self, ctx)
-- isort doesn't do a good job of auto-detecting the line endings.
local line_ending
local file_format = vim.bo[ctx.buf].fileformat
if file_format == "dos" then
line_ending = "\r\n"
elseif file_format == "mac" then
line_ending = "\r"
else
line_ending = "\n"
end
return {
"--stdout",
"--line-ending",
line_ending,
"--filename",
"$FILENAME",
"-",
}
end,
cwd = util.root_file({
-- https://pycqa.github.io/isort/docs/configuration/config_files.html
".isort.cfg",
Expand Down
Loading