stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
2.55k stars 135 forks source link

bug: error: attempt to call field 'root' (a nil value) #449

Closed radu781 closed 3 weeks ago

radu781 commented 3 weeks ago

Neovim version (nvim -v)

NVIM v0.10.0-dev-2752+g35239e977

Operating system/version

Windows 10

Add the debug logs

Log file

Error executing Lua callback: ...site\pack\packer\start\conform.nvim/lua/conform/util.lua:53: attempt to call field 'root' (a nil value) stack traceback: ...site\pack\packer\start\conform.nvim/lua/conform/util.lua:53: in function 'cwd' ...site\pack\packer\start\conform.nvim/lua/conform/init.lua:633: in function 'get_formatter_info' ...te\pack\packer\start\conform.nvim/lua/conform/health.lua:144: in function 'append_formatters' ...te\pack\packer\start\conform.nvim/lua/conform/health.lua:163: in function 'show_window' ...site\pack\packer\start\conform.nvim/lua/conform/init.lua:165: in function <...site\pack\packer\start\conform.nvim/lua/conform/init.lua:164>

Describe the bug

I can no longer use the plugin as it is intended, even a call to format fails

require("conform").format()

Full config:

local conform = require("conform")
conform.setup({
    formatters_by_ft = {
        lua = { "stylua" },
        -- Conform will run multiple formatters sequentially
        python = { "isort", "black" },
        -- Use a sub-list to run only the first available formatter
        -- javascript = { { "prettierd", "prettier" } },
        rust = { "rustfmt" },
        dart = { "dart format" },
    },
})

vim.keymap.set("n", "<leader>fr", function()
    local success = conform.format()
    local fidget = require("fidget")
    if success then
        fidget.notify("File formatted 󰸞")
    else
        fidget.notify("File format failed", vim.log.levels.ERROR, { annote = "File format failed" })
    end
end, { desc = "format file" })

What is the severity of this bug?

blocking (cannot use plugin)

Steps To Reproduce

  1. require("conform").format()

Expected Behavior

A couple of days ago this used to work, as in format the file without error

Minimal example file

No response

Minimal init.lua

No response

Additional context

No response

stevearc commented 3 weeks ago

You are on an old version of Neovim nightly that does not have vim.fs.root. I recommend upgrading to the released v0.10.0 version.

GLaDOS-418 commented 4 days ago

I was also getting this error even when I was using the nvim 0.10.0. it turned out I had a wrong value for one of the settings.