Open ejrichards opened 3 months ago
I dug into the Harpoon code a bit and was able to make a smaller minimal config based on how it is loading buffers:
init.lua
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
},
})
nvim -u init.lua
:LoadTest
:UfoInspect
- Same output as aboveRelevant 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!
this was becoming irritating as I usually first zm
when opening a large file.
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 error