-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UFO fails to initialize in buffer when the buffer is loaded while hidden then opened (Harpoon) #210
Comments
I dug into the Harpoon code a bit and was able to make a smaller minimal config based on how it is loading buffers:
vim.api.nvim_create_user_command('LoadTest', function ()
local filename = 'init.lua'
local bufnr = vim.fn.bufnr(filename, true)
vim.fn.bufload(bufnr)
vim.api.nvim_set_option_value("buflisted", true, { buf = bufnr })
vim.api.nvim_set_current_buf(bufnr)
end, {})
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not 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({
{
"kevinhwang91/nvim-ufo",
dependencies = { "kevinhwang91/promise-async" },
config = function()
vim.o.foldcolumn = '1'
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
local ufo = require('ufo')
ufo.setup({
provider_selector = function(bufnr, filetype, buftype)
return {'treesitter', 'indent'}
end
})
end
},
})
Relevant function in harpoon: Link |
facing this exact same issue, were you able to find a solution for this? |
A workaround for harpoon specifically, you can force Ufo to reload on every navigation: require("harpoon"):extend(require("harpoon.extensions").builtins.command_on_nav('UfoEnableFold')) |
thanks for the solution! |
Neovim version (nvim -v | head -n1)
NVIM v0.9.5
Operating system/version
Ubuntu 22.04.4 (WSL) and Windows 11
How to reproduce the issue
Minimal config:
nvim -u init.lua init.lua
<Space>a
to append the file to Harpoon list:bw
<C-j>
to open the file via Harpoon:UfoInspect
Output:
:e
to reload:UfoInspect
Expected behavior
UFO should initialize properly when a buffer is opened via Harpoon
Actual behavior
No folds are created and
:UfoInspect
reports an errorThe text was updated successfully, but these errors were encountered: