Folding is added as per lazy config
This commit is contained in:
		
							parent
							
								
									b03ea9dd9b
								
							
						
					
					
						commit
						4fcc6399a5
					
				| 
						 | 
					@ -1,32 +1,35 @@
 | 
				
			||||||
return {
 | 
					return {
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
    "kevinhwang91/nvim-ufo",
 | 
					    "kevinhwang91/nvim-ufo",
 | 
				
			||||||
    event = { "User AstroFile", "InsertEnter" },
 | 
					    event = "BufRead",
 | 
				
			||||||
    dependencies = { "kevinhwang91/promise-async" },
 | 
					    dependencies = {
 | 
				
			||||||
    opts = {
 | 
					      { "kevinhwang91/promise-async" },
 | 
				
			||||||
      preview = {
 | 
					      {
 | 
				
			||||||
        mappings = {
 | 
					        "luukvbaal/statuscol.nvim",
 | 
				
			||||||
          scrollB = "<C-b>",
 | 
					        config = function()
 | 
				
			||||||
          scrollF = "<C-f>",
 | 
					          local builtin = require("statuscol.builtin")
 | 
				
			||||||
          scrollU = "<C-u>",
 | 
					          require("statuscol").setup({
 | 
				
			||||||
          scrollD = "<C-d>",
 | 
					            -- foldfunc = "builtin",
 | 
				
			||||||
        },
 | 
					            -- setopt = true,
 | 
				
			||||||
 | 
					            relculright = true,
 | 
				
			||||||
 | 
					            segments = {
 | 
				
			||||||
 | 
					              { text = { builtin.foldfunc }, click = "v:lua.ScFa" },
 | 
				
			||||||
 | 
					              { text = { "%s" }, click = "v:lua.ScSa" },
 | 
				
			||||||
 | 
					              { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					          })
 | 
				
			||||||
 | 
					        end,
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      provider_selector = function(_, filetype, buftype)
 | 
					 | 
				
			||||||
        local function handleFallbackException(bufnr, err, providerName)
 | 
					 | 
				
			||||||
          if type(err) == "string" and err:match "UfoFallbackException" then
 | 
					 | 
				
			||||||
            return require("ufo").getFolds(bufnr, providerName)
 | 
					 | 
				
			||||||
          else
 | 
					 | 
				
			||||||
            return require("promise").reject(err)
 | 
					 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
        end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return (filetype == "" or buftype == "nofile") and "indent" -- only use indent until a file is opened
 | 
					 | 
				
			||||||
          or function(bufnr)
 | 
					 | 
				
			||||||
            return require("ufo")
 | 
					 | 
				
			||||||
              .getFolds(bufnr, "lsp")
 | 
					 | 
				
			||||||
              :catch(function(err) return handleFallbackException(bufnr, err, "treesitter") end)
 | 
					 | 
				
			||||||
              :catch(function(err) return handleFallbackException(bufnr, err, "indent") end)
 | 
					 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
      end,
 | 
					 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  }
 | 
					    config = function()
 | 
				
			||||||
 | 
					      -- Fold options
 | 
				
			||||||
 | 
					      vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
 | 
				
			||||||
 | 
					      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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      require("ufo").setup()
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue