Nvim: add ufo fold plugin

This commit is contained in:
Marko Korhonen 2023-09-20 16:23:52 +03:00
parent bf072046bf
commit af6c34baaa
Signed by: FunctionalHacker
GPG key ID: A7F78BCB859CD890
5 changed files with 32 additions and 1 deletions

View file

@ -212,6 +212,13 @@ local plugins = {
config = require("plugins.dashboard"),
dependencies = { { "kyazdani42/nvim-web-devicons" } },
},
-- Better folds
{
"kevinhwang91/nvim-ufo",
dependencies = { "kevinhwang91/promise-async" },
config = require("plugins.ufo"),
},
}
local lazy_opts = {}

View file

@ -12,6 +12,13 @@ function m.setup()
-- Inform lsp about completion capabilities from cmp
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Neovim hasn't added foldingRange to default capabilities, users must add it manually
-- for ufo
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
require("mason").setup()
local mason_lsp = require("mason-lspconfig")
mason_lsp.setup()

View file

@ -0,0 +1,7 @@
return function()
require("ufo").setup({
close_fold_kinds = {
"imports",
},
})
end

View file

@ -17,4 +17,8 @@ return function()
-- Exit terminal insert mode with esc
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", {})
-- Using ufo, need to remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
end

View file

@ -49,10 +49,16 @@ o.shiftwidth = 4
o.smartindent = true
-- Firenvim settings
vim.g.firenvim_config = {
g.firenvim_config = {
localSettings = {
[".*"] = {
takeOver = "never",
},
},
}
-- Fold settings (for ufo)
o.foldcolumn = "1"
o.foldlevel = 99
o.foldlevelstart = 99
o.foldenable = true