kevinhwang91 / nvim-ufo

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

first file fold is not enabled when nvim start from directory #114

Closed devstefancho closed 1 year ago

devstefancho commented 1 year ago

Neovim version (nvim -v | head -n1)

NVIM v0.8.2

Operating system/version

macOS 12.2.1

How to reproduce the issue

https://user-images.githubusercontent.com/61320923/218629737-6c03a987-79f0-47f2-9d30-02605666ac83.mov

My config file commit code

My nvim directory structure

markdown
.
├── README.md
├── after
│   └── plugin
│       ├── autopairs.lua
│       ├── bufferline.lua
│       ├── cmp.lua
│       ├── colorizer.lua
│       ├── colorscheme
│       ├── comment.lua
│       ├── gitsigns.lua
│       ├── indent-blankline.lua
│       ├── lspconfig.lua
│       ├── lspsaga.lua
│       ├── lualine.lua
│       ├── luasnip.lua
│       ├── null-ls.lua
│       ├── nvim-dap.lua
│       ├── nvim-tree.lua
│       ├── nvim-ufo.lua
│       ├── telescope.lua
│       ├── toggleterm.lua
│       ├── treesitter.lua
│       ├── true-zen.lua
│       ├── ts-autotag.lua
│       └── web-devicons.lua
├── init.lua
├── lua
│   └── myconfig
│       ├── base.lua
│       ├── globals.lua
│       ├── highlights.lua
│       ├── icons.lua
│       ├── macos.lua
│       ├── maps.lua
│       ├── nvim-lsp
│       ├── plugins.lua
│       └── windows.lua
└── plugin
    └── packer_compiled.lua

8 directories, 32 files

Here is my lua config

init.lua

vim.o.foldcolumn = "1" -- '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

-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)

(...)
  -- Install with Packer
  use({ "kevinhwang91/nvim-ufo", requires = "kevinhwang91/promise-async" })

after/plugin/nvim-ufo.lua

require("ufo").setup({
  provider_selector = function(bufnr, filetype, buftype)
    return { "treesitter", "indent" }
  end,
})

Expected behavior

cd ~/.config/nvim
vi .

then open with nvim-tree ( In video, bufferline.lua) then open any file with telescope (or just :e init.lua)

then the second opened with enabling fold ( In video, material.lua)

Actual behavior

cd ~/.config/nvim
vi .

then open with nvim-tree then open any file with telescope (or just :e init.lua)

then file opened but not enabling fold and when opening second file, fold is enabled

kevinhwang91 commented 1 year ago

I don't use nvim-tree and telescope, can't help with this issue.

rockyzhang24 commented 1 year ago

I cannot reproduce it no matter what providers I use. So this is not a bug of nvim-ufo, even not a bug of nvim-tree or telescope.

See the demo below where I have the same config with yours.

https://user-images.githubusercontent.com/11582667/218932585-57a4838e-a428-41ca-a050-5d2db7a75c93.mov

devstefancho commented 1 year ago

@rockyzhang24 Hmm... thanks for sharing demo If you don't mind would you share your config?

rockyzhang24 commented 1 year ago

Sure, but I am using coc currently whose config is not uploaded to github. I will attach my config for nvim-lsp for your reference, https://github.com/rockyzhang24/dotfiles/tree/master/.config/nvim. The nvim-tree config here is kinda outdated because I haven't used it for a while. Just now when I tried to reproduce your issue, I re-installed nvim-tree and used the config (shown below) grabbed from its readme

require("nvim-tree").setup()

local function open_nvim_tree()
  require("nvim-tree.api").tree.open()
end
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })

Hope this is helpful.

kevinhwang91 commented 1 year ago

It's stale.