Skip to content

Commit

Permalink
[LazyVim] Configure UFO for better folding
Browse files Browse the repository at this point in the history
  • Loading branch information
hposca committed May 2, 2023
1 parent 3955d94 commit fd9b5e3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LazyVim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,10 @@ map("n", "<leader>Ww", "<C-W>p", { desc = "Other window" })
map("n", "<leader>Wd", "<C-W>c", { desc = "Delete window" })
map("n", "<leader>W-", "<C-W>s", { desc = "Split window below" })
map("n", "<leader>W|", "<C-W>v", { desc = "Split window right" })

-- Improved Code Folding
map("n", "zR", require("ufo").openAllFolds, { desc = "Open all folds" })
map("n", "zM", require("ufo").closeAllFolds, { desc = "Close all folds" })
map("n", "zr", require("ufo").openFoldsExceptKinds, { desc = "Fold less" })
map("n", "zm", require("ufo").closeFoldsWith, { desc = "Fold more" })
map("n", "zp", require("ufo").peekFoldedLinesUnderCursor, { desc = "Peek fold" })
6 changes: 6 additions & 0 deletions LazyVim/lua/config/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ local opt = vim.opt

opt.clipboard = ""

opt.foldenable = true -- enable fold for nvim-ufo
opt.foldlevel = 99 -- set high foldlevel for nvim-ufo
opt.foldlevelstart = 99 -- start with all code unfolded
opt.foldcolumn = "1"
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]

-- VimWiki options
vim.cmd([[
let g:vimwiki_list = [{'path': '~/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}]
Expand Down
25 changes: 25 additions & 0 deletions LazyVim/lua/plugins/ufo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
return {
"kevinhwang91/nvim-ufo",
dependencies = {
"kevinhwang91/promise-async",
{
"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,
},
},
opts = {
provider_selector = function(bufnr, filetype, buftype)
return { "treesitter", "indent" }
end,
},
}

0 comments on commit fd9b5e3

Please sign in to comment.