Skip to content

Commit

Permalink
Add nvim-ufo
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpaz committed Mar 4, 2024
1 parent 3853039 commit 0103323
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions lua/custom/plugins/nvim-ufo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
return {
{
'kevinhwang91/nvim-ufo',
event = 'BufRead',
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,
},
},
config = function()
-- default settings to enable
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.foldenable = true
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]

-- setup folding source: first lsp, then indent as fallback
require('ufo').setup {
provider_selector = function()
return { 'treesitter', 'indent' }
end,
}

-- remap keys for "fold all" and "unfold all"
vim.keymap.set('n', 'zR', require('ufo').openAllFolds, { desc = 'Open all folds' })
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds, { desc = 'Close all folds' })
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 },
}

0 comments on commit 0103323

Please sign in to comment.