neovim-config/lua/plugins/folding.lua

65 lines
2.2 KiB
Lua
Raw Normal View History

2023-12-01 20:26:02 +00:00
return {
-- add folding range to capabilities
{
"neovim/nvim-lspconfig",
opts = {
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,
-- },
},
2023-12-01 20:26:02 +00:00
event = "BufReadPost",
opts = {
provider_selector = function()
return { "treesitter", "indent" }
end,
},
2023-12-01 20:26:02 +00:00
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
2024-05-21 03:58:39 +00:00
-- disabling since LazyVim already sets this nicely and it was overriding my diff fillchar
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
2023-12-01 20:26:02 +00:00
-- 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 },
2023-12-01 20:26:02 +00:00
}