Neovim version (nvim -v)
NVIM v0.12.2
Operating system/version
WSL Ubuntu 24.04.3
Read debugging tips
Add the debug logs
Log file
I don't think this is relevant for this issue.
Describe the bug
If only LSP formatters are being used, :ConformInfo might list something like the following:
Formatters for this buffer:
LSP: server1, server2
The listed servers might be incorrect if some are taken out by using the filter option.
What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
nvim -u repro.lua test.lua
- Wait for LSP servers to be installed by Mason
:ConformInfo
- Formatters for this buffer shows both
lua_ls and stylua
Expected Behavior
Only stylua should be shown as a formatter, as lua_ls has been filtered out in the repro.lua
Minimal example file
File is empty but should be Lua.
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 = {
lua = {
filter = function(client)
return client.name ~= "lua_ls"
end,
},
},
})
end,
},
-- add any other plugins here
"neovim/nvim-lspconfig",
{
"mason-org/mason.nvim",
opts = {},
},
{
"mason-org/mason-lspconfig.nvim",
opts = {
ensure_installed = { "lua_ls", "stylua" },
},
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
Additional context
Looks like :ConformInfo gathers the LSP clients here:
|
local lsp_clients = lsp_format.get_format_clients({ bufnr = vim.api.nvim_get_current_buf() }) |
This does not pass any filter fields that the user specified in their setup options.
However, the format command may merge filetype options:
|
merge_default_opts( |
|
opts, |
|
get_opts_from_filetype(opts.bufnr) or {}, |
|
{ allow_filetype_opts = true } |
|
) |
So, the actual formatting may filter out certain LSP servers.
Neovim version (nvim -v)
NVIM v0.12.2
Operating system/version
WSL Ubuntu 24.04.3
Read debugging tips
Add the debug logs
log_level = vim.log.levels.DEBUGand pasted the log contents below.Log file
I don't think this is relevant for this issue.
Describe the bug
If only LSP formatters are being used,
:ConformInfomight list something like the following:The listed servers might be incorrect if some are taken out by using the
filteroption.What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
nvim -u repro.lua test.lua:ConformInfolua_lsandstyluaExpected Behavior
Only
styluashould be shown as a formatter, aslua_lshas been filtered out in therepro.luaMinimal example file
-- test.luaFile is empty but should be Lua.
Minimal init.lua
Additional context
Looks like
:ConformInfogathers the LSP clients here:conform.nvim/lua/conform/health.lua
Line 148 in dca1a19
This does not pass any
filterfields that the user specified in their setup options.However, the
formatcommand may merge filetype options:conform.nvim/lua/conform/init.lua
Lines 408 to 412 in dca1a19
So, the actual formatting may filter out certain LSP servers.