kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.16k stars 37 forks source link

"UnhandledPromiseRejection: expected table, got nil" in nightly NeoVim #209

Closed sergey-tikhonenko closed 3 months ago

sergey-tikhonenko commented 3 months ago

Neovim version (nvim -v | head -n1)

NVIM v0.10.0-dev, git202403252105-3f238b39c-971e32c87

Operating system/version

Ubuntu 22.04.4 LTS

How to reproduce the issue

mv ~/.config/nvim{,.0}                                                                                                                                                                                                                                          
mv ~/.local/share/nvim{,.0}                                                                                                                                                                                                                                     
mv ~/.local/state/nvim{,.0}                                                                                                                                                                                                                                     
mv ~/.cache/nvim{,.0}                                                                                                                                                                                                                                           
mkdir -p  ~/.config/nvim/
cat >> ~/.config/nvim/init.lua <<EOF
-- [[ Install `lazy.nvim` plugin manager ]]
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)

-- [[ Configure and install plugins ]]
require("lazy").setup({

  { -- LSP Configuration & Plugins
    "neovim/nvim-lspconfig",
    dependencies = {
      "williamboman/mason.nvim",
      "williamboman/mason-lspconfig.nvim",
      "WhoIsSethDaniel/mason-tool-installer.nvim",
    },
    config = function()
      local capabilities = vim.lsp.protocol.make_client_capabilities()
      capabilities.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true }
--[[      capabilities = vim.tbl_deep_extend("force", capabilities, {
        textDocument = { foldingRange = { dynamicRegistration = false, lineFoldingOnly = true, }, },
      })
--]]
      local servers = {
        lua_ls = {},
      }
      require("mason").setup()
      local ensure_installed = vim.tbl_keys(servers or {})
      require("mason-tool-installer").setup({ ensure_installed = ensure_installed })

      require("mason-lspconfig").setup({
        handlers = {
          function(server_name)
            local server = servers[server_name] or {}
            server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
            require("lspconfig")[server_name].setup(server)
          end,
        },
      })
    end,
  },
  { -- Highlight, edit, and navigate code
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    opts = {
      ensure_installed = { "bash", "c", "html", "lua", "markdown", "vim", "vimdoc" },
      auto_install = true,
    },
    config = function(_, opts)
      ---@diagnostic disable-next-line: missing-fields
      require("nvim-treesitter.configs").setup(opts)
    end,
  },

  { -- Configure nvim-ufo (smart folding)
    "kevinhwang91/nvim-ufo",
    dependencies = { "kevinhwang91/promise-async" },
    event = "BufReadPost",
    opts = {
      close_fold_kinds_for_ft = { "imports", "comment" },
    },
    init = function()
      --   vim.o.foldcolumn = "0" -- '0' is not bad
      vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
      vim.o.foldlevelstart = 99
      --   vim.o.foldenable = true
    end,
  },

})
EOF
$ nvim --headless "+Lazy! sync" +TSUpdateSync +MasonToolsInstall "+sleep 10" +qa
$ nvim ~/.config/nvim/init.lua
  1. After opening the lua file in nvim the bellow error is occurs.
  2. The error is occurred only if the following line: close_fold_kinds_for_ft = { "imports", "comment" }, was present in the configuration.
  3. For setup, the reduced kickstart from neovim team was used.
  4. In the stable version (9.3) everything is successful. ...

    
    $ nvim -V1 -v
    NVIM v0.10.0-dev
    Build type: RelWithDebInfo
    LuaJIT 2.1.0-beta3
    Compilation: /usr/bin/cc -g -O2 -ffile-prefix-map=/build/neovim-5ZuIL6/neovim-0.10.0~ubuntu1+git202403252105-3f238b39c-971e32c87=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -O2 -g -Og -g -flto -fno-fat-lto-objects -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fsigned-char -fstack-protector-strong -Wno-conversion -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=auto  -DUNIT_TESTING -DHAVE_UNIBILIUM -D_GNU_SOURCE -DINCLUDE_GENERATED_DECLARATIONS -I/usr/include/luajit-2.1 -I/build/neovim-5ZuIL6/neovim-0.10.0~ubuntu1+git202403252105-3f238b39c-971e32c87/.deps/usr/include -I/build/neovim-5ZuIL6/neovim-0.10.0~ubuntu1+git202403252105-3f238b39c-971e32c87/build/src/nvim/auto -I/build/neovim-5ZuIL6/neovim-0.10.0~ubuntu1+git202403252105-3f238b39c-971e32c87/build/include -I/build/neovim-5ZuIL6/neovim-0.10.0~ubuntu1+git202403252105-3f238b39c-971e32c87/build/cmake.config -I/build/neovim-5ZuIL6/neovim-0.10.0~ubuntu1+git202403252105-3f238b39c-971e32c87/src -I/usr/include 
    
            общесистемный файл vimrc: "$VIM/sysinit.vim"
          значение $VIM по умолчанию: "/usr/share/nvim"

Run :checkhealth for more info


### Expected behavior

No error

### Actual behavior

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:
vim/shared.lua:0: t: expected table, got nil
stack traceback:
[C]: in function 'error'
...serge/.local/share/nvim/lazy/promise-async/lua/async.lua:90: in function 'await'
...ge/.local/share/nvim/lazy/nvim-ufo/lua/ufo/fold/init.lua:34: in function <...ge/.local/share/nvim/lazy/nvim-ufo/lua/ufo/fold/init.lua:24>

kevinhwang91 commented 3 months ago

close_fold_kinds_for_ft = { default = {'imports', 'comment'}, },