kickstart.nvim/lua/custom/plugins/init.lua

45 lines
1.4 KiB
Lua

-- You can add your own plugins here or in other files in this directory!
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {
-- Add this section for nvim-ufo and its dependencies
{
'kevinhwang91/nvim-ufo',
dependencies = {
'kevinhwang91/promise-async',
'nvim-treesitter/nvim-treesitter',
},
config = function()
-- Enable fold column
vim.o.foldcolumn = '1'
-- Set fold level to 99 (effectively expanding all folds)
vim.o.foldlevel = 99
-- Start with all folds expanded
vim.o.foldlevelstart = 99
-- Use nvim-ufo provider
vim.o.foldenable = true
-- Using ufo provider need remap `zR` and `zM`
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
vim.keymap.set('n', 'zm', require('ufo').closeFoldsWith) -- closeAllFolds == closeFoldsWith(0)
vim.keymap.set('n', 'K', function()
local winid = require('ufo').peekFoldedLinesUnderCursor()
if not winid then
-- choose one of coc.nvim and nvim lsp
vim.fn.CocActionAsync 'definitionHover' -- coc.nvim
vim.lsp.buf.hover()
end
end)
-- Configure UFO
require('ufo').setup {
provider_selector = function(bufnr, filetype, buftype)
return { 'treesitter', 'indent' }
end,
}
end,
},
}