From 58ebc9f9c26e66f7fcbd257e8189ff500503ff27 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 31 Jul 2026 12:24:47 -0400 Subject: [PATCH] Replace nvim-ufo with LazyVim's native LSP folding LazyVim wires foldexpr to vim.lsp.foldexpr() when the server advertises textDocument/foldingRange, falling back to vim.treesitter.foldexpr(). ufo's init block fought that by setting foldcolumn/foldlevel/foldenable and remapping zR/zM. The servers["*"] foldingRange capability is also redundant: Neovim advertises it with lineFoldingOnly by default. Co-Authored-By: Claude Opus 5 --- lua/plugins/folding.lua | 68 ----------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 lua/plugins/folding.lua diff --git a/lua/plugins/folding.lua b/lua/plugins/folding.lua deleted file mode 100644 index f3b2bf6..0000000 --- a/lua/plugins/folding.lua +++ /dev/null @@ -1,68 +0,0 @@ -return { - -- add folding range to capabilities - { - "neovim/nvim-lspconfig", - opts = { - servers = { - ["*"] = { - capabilities = { - textDocument = { - foldingRange = { - dynamicRegistration = false, - lineFoldingOnly = true, - }, - }, - }, - }, - }, - }, - }, - -- add nvim-ufo - { - "kevinhwang91/nvim-ufo", - dependencies = { - "kevinhwang91/promise-async", - -- This looks awful, so leaving it disabled - -- { - -- "luukvbaal/statuscol.nvim", - -- config = function() - -- local builtin = require("statuscol.builtin") - -- require("statuscol").setup({ - -- relculright = true, - -- segments = { - -- { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, - -- { text = { "%s" }, click = "v:lua.ScSa" }, - -- { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, - -- }, - -- }) - -- end, - -- }, - }, - event = "BufReadPost", - opts = { - provider_selector = function() - return { "treesitter", "indent" } - end, - }, - init = function() - 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 - -- disabling since LazyVim already sets this nicely and it was overriding my diff fillchar - -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] - -- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself - vim.keymap.set("n", "zR", function() - require("ufo").openAllFolds() - end) - vim.keymap.set("n", "zM", function() - require("ufo").closeAllFolds() - end) - end, - }, - -- Folding preview, by default h and l keys are used. - -- On first press of h key, when cursor is on a closed fold, the preview will be shown. - -- On second press the preview will be closed and fold will be opened. - -- When preview is opened, the l key will close it and open fold. In all other cases these keys will work as usual. - { "anuvyklack/fold-preview.nvim", dependencies = "anuvyklack/keymap-amend.nvim", config = true }, -}