stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
3.01k stars 156 forks source link

bug: lua/conform/util.lua:53: attempt to call field 'root' (a nil value) #442

Closed danielpost closed 4 months ago

danielpost commented 4 months ago

Neovim version (nvim -v)

NVIM v0.10.0-dev-2448+g0fcbda598-Homebrew

Operating system/version

MacOS 14.4.1

Add the debug logs

Log file

Running ConformInfo gives the same bug

Describe the bug

Getting the following error when running Conform. It's also happening when running :checkhealth and seems to be related to this change: https://github.com/stevearc/conform.nvim/commit/584adfe7c665827601f4245c0c40273e8bc9e7cb

E5108: Error executing lua: ....local/share/nvim/lazy/conform.nvim/lua/conform/util.lua:53: attempt to call field 'root' (a nil value)
stack traceback:
    ....local/share/nvim/lazy/conform.nvim/lua/conform/util.lua:53: in function 'cwd'
    ....local/share/nvim/lazy/conform.nvim/lua/conform/init.lua:633: in function 'get_formatter_info'
    ....local/share/nvim/lazy/conform.nvim/lua/conform/init.lua:293: in function 'list_formatters'
    ...are/nvim/lazy/LazyVim/lua/lazyvim/plugins/formatting.lua:61: in function 'sources'
    ...ocal/share/nvim/lazy/LazyVim/lua/lazyvim/util/format.lua:40: in function <...ocal/share/nvim/lazy/LazyVim/lua/lazyvim/util/format.lua:39>
    vim/shared.lua: in function 'resolve'
    ...ocal/share/nvim/lazy/LazyVim/lua/lazyvim/util/format.lua:118: in function 'format'
    ...l/share/nvim/lazy/LazyVim/lua/lazyvim/config/keymaps.lua:96: in function <...l/share/nvim/lazy/LazyVim/lua/lazyvim/config/keymaps.lua:95>

What is the severity of this bug?

blocking (cannot use plugin)

Steps To Reproduce

  1. Run Conform on any file

Expected Behavior

No error message and a formatted file.

Minimal example file

No response

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,
        -- add your config here
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

No response

danielpost commented 4 months ago

Updating Neovim fixes the issue, sorry 🤦🏼‍♂️