nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
The Unlicense
2.44k stars 73 forks source link

Condition with function `util.root_has_file` error #162

Closed Gitfz810 closed 2 months ago

Gitfz810 commented 2 months ago

FAQ

Issues

Neovim Version

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478

Dev Version?

Operating System

mac osx

Minimal Config

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"

if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  {
    "nvimtools/none-ls.nvim",
    config = function()
      local setup, null_ls = pcall(require, "null-ls")
      if not setup then
        return
      end

      local formatting = null_ls.builtins.formatting

      null_ls.setup({
        sources = {
          formatting.stylua.with({ -- lua formatter
            condition = function(utils)
              return utils.root_has_file({ "stylua.toml", ".stylua.toml" })
            end,
          }),
        },
      })
    end,
  },
}, {
  checker = {
    enabled = true,
    notify = false,
  },
  change_detection = {
    notify = false,
  },
})

Steps to Reproduce

mkdir -p foo

nvim mian.rs

Reproducibility Check

Expected Behavior

Open file with no error.

Actual Behavior

image

Debug Log

no useful log for this error

Help

Yes

Implementation Help

No response

Requirements