Python "isort" is ignoring the project configuration
exhuma opened this issue · 5 comments
Which configuration?
Type (custom or builtin): builtin
Filetype: python
Formatter: isort
Configuration(s) (post all the variants you tried):
require('formatter').setup(
{
logging = true,
log_level = vim.log.levels.WARN,
filetype = {
python = {
require("formatter.filetypes.python").black,
require("formatter.filetypes.python").isort,
},
["*"] = {
require("formatter.filetypes.any").remove_trailing_whitespace
}
}
}
)
Expected behavior
The formatter should run isort
with the project configuration (this is the default isort
behaviour)
Actual behaviour
Runs isort
with the default config even if a configuration file exists in the project root.
Additional context
/
Is vim in the project directory when you run the formatter; is the output of :pwd<CR>
the project directory
Actually, this looks similar to #218
I can confirm that :pwd
shows the correct path. That is, the root of the project which contains the isort
config.
Ok it's because the stdin
option copies everything to a temp file first, so isort things the project directory is the temp dir or something.
If you change the line about requiring isort,
require("formatter.filetypes.python").isort,
to
function()
local util = require("formatter.util")
return {
exe = "isort",
args = {
"--quiet",
"--",
util.escape_path(util.get_current_buffer_file_path())
},
stdin = false
}
end,
that should fix it
Unfortunately this still ignores the config :(