Closed Pandoks closed 9 months ago
0.9.2
macOS 13.5.2
I am using lazy.nvim ufo config:
ufo config
local handler = function(virtText, lnum, endLnum, width, truncate) local newVirtText = {} local suffix = (" %d "):format(endLnum - lnum) local sufWidth = vim.fn.strdisplaywidth(suffix) local targetWidth = width - sufWidth local curWidth = 0 for _, chunk in ipairs(virtText) do local chunkText = chunk[1] local chunkWidth = vim.fn.strdisplaywidth(chunkText) if targetWidth > curWidth + chunkWidth then table.insert(newVirtText, chunk) else chunkText = truncate(chunkText, targetWidth - curWidth) local hlGroup = chunk[2] table.insert(newVirtText, { chunkText, hlGroup }) chunkWidth = vim.fn.strdisplaywidth(chunkText) -- str width returned from truncate() may less than 2nd argument, need padding if curWidth + chunkWidth < targetWidth then suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth) end break end curWidth = curWidth + chunkWidth end table.insert(newVirtText, { suffix, "MoreMsg" }) return newVirtText end return { "kevinhwang91/nvim-ufo", lazy = false, -- too buggy to lazy load dependencies = { "kevinhwang91/promise-async", "nvim-treesitter/nvim-treesitter", }, opts = { fold_virt_text_handler = handler, provider_selector = function() return { "treesitter", "indent" } end, }, keys = { { "<leader>K", "<cmd>lua require('ufo').peekFoldedLinesUnderCursor()<cr>", mode = "n", desc = "Peek folded portion", }, }, config = function(_, opts) vim.o.foldlevel = 99 vim.o.foldlevelstart = 99 vim.o.foldenable = true vim.o.fillchars = "eob: ,fold: ,foldopen:,foldsep: ,foldclose:" require("ufo").setup(opts) end, }
formatter.nvim:
formatter.nvim
return { "mhartington/formatter.nvim", event = "BufWritePre", keys = { { "<leader>F", "<cmd>Format<cr>", mode = "n", desc = "Format the file" }, }, config = function() local mason = vim.fn.stdpath("data") .. "/mason/bin/" local opts = { logging = false, filetype = { lua = { require("formatter.filetypes.lua").stylua, ignore_exitcode = true, }, sh = { require("formatter.filetypes.sh").shfmt, ignore_exitcode = true, }, c = { require("formatter.filetypes.c").clangformat, ignore_exitcode = true, }, javascript = { require("formatter.filetypes.javascript").prettier, ignore_exitcode = true, }, typescript = { require("formatter.filetypes.typescript").prettier, ignore_exitcode = true, }, svelte = { require("formatter.filetypes.svelte").prettier, ignore_exitcode = true, }, yaml = { require("formatter.filetypes.yaml").prettier, ignore_exitcode = true, }, markdown = { require("formatter.filetypes.markdown").prettier, ignore_exitcode = true, }, ["*"] = { require("formatter.filetypes.any").remove_trailing_whitespace, ignore_exitcode = true, }, }, } require("formatter").setup(opts) -- format after save vim.api.nvim_create_augroup("FormatAutogroup", { clear = true }) vim.api.nvim_create_autocmd({ "BufWritePost" }, { group = "FormatAutogroup", command = "FormatWrite", }) end, }
Open a file. UFO folding works perfectly. Edit something. Save, which is auto formatted. Fold anything, and it folds the entire buffer. I need to reopen the buffer using :e to get the functionality working again.
:e
Normal UFO folding:
Entire buffer folding:
Neovim version (nvim -v | head -n1)
0.9.2
Operating system/version
macOS 13.5.2
How to reproduce the issue
I am using lazy.nvim
ufo config
:formatter.nvim
:Open a file. UFO folding works perfectly. Edit something. Save, which is auto formatted. Fold anything, and it folds the entire buffer. I need to reopen the buffer using
:e
to get the functionality working again.Expected behavior
Normal UFO folding:![2023-09-14 00 41 02](https://github.com/kevinhwang91/nvim-ufo/assets/35944715/679f9a9b-1988-48ca-9970-f1a8df200727)
Actual behavior
Entire buffer folding:![2023-09-14 00 41 59](https://github.com/kevinhwang91/nvim-ufo/assets/35944715/369036c9-a1a4-4c04-998a-b8bde4ead55f)