Open
Description
Neovim version (nvim -v)
0.11.1
Operating system/version
macOS 15.5
Read debugging tips
- I have read through the debugging tips.
Add the debug logs
- I have set
log_level = vim.log.levels.DEBUG
and pasted the log contents below.
Log file
Log file: /Users/ahmed/.local/state/nvim/conform.log
2025-05-30 16:48:21[DEBUG] Run CWD: /Users/ahmed/Sites/personal/dev/file.py
2025-05-30 16:48:21[DEBUG] ruff_fix exited with code 0
2025-05-30 16:48:21[INFO] Run ruff_organize_imports on /Users/ahmed/Sites/personal/dev/file.py
2025-05-30 16:48:21[DEBUG] Run command: { "/Users/ahmed/.local/bin/ruff", "check", "--fix", "--force-exclude", "--select=I001", "--exit-zero", "--no-cache", "--stdin-filename", "/Users/ahmed/Sites/personal/dev/file.py", "-" }
2025-05-30 16:48:21[DEBUG] Run CWD: /Users/ahmed/Sites/personal/dev/ai-explorations
2025-05-30 16:48:21[DEBUG] ruff_organize_imports exited with code 0
2025-05-30 16:48:21[INFO] Run trim_whitespace on /Users/ahmed/Sites/personal/dev/file.py
2025-05-30 16:48:21[INFO] Run trim_newlines on /Users/ahmed/Sites/personal/dev/file.py
Formatters for this buffer:
LSP: ruff
ruff_fix ready (python) /Users/ahmed/.local/bin/ruff
ruff_organize_imports ready (python) /Users/ahmed/.local/bin/ruff
trim_whitespace ready (*)
trim_newlines ready (*)
Other formatters:
alejandra ready (nix) /etc/profiles/per-user/ahmed/bin/alejandra
deno_fmt unavailable: Command 'deno' not found
goimports unavailable: Command 'goimports' not found
injected unavailable: Condition failed
jq ready (json) /run/current-system/sw/bin/jq
prettier ready (typescriptreact, graphql, less, scss, vue, json, markdown.mdx, jsonc, css, javascript, markdown, yaml, html, mdx, typescript.tsx, javascript.jsx, javascriptreact, typescript) /etc/profiles/per-user/ahmed/bin/prettier
shfmt ready (zsh) /etc/profiles/per-user/ahmed/bin/shfmt
statix ready (nix) /etc/profiles/per-user/ahmed/bin/statix
stylua ready (lua) /etc/profiles/per-user/ahmed/bin/stylua
taplo ready (toml) /etc/profiles/per-user/ahmed/bin/taplo
Describe the bug
I'm setting formatters for python
as follows, because I'm using ruff
as an LSP already. But when I save a file the LSP formatting doesn't run.
python = { 'ruff_fix', 'ruff_organize_imports', lsp_format = 'first' },
:=require('conform').list_formatters(0)
doesn't show LSP in the list, but :ConformInfo
shows it as enabled, but the logs doesn't show anything about formatting.
If I run vim.lsp.buf.format()
it works, also require("conform").format({ bufnr = 0 })
works and I see this in the log file
2025-05-30 16:57:45[DEBUG] Running LSP formatter on /Users/ahmed/Sites/personal/dev/file.py
2025-05-30 16:57:45[DEBUG] Running formatters on /Users/ahmed/Sites/personal/dev/file.py: { "ruff_fix", "ruff_organize_imports", "trim_whitespace", "trim_newlines" }
What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
- nvim -u repro.lua file.py
- save the file
- file is not formatted
Expected Behavior
- nvim -u repro.lua file.py
- save the file
- file is formatted
This is the output when running vim.lsp.buf.format()
or require("conform").format({ bufnr = 0 })
import datetime
def foo():
return datetime.time()
print(foo())
Minimal example file
import datetime
def foo():
return datetime.time()
print(foo())
Minimal init.lua
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
{
"stevearc/conform.nvim",
config = function()
require("conform").setup({
log_level = vim.log.levels.DEBUG,
formatters_by_ft = {
-- python = { lsp_format = "first" }, -- this also doesn't work
python = { "ruff_fix", "ruff_organize_imports", lsp_format = "first" },
},
})
end,
},
{
"https://github.com/neovim/nvim-lspconfig",
config = function()
vim.lsp.config("*", {
root_markers = { ".git" },
})
vim.lsp.config("ruff", {
init_options = {
settings = {
configurationPreference = "filesystemFirst",
fixAll = true,
organizeImports = true,
lint = {
enable = true,
preview = true,
},
format = {
preview = true,
},
},
},
})
vim.lsp.enable("ruff")
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
Additional context
No response