Git Product home page Git Product logo

nvim-ufo's Introduction

nvim-ufo

The goal of nvim-ufo is to make Neovim's fold look modern and keep high performance.

ufo-demo.mp4

setup foldcolumn like demo


Table of contents

Features

  • Penetrate color for folded lines like other modern editors/IDEs
  • Never block Neovim
  • Adding folds high accuracy with Folding Range in LSP
  • Support fallback and customize strategy for fold provider
  • Peek folded line and jump the desired location with less redraw

Quickstart

Requirements

Installation

Install with Packer.nvim:

use {'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'}

Minimal configuration

use {'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'}

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

-- Using ufo provider need 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)

-- Option 1: coc.nvim as LSP client
use {'neoclide/coc.nvim', branch = 'master', run = 'yarn install --frozen-lockfile'}
require('ufo').setup()
--

-- Option 2: nvim lsp as LSP client
-- Tell the server the capability of foldingRange,
-- Neovim hasn't added foldingRange to default capabilities, users must add it manually
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = {
    dynamicRegistration = false,
    lineFoldingOnly = true
}
local language_servers = require("lspconfig").util.available_servers() -- or list servers manually like {'gopls', 'clangd'}
for _, ls in ipairs(language_servers) do
    require('lspconfig')[ls].setup({
        capabilities = capabilities
        -- you can add other fields for setting up lsp server in this table
    })
end
require('ufo').setup()
--

-- Option 3: treesitter as a main provider instead
-- (Note: the `nvim-treesitter` plugin is *not* needed.)
-- ufo uses the same query files for folding (queries/<lang>/folds.scm)
-- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()`
require('ufo').setup({
    provider_selector = function(bufnr, filetype, buftype)
        return {'treesitter', 'indent'}
    end
})
--

-- Option 4: disable all providers for all buffers
-- Not recommend, AFAIK, the ufo's providers are the best performance in Neovim
require('ufo').setup({
    provider_selector = function(bufnr, filetype, buftype)
        return ''
    end
})

Usage

Use fold as usual.

Using a provider of ufo, must set a large value for foldlevel, this is the limitation of foldmethod=manual. A small value may close fold automatically if the fold ranges updated.

After running zR and zM normal commands will change the foldlevel, ufo provide the APIs openAllFolds/closeAllFolds to open/close all folds but keep foldlevel value, need to remap them.

Like zR and zM, if you used zr and zm before, please use closeFoldsWith API to close folds like set foldlevel=n but keep foldlevel value.

Documentation

How does nvim-ufo get the folds?

If ufo detect foldmethod option is not diff or marker, it will request the providers to get the folds, the request strategy is formed by the main and the fallback. The default value of main is lsp and the default value of fallback is indent which implemented by ufo.

For example, Changing the text in a buffer will request the providers for folds.

foldmethod option will finally become manual if ufo is working.

Setup and description

{
    open_fold_hl_timeout = {
        description = [[Time in millisecond between the range to be highlgihted and to be cleared
                    while opening the folded line, `0` value will disable the highlight]],
        default = 400
    },
    provider_selector = {
        description = [[A function as a selector for fold providers. For now, there are
                    'lsp' and 'treesitter' as main provider, 'indent' as fallback provider]],
        default = nil
    },
    close_fold_kinds_for_ft = {
        description = [[After the buffer is displayed (opened for the first time), close the
                    folds whose range with `kind` field is included in this option. For now,
                    'lsp' provider's standardized kinds are 'comment', 'imports' and 'region'.
                    This option is a table with filetype as key and fold kinds as value. Use a
                    default value if value of filetype is absent.
                    Run `UfoInspect` for details if your provider has extended the kinds.]],
        default = {default = {}}
    },
    fold_virt_text_handler = {
        description = [[A function customize fold virt text, see ### Customize fold text]],
        default = nil
    },
    enable_get_fold_virt_text = {
        description = [[Enable a function with `lnum` as a parameter to capture the virtual text
                    for the folded lines and export the function to `get_fold_virt_text` field of
                    ctx table as 6th parameter in `fold_virt_text_handler`]],
        default = false
    },
    preview = {
        description = [[Configure the options for preview window and remap the keys for current
                    buffer and preview buffer if the preview window is displayed.
                    Never worry about the users's keymaps are overridden by ufo, ufo will save
                    them and restore them if preview window is closed.]],
        win_config = {
            border = {
                description = [[The border for preview window,
                    `:h nvim_open_win() | call search('border:')`]],
                default = 'rounded',
            },
            winblend = {
                description = [[The winblend for preview window, `:h winblend`]],
                default = 12,
            },
            winhighlight = {
                description = [[The winhighlight for preview window, `:h winhighlight`]],
                default = 'Normal:Normal',
            },
            maxheight = {
                description = [[The max height of preview window]],
                default = 20,
            }
        },
        mappings = {
            description = [[The table for {function = key}]],
            default = [[see ###Preview function table for detail]],
        }
    }
}

:h ufo may help you to get the all default configuration.

Preview function table

Function Action Def Key
scrollB Type CTRL-B in preview window
scrollF Type CTRL-F in preview window
scrollU Type CTRL-U in preview window
scrollD Type CTRL-D in preview window
scrollE Type CTRL-E in preview window <C-E>
scrollY Type CTRL-Y in preview window <C-Y>
jumpTop Jump to top region in preview window
jumpBot Jump to bottom region in preview window
close In normal window: Close preview window
In preview window: Close preview window
q
switch In normal window: Go to preview window
In preview window: Go to normal window
<Tab>
trace In normal window: Trace code based on topline
In preview window: Trace code based on cursor
<CR>

Additional mouse supported:

  1. <ScrollWheelUp> and <ScrollWheelDown>: Scroll preview window.
  2. <2-LeftMouse>: Same as trace action in preview window.

trace action will open all fold for the folded lines

Commands

Command Description
UfoEnable Enable ufo
UfoDisable Disable ufo
UfoInspect Inspect current buffer information
UfoAttach Attach current buffer to enable all features
UfoDetach Detach current buffer to disable all features
UfoEnableFold Enable to get folds and update them at once for current buffer
UfoDisableFold Disable to get folds for current buffer

API

ufo.lua

Highlight groups

" hi default UfoFoldedFg guifg=Normal.foreground
" hi default UfoFoldedBg guibg=Folded.background
hi default link UfoPreviewSbar PmenuSbar
hi default link UfoPreviewThumb PmenuThumb
hi default link UfoPreviewWinBar UfoFoldedBg
hi default link UfoPreviewCursorLine Visual
hi default link UfoFoldedEllipsis Comment
hi default link UfoCursorFoldedLine CursorLine
  • UfoFoldedFg: Foreground for raw text of folded line.
  • UfoFoldedBg: Background of folded line.
  • UfoPreviewSbar: Scroll bar of preview window, only take effect if the border is missing right horizontal line, like border = 'none'.
  • UfoPreviewCursorLine: Highlight current line in preview window if it isn't the start of folded lines.
  • UfoPreviewWinBar: Virtual winBar of preview window.
  • UfoPreviewThumb: Thumb of preview window.
  • UfoFoldedEllipsis: Ellipsis at the end of folded line, invalid if fold_virt_text_handler is set.
  • UfoCursorFoldedLine: Highlight the folded line under the cursor

Advanced configuration

Configuration can be found at example.lua

Customize configuration

local ftMap = {
    vim = 'indent',
    python = {'indent'},
    git = ''
}
require('ufo').setup({
    open_fold_hl_timeout = 150,
    close_fold_kinds_for_ft = {
        default = {'imports', 'comment'},
        json = {'array'},
        c = {'comment', 'region'}
    },
    preview = {
        win_config = {
            border = {'', '', '', '', '', '', '', ''},
            winhighlight = 'Normal:Folded',
            winblend = 0
        },
        mappings = {
            scrollU = '<C-u>',
            scrollD = '<C-d>',
            jumpTop = '[',
            jumpBot = ']'
        }
    },
    provider_selector = function(bufnr, filetype, buftype)
        -- if you prefer treesitter provider rather than lsp,
        -- return ftMap[filetype] or {'treesitter', 'indent'}
        return ftMap[filetype]

        -- refer to ./doc/example.lua for detail
    end
})
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
vim.keymap.set('n', 'zr', require('ufo').openFoldsExceptKinds)
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)

Customize fold text

Adding number suffix of folded lines instead of the default ellipsis, here is the example:

local handler = function(virtText, lnum, endLnum, width, truncate)
    local newVirtText = {}
    local suffix = (' 󰁂 %d '):format(endLnum - lnum)
    local sufWidth = vim.fn.strdisplaywidth(suffix)
    local targetWidth = width - sufWidth
    local curWidth = 0
    for _, chunk in ipairs(virtText) do
        local chunkText = chunk[1]
        local chunkWidth = vim.fn.strdisplaywidth(chunkText)
        if targetWidth > curWidth + chunkWidth then
            table.insert(newVirtText, chunk)
        else
            chunkText = truncate(chunkText, targetWidth - curWidth)
            local hlGroup = chunk[2]
            table.insert(newVirtText, {chunkText, hlGroup})
            chunkWidth = vim.fn.strdisplaywidth(chunkText)
            -- str width returned from truncate() may less than 2nd argument, need padding
            if curWidth + chunkWidth < targetWidth then
                suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
            end
            break
        end
        curWidth = curWidth + chunkWidth
    end
    table.insert(newVirtText, {suffix, 'MoreMsg'})
    return newVirtText
end

-- global handler
-- `handler` is the 2nd parameter of `setFoldVirtTextHandler`,
-- check out `./lua/ufo.lua` and search `setFoldVirtTextHandler` for detail.
require('ufo').setup({
    fold_virt_text_handler = handler
})

-- buffer scope handler
-- will override global handler if it is existed
-- local bufnr = vim.api.nvim_get_current_buf()
-- require('ufo').setFoldVirtTextHandler(bufnr, handler)

Feedback

  • If you get an issue or come up with an awesome idea, don't hesitate to open an issue in github.
  • If you think this plugin is useful or cool, consider rewarding it a star.

License

The project is licensed under a BSD-3-clause license. See LICENSE file for details.

nvim-ufo's People

Contributors

aileot avatar anuvyklack avatar kevinhwang91 avatar masaeedu avatar milisims avatar mrcjkb avatar rayjameson avatar stevanmilic avatar tauon avatar ucchiee avatar wookayin avatar xiyaowong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-ufo's Issues

Include the bottom line inside a fold

Feature description

In editors like intellij or simply using a custom fold text in vim, it is possible to include the bottom like as part of a fold like in the screenshot below

image

Note that the trailing } is displayed as part of the {...} on the folded line rather than below it on a new line.

Describe the solution you'd like

As described above it would be nice if a user could include the closing item e.g. the closing parentheses as part of a fold rather than trailing outside of it e.g.

// Desired outcome
function testThing() {...} // The closing parens are on the same line as the fold.

// Current state
function testThing() { ...
}

This would also allow something like

import {...} from "thing"

by using whatever the trailing content of the last fold line is appended to the fold text

Additional context

No response

Error when starting neovim whilst restoring a session

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+2060-g0f1b17788

Operating system/version

macOS 12.4

How to reproduce the issue

cat mini.lua

-- Use Vim packages install the plugin, also work with some plugins manager such as packer.nvim
vim.o.packpath = '~/.local/share/nvim/site'
vim.cmd('packadd promise-async')
vim.cmd('packadd nvim-ufo')
vim.cmd('packadd auto-session')

-- Setting
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = -1
vim.o.foldenable = true

local ufo = require('ufo')
ufo.setup()
vim.keymap.set('n', 'zR', ufo.openAllFolds)
vim.keymap.set('n', 'zM', ufo.closeAllFolds)

require('auto-session').setup()

nvim --clean -u mini.lua

  1. Open nvim in a directory and open some files in nvim
  2. Close nvim with some files open (this will create the session on vim leave)
  3. Reopen neovim in the same directory, see error
    ...

Expected behavior

Since the most recent commit, 8cf1259 when I re-open neovim with a session autoloaded using the https://github.com/rmagatti/auto-session plugin. I encounter the bug described below about the invalid buffer id: 1 I think when restarting a session, some buffers are deleted really quickly before the session restarts.

Actual behavior

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:                                                                                                           
...site/pack/packer/start/nvim-ufo/lua/ufo/model/buffer.lua:17: Invalid buffer id: 1 

UnhandledPromiseRejection with the reason: ufo/provider/lsp.lua:61: service not started

Neovim version (nvim -v | head -n1)

NVIM v0.7.2

Operating system/version

archlinux

How to reproduce the issue

Install Coc & setup ufo with:

local ufo = require('ufo')

ufo.setup({
  open_fold_hl_timeout = 0,
})

vim.keymap.set('n', 'zr', ufo.openAllFolds)
vim.keymap.set('n', 'zm', ufo.closeAllFolds)

Then do some work, and at some point the following message keeps appearing at every 5 seconds (triggered by many actions, such as write file, or cursor movement):

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:                                                                                                                                
...vim/site/pack/packer/start/nvim-ufo/lua/ufo/provider.lua:51: ...site/pack/packer/start/nvim-ufo/lua/ufo/provider/lsp.lua:61: service not started 
...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/fold.lua:89: in function <Anonymous:70>

No ufo.log found.

Expected behavior

No error.

Actual behavior

Error.

Single-line folds aren't handled

Neovim version (nvim -v | head -n1)

0.8.0-dev

Operating system/version

archlinux

How to reproduce the issue

Open a file with single line folds and close all folds.

local dict = {
    a = 1,
    b = {
        c = 2,
    },
    d = { e = 3 }
}

Expected behavior

All folds use the ufo style.

Actual behavior

image

[Bug] Searching within a fold closes it

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+1941-gb7084fef4

Operating system/version

macOS 12.4

How to reproduce the issue

  1. Use the following init.lua via nvim -u <minimal-init> --no-plugin <file-with-folds>
vim.cmd("packadd! nvim-ufo")

vim.opt.termguicolors = true
vim.opt.foldlevelstart = 2
vim.opt.foldenable = true

require("ufo").setup()
  1. go to a closed fold, open it with zo
  2. search for any item within the fold using either :call search('thing') or /thing<CR>
  3. Fold is closed

Expected behavior

Searching inside a folded area should not cause the fold to be closed

Actual behavior

Searching inside a folded area causes the fold to close back up

nvim-ufo-bug.mov

Enhance `zC` and `zO`

Feature description

Sometimes it's too unexpected while typing zC and zO.

Describe the solution you'd like

Use a selector with a preview based on foldlevel to show the result.

Additional context

No response

Namespace conflict with notomo/promise.nvim

Neovim version (nvim -v | head -n1)

0.8.0-dev

Operating system/version

archlinux

How to reproduce the issue

  1. Install the plugin, including the minimal configuration, with coc-nvim
  2. Start neovim

Expected behavior

Plugin works

Actual behavior

There are a few issues, first one is:

Error executing vim.schedule lua callback: unhandled promise rejection: { "/home/romgrk/.config/nvim/bundle/nvim-ufo/lua/ufo/utils.lua:110: attempt to call a table value" }
stack traceback:
        [C]: in function 'error'
        ...rk/.config/nvim/bundle/promise.nvim/lua/promise/init.lua:65: in function <...rk/.config/nvim/bundle/promise.nvim/lua/promise/init.lua:63>

It is solved by add require('promise').new(...) here:

return require('promise')(function(resolve)

The second issue (after fixing the one above) is:

Error detected while processing BufWritePost Autocommands for "*":
E5108: Error executing lua /home/romgrk/.config/nvim/bundle/nvim-ufo/lua/ufo/fold.lua:201: attempt to call method 'thenCall' (a nil value)
stack traceback:
        /home/romgrk/.config/nvim/bundle/nvim-ufo/lua/ufo/fold.lua:201: in function 'listener'
        /home/romgrk/.config/nvim/bundle/nvim-ufo/lua/ufo/event.lua:52: in function 'emit'

Error on opening saved session

Neovim version (nvim -v | head -n1)

head

Operating system/version

macOS 12.4

How to reproduce the issue

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:
...site/pack/packer/start/nvim-ufo/lua/ufo/fold/manager.lua:141: Vim(foldopen):E490: No fold found
stack traceback:
        ...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/fold.lua:44: in function <Anonymous:25>

I'm getting this error when using the plugin with auto-session plugin, looks like some folds cannot be restored after entering session.

Expected behavior

  1. save session
  2. exit nvim
  3. enter nvim
  4. no error appear

Actual behavior

  1. save session
  2. exit nvim
  3. enter nvim
  4. the reported error appears

NOTE: The error doesn't happen always, and I can't understand why it fails sometimes.

(Example) Show last line of the folded region for treesitter provider

Feature description

Since lsp provider folds differently than the treesitter parser, showing the last line of the folded region for treesitter can be helpful.

I have written an example configuration that sets the virtual_text handler to set the last line, and uses some internal functions to use default highlights for the displayed line.

Note: This is a personal/opinionated example, the users's tastes may differ, but this example could be used as a guide to creating your own virt-text-handler

Another note: using this snippet for lsp or indent provider wont break it but would be very redundant and cluttered, so its not recommended

Describe the solution you'd like

Edit/use this snippet in advanced_configuration example section

local function set_end_lines(bufnr, text, lnum, end_lnum)
    local current_buf_folds = require("ufo.fold.buffer").pool[bufnr]
    local nss = {}
    for _, ns in pairs(vim.api.nvim_get_namespaces()) do
        if require("ufo.decorator").ns ~= ns then
            table.insert(nss, ns)
        end
    end

    local syntax = vim.bo[bufnr].syntax ~= ""
    local winid = vim.api.nvim_get_current_win()
    local wininfo = vim.fn.getwininfo(winid)[1]
    local width = vim.api.nvim_win_get_width(winid) - wininfo.textoff

    local virt_text = require("ufo.render").getVirtText(bufnr, text, width, end_lnum, syntax, nss)

    if not vim.tbl_isempty(current_buf_folds.foldedLines) and current_buf_folds.foldedLines[lnum] ~= nil then
        vim.api.nvim_buf_set_extmark(current_buf_folds.bufnr, current_buf_folds.ns, lnum - 1, 0, {
            id = current_buf_folds.foldedLines[lnum].id,
            end_row = lnum - 1,
            end_col = 0,
            virt_text = virt_text,
            virt_text_win_col = 0,
            priority = 10,
            hl_mode = "combine",
        })
    end

    return virt_text
end

local function handler(virt_text, lnum, end_lnum, width, truncate)
    local result = {}

    local counts = ("    %d    "):format(end_lnum - lnum)
    local suffix = " ⋯⋯  "
    local padding = ""

    local bufnr = vim.api.nvim_get_current_buf()
    local end_text = vim.api.nvim_buf_get_lines(bufnr, end_lnum - 1, end_lnum, false)[1]
    local end_virt_text = set_end_lines(bufnr, end_text, lnum, end_lnum)

    local sufWidth = (2 * vim.fn.strdisplaywidth(suffix)) + vim.fn.strdisplaywidth(counts)
    for _, v in ipairs(end_virt_text) do
        sufWidth = sufWidth + vim.fn.strdisplaywidth(v[1])
    end

    local target_width = width - sufWidth
    local cur_width = 0

    for _, chunk in ipairs(virt_text) do
        local chunk_text = chunk[1]

        local chunk_width = vim.fn.strdisplaywidth(chunk_text)
        if target_width > cur_width + chunk_width then
            table.insert(result, chunk)
        else
            chunk_text = truncate(chunk_text, target_width - cur_width)
            local hl_group = chunk[2]
            table.insert(result, { chunk_text, hl_group })
            chunk_width = vim.fn.strdisplaywidth(chunk_text)

            if cur_width + chunk_width < target_width then
                padding = padding .. (" "):rep(target_width - cur_width - chunk_width)
            end
            break
        end
        cur_width = cur_width + chunk_width
    end

    table.insert(result, { suffix, "UfoFoldedEllipsis" })
    table.insert(result, { counts, "MoreMsg" })
    table.insert(result, { suffix, "UfoFoldedEllipsis" })

    for _, v in ipairs(end_virt_text) do
        table.insert(result, v)
    end

    table.insert(result, { padding, "" })

    return result
end

require("ufo").setup {
  -- your other config
  fold_virt_text_handler = handler,
end

Additional context

Some examples
folds1

folds2

High level folded line may disapear if fold ranges updated

Neovim version (nvim -v | head -n1)

master

Operating system/version

ArchLinux

How to reproduce the issue

local function level1()
    local function level2()

    end
end
  1. 2ggzczc
  2. O and insert a new function become
local function name()
    
end
local function level1()
    local function level2()

    end
end
  1. Go to level1 and type zo
  2. level2 is opened.

Expected behavior

level2 keep closed

Actual behavior

level2 is opened

Syntax highlighting on folds

Neovim version (nvim -v | head -n1)

v0.8.0-dev+513-g01fc5097d

Operating system/version

macOS 12.4

How to reproduce the issue

  1. Open file and syntax highlighting does not penetrate folds.
  2. :TSBufDisable highlight
  3. Open/close folds to refresh and highlighting appears.

Expected behavior

Syntax highlighting on folds while using treesitter highlighting.

Actual behavior

Highlighting only shows up after disabling treesitter highlighting and using regex i.e. :TSBufDisable highlight

Disable UFO in certain buffer types

Feature description

Using something like a disabled table in the configuration function, one should be able to disable nvim-ufo in certain buffer types. An example of where this is useful is .org documents. The nvim-orgmode/orgmode plugin has built in fold support, but nvim-ufo overrides that with incorrect behaviour (intent based). The ability to disable it in certain buffer types would allow for the best of both worlds.

One distinction is that when switching to another buffer of a different type, nvim-ufo should be able to work again.

Describe the solution you'd like

Something similar to how LSP servers handle enabling and disabling filetypes would be best. An example configuration would be something like:

require('ufo').setup({
    open_fold_h1_timeout = 100,
    disabled = { 'org' },
})

Additional context

No response

Customize folding using different source

Feature description

Would be great to provide an API and allow the binding of different folding expressions. One scenario is a very large (auto-generated) code (100k ~ 200k LOC per file) I am using.

Describe the solution you'd like

e.g.

if filetype = 'go' then
  if  filesize < 6M then
   api.nvim_win_set_option(current_window, 'foldexpr', 'ufo#foldexpr()')
  elseif  filesize < 10M then
   api.nvim_win_set_option(current_window, 'foldexpr', 'tsfold#foldexpr()')
  else
   api.nvim_win_set_option(current_window, 'foldexpr', 'tsfold#foldexpr()')
  end
end
if filetype = 'lua' then
  api.nvim_win_set_option(current_window, 'foldexpr', 'treesitter#foldexpr()')
end

Additional context

No response

zm and zr not working?

Neovim version (nvim -v | head -n1)

0.7

Operating system/version

Arch Linux

How to reproduce the issue

Pressing zm and zr

Expected behavior

Close / Open all folds by 1 level.

Actual behavior

Nothing happens.

Using ufo zR and zM works fine, but not zm and zr, they just do nothing.

vim.keymap.set("n", "zR", require("ufo").openAllFolds)
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)

`loadview` only restores visible folds

Neovim version (nvim -v | head -n1)

NVIM v0.7.2

Operating system/version

ArchLinux latest

How to reproduce the issue

cat mini.lua

local create_autocmd = vim.api.nvim_create_autocmd
local create_augroup = vim.api.nvim_create_augroup

vim.o.packpath = "~/.local/share/nvim/site"
vim.cmd("packadd promise-async")
vim.cmd("packadd nvim-ufo")

-- Setting
vim.o.foldcolumn = "1"
vim.o.foldlevel = 99
vim.o.foldlevelstart = -1
vim.o.foldenable = true

local ufo = require("ufo")
ufo.setup()
vim.keymap.set("n", "zR", ufo.openAllFolds)
vim.keymap.set("n", "zM", ufo.closeAllFolds)

local saveAndLoadViews = create_augroup("saveAndLoadViews", { clear = true })
create_autocmd("BufLeave", {
	pattern = "*.*",
	command = "mkview",
	group = saveAndLoadViews,
	desc = "Save view on leaving buffer",
})
create_autocmd("BufEnter", {
	pattern = "*.*",
	command = "silent! loadview",
	group = saveAndLoadViews,
	desc = "Load view on entering buffer",
})

nvim --clean -u mini.lua some-file.ext

  1. open a file which contains a number of fold
  2. close some folds
  3. move the cursor so that some closed folds are off screen/invisible
  4. close neovim
  5. open file again
  6. scroll to look at the (previously) closed folds off screen
    ...

(NOTE: the bug does not seem to happen when opening a file with :e from within neovim)

Expected behavior

I use some autocmds to save and restore views and in particular folds (see above mini.lua). I would like all folds to be restored when opening a file again.

Actual behavior

Only visible folds (that aren't off screen) are restored. All folds that are above or below what's currently visible on screen are fully opened.

Thanks for the great plugin! This has been something I've been missing for a while. I'm especially happy that it also gets rid of some annoying bugs in neovim's treesitter fold handling!

[Enhancement] Integrate with indent-blankline.nvim or provide an API for an integration

Feature description

Hi,

Thanks for your work on this plugin, it's the first time in many years of using (neo)vim that I've ever had normal looking folds 🚀.

One thing that using folds more has re-introduced for me though is the gaps appearing between my indent lines. The plugin https://github.com/lukas-reineke/indent-blankline.nvim fixes this limitation in normal lines by using extmarks to draw the indent lines and cover the gaps that exist in conceal based solutions.

With this plugin enabled, though, these extmarks are no longer visible and folded section introduce gaps between my indent lines.

Describe the solution you'd like

I don't know how this plugin is designed i.e. extmarks (most likely I think) or floating windows, but I'm wondering if there's some chance of either blending the extmarks not sure if this could work or if it's possible to query for the existing indent lines (extmarks) via nvim_buf_get_extmarks and re-apply/add them to the extmarks this plugin creates and if it's via floating window then it should already be working.

If it isn't entirely easy or possible on this side then maybe the author of that plugin would be willing to provide an API to get the indents for a line so they can be prepended to the fold text. I'm happy to ask if you are amenable but I don't really know how this is structured and what approach would make sense

Additional context

Example in vscode with indents extending beyond folds (I know vscode is rarely 100% applicable, I just meant for reference of what the desired result looks like)

image

Unfolded indents across blank lines

image

Current indent lines across folds

image

Error when call `setFoldVirtTextHandler`

Neovim version (nvim -v | head -n1)

NVIM 0.7.2

Operating system/version

Fedora 36

How to reproduce the issue

Add next line inside ~/.config/nvim/after/ftplugin/lua.lua

require('ufo').setFoldVirtTextHandler(nil, handler)

Expected behavior

no error

Actual behavior

E5113: Error while calling lua chunk: ...re/nvim/site/pack/packer/start/ufo/lua/ufo/decorator.lua:180: 
attempt to index field 'virtTextHandlers' (a nil value)
stack traceback:
        ...re/nvim/site/pack/packer/start/ufo/lua/ufo/decorator.lua:180: in function 'setVirtTextHandler'
        ....local/share/nvim/site/pack/packer/start/ufo/lua/ufo.lua:150: in function 'setFoldVirtTextHandler'

Index out of bounds

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+608-g778541067-dirty

Operating system/version

wsl2 Arch

How to reproduce the issue

  1. cd neovim && nvim runtime/lua/vim/lsp/codelens.lua
  2. input za to trigger a fold

note thant it must use lua language server to reproduce.

Expected behavior

Get correct folded result

Actual behavior

There is a 0 with some buf info in screen.
image

Strange foldtext suffix with tree-sitter

Neovim version (nvim -v | head -n1)

head

Operating system/version

macOS 12.4

How to reproduce the issue

image

I'm getting this strange output from time-to-time with tree-sitter provider. I'm not entirely sure if it's related to that provider only, since that's the only I'm using tho. Reloading the buffer makes the folded text correct again.

Expected behavior

For fold text to not have occasional strange suffix.

Actual behavior

Fold text sometimes gets buggy.

Treesitter provider gets wrong highlights

Neovim version (nvim -v | head -n1)

NVIM v0.7.2

Operating system/version

macOS 11.5

How to reproduce the issue

I use the Treesitter provider with my own highlight definitions and not a colour scheme. When I close the fold not all of the nodes seem to get recognised correctly.

Expected behavior

The colour of the folded text gets displayed correctly

Actual behavior

This is the unfolded text:
Captura de Tela 2022-07-16 às 23 07 18

and then here is the top line while folded:
Captura de Tela 2022-07-16 às 23 07 26

Support for Vim's foldmarkers

Feature description

Currently, while using this plugin, you can't use the fold markers you created previously. I'd like to have the possibility to use Vim's basic fold method, the manual one using the fold markers.

Describe the solution you'd like

The solution I'm proposing is to just replicate the original Vim foldmarker support while also having the advanced functionality of this plugin available.

Additional context

Some helpful stuff:

  1. The currently set fold markers can be used inside Lua by reading the options (yes, they're stored inside an array):
local fmrOpen  = vim.opt.foldmarker:get()[1]
local fmrClose = vim.opt.foldmarker:get()[2]

This will read the foldmarkers that are set by anything: be it user configuration, a plugin, the modeline etc.

  1. Vim actually doesn't care if the foldmarkers are part of the code, or if they're inside comments (a good example is this), it just searches for the foldmarkers wherever it finds them in the buffer. This usually gets solved by using different foldmarkers, but, if you don't want this to happen at all and want to go the approach that foldmarkers should be only inside comments, you could also do some matching with the code's comment string, but this isn't perfect.
local commentString = vim.opt.commentstring:get()

Why isn't it perfect? Well, it renders pretty different results. Take a couple of examples (%s is a placeholder for the comment)

  • The commentstring for Lua is --%s (this example is expectable)
  • The commentstring for C/C++ is /*%s*/ (for C/C++, it's apparently a multi-line comment, even though there's a single-line comment too)
  • The commmentstring for Python is # %s (yes, with a space, even though Python doesn't require that space for comments)

So, using the commentstring isn't perfect, and it requires a bit more work. I just recommend going the Vim way and matching the foldmarkers wherever they appear in the text, I think it's the better way.

Line under fold is eaten up with a keybinding

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+457-g6d52a29c3

Operating system/version

Linux archbox 5.18.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 16 Jun 2022 20:40:45 +0000 x86_64 GNU/Linux

How to reproduce the issue

Whenever using UFO, the normal fold keybindings work just fine; however, a keybinding like this does not:

-- This is meant to toggle a fold (i.e., open if it is closed, close if it is open)
map("n", "z;", "@=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>", {silent = true})

Something else that is similar that also doesn't work is this:

-- File: lua/plugs/fold.lua
M.open_fold = function()
    if fn.foldclosed(".") == -1 then
        ex.foldclose()
    else
        while fn.foldclosed(".") ~= -1 do
            ex.foldopen()
        end
    end
end

map("n", "z,", ":lua require('plugs.fold').open_fold()<CR>")

Go to any fold and press z;

Expected behavior

The expected behavior is for the keybinding z; to open the fold after it closes it.

Actual behavior

What ends up happening is that the line under the fold gets 'eaten' up and brought into the fold that is under the cursor. Here is a video showing what it does. I press zc, zo, z;, z;, z; (the keybinding above). The z; also seems to turn every single line into a fold.

cut

I'm unsure if this is specific to my configuration or not. I have found that the issue is with this autocmd:

au CmdlineLeave * lua require('ufo.event').emit('CmdlineLeave')

I also have anyfold installed. When the fold starts to get 'eaten', if I run AnyFoldActivate, it resets the folds and prevents the issue as mentioned above. Then the keybinding z; will work just fine.

A way to solve this is to add a return statement after line 125 in ufo/fold.lua.

debounced:flush()

I'm doubt this is the correct way to solve this issue, but it does seem to work for my problem and I haven't ran into anything else yet.

Regression: saving buffer will affect folding

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+1856-g58323b1fe

Operating system/version

macOS 12

How to reproduce the issue

  1. Open some fold manually (with zr, etc.) while &foldlevel remaining unchanged
  2. Save the buffer, e.g., :w

nvim-ufo config is quite minimal, e.g.,

  require 'ufo'.setup {
    open_fold_hl_timeout = 150,
  }

FYI, the file I was working on is a python file where foldmethod=expr.

Expected behavior

All open/close folds should remain intact and untouched. This would include all folds that were manually opened or closed. This behavior was fine in d99d722.

Actual behavior

Bug: Folds will close (or open) as per the &foldlevel variable.

After doing git bisect, I think the first commit that breaks the behavior is d0bf0cb.

Unhandled exception when opening different file type.

Neovim version (nvim -v | head -n1)

nvim v0.7.0

Operating system/version

arch linux

How to reproduce the issue

  1. Open a go file (golang lsp is started)
  2. Open another file (yaml for example)
    Then the following exception happens:
Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:                                                                                                                                                                                                         
{ ["message"] = cannot parse non-Go file file:///home/rz/repos/gitlab.comlinux/ces/ces-operator/config/crd/bases/example.com_compauthcertificates.yaml, ["code"] =  }                                                                                                             
stack traceback:                                                                                                                                                                                                                                                                              
        ...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/fold.lua:51: in function <Anonymous:40>

Expected behavior

No exception should happen.

Actual behavior

As mentioned above an exception happens.

Rust issue

Neovim version (nvim -v | head -n1)

NVIM 0.7.2

Operating system/version

Gentoo Linux 2.8

How to reproduce the issue

  1. Open a Rust file

Expected behavior

File opens normally

Actual behavior

I receive the message

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:
{ ["code"] = -32801, ["message"] = waiting for cargo metadata or cargo chec }
stack tracebak:
        ...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/fold.lua:59: in function <Anonymous:40>

nvim often becomes unresponsive due to recursion stack overflow when having vertical splits

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+1856-g58323b1fe

Operating system/version

macOS 12.x

How to reproduce the issue

nvim-ufo version: f3662fe (latest as of now). The bug was reproducible when a minimal config is used, i.e., require 'ufo'.setup {} only.

It's quite hard for me to specify the exact condition for this bug to happen, as I don't have a deterministic way/scenario to 100% reproduce the bug, but here's some steps:

  1. Open a file with lots of folds
  2. :vsplit to open the buffer in two different windows
  3. Do some fold operations: activate nvim-ufo, open/close folds, jumping between windows, moving cursors, etc.
  4. The nvim sometimes becomes barely responsive (perhaps while updating folds, etc.)

Expected behavior

There should be no lag or errors and everything should work smoothly.

Actual behavior

An error message shows as a virtual text or maybe in a floating window:

 ufo: Error executing lua: /Users/wookayin/.vim/plugged/nvim-ufo/lua/ufo/decorator.lua:203: Vim:E169: Command too recursive                                                     
                 ⋯                                                                                                         stack traceback:                         [C]: in func
                                                                                                                                            [C]: in function 'cmd'  

image

decorator.lua:L203 is cmd('redraw'). For some reason or specific to my config, some heavy routines seem to be running while redrawing the vim screen.

Unfortunately, I was unable to get the stacktrace because the full error message was truncated.

Interestingly, this usually doesn't happen when a buffer is in a horizontally split. When there is no vertical split or only horizontal splits are made, the UI works fine.

Remark the folded line and export the data

Feature description

A folded line actually carry an extmark, we can remap i and a to insert new text to add 'notes' when reviewing the code.
And export the extmarks based on foldlevel to make us understand the meaning of the code we remarked forever unless the file is changed.

I like this feature because I am lazy to make notes but I like reading the fucking source code.

Describe the solution you'd like

Support undo/redo first, and make the extmark more stable when we are making notes.

Additional context

No response

UnhandledPromiseRejection when opening Telescope

Neovim version (nvim -v | head -n1)

nvim v0.7.0

Operating system/version

Arch Linux

How to reproduce the issue

  1. Open Telescope

Expected behavior

No errors

Actual behavior

When I open Telescope (git-files in this case) I see at least sometimes:

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:
...vim/site/pack/packer/start/nvim-ufo/lua/ufo/provider.lua:48: ...site/pack/packer/start/nvim-ufo/lua/ufo/provider/lsp.lua:58: attempt to call method 'match' (a nil value)
stack traceback:
        ...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/fold.lua:51: in function <Anonymous:40>

UnhandledPromiseRejection for neogit commits

Neovim version (nvim -v | head -n1)

NVIM v0.7.2

Operating system/version

arch linux

How to reproduce the issue

  1. commiting a message with neogit

Expected behavior

No error.

Actual behavior

I still get the error:

error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:                                                                           
{ ["code"] = 0, ["message"] = stat /home/rz/repos/gitlab.pnet.ch/linux/ces/agent/.git/NEOGIT_COMMIT_EDITMSG: no such file or ```

Even with the following configuration:

local ftMap = {
	vim = "indent",
	git = "",
	NEOGIT_COMMIT_EDITMSG = "",
}

``` lua
-- global handler
ufo.setup({
	fold_virt_text_handler = handler,
	provider_selector = function(bufnr, filetype)
		-- return a string type use internal providers
		-- return a string in a table like a string type
		-- return empty string '' will disable any providers
		-- return `nil` will use default value {'lsp', 'indent'}
		return ftMap[filetype]
	end,
})

Not sure what I am doing wrong.

Error message appearing when opening/closing folds

Neovim version (nvim -v | head -n1)

0.8.0-dev

Operating system/version

archlinux

How to reproduce the issue

Not sure, need to open/close folds a few times.

Expected behavior

No error message.

Actual behavior

image

Peek folded line snippet without opening

Feature description

high priority for this feature if the document is improved.

Describe the solution you'd like

using a floating window and show the rendered code.

Additional context

No response

UFO auto closes all folds (zM) on text change

Neovim version (nvim -v | head -n1)

0.7

Operating system/version

Arch Linux

How to reproduce the issue

ufo.autocloses.all.folds.mp4

Expected behavior

I want to open / close my folds manually.

Actual behavior

It closes all folds when the text change.

foldlevel changed by `zR`, `zM` sometime buggy

Neovim version (nvim -v | head -n1)

NVIM v0.7.0

Operating system/version

ArchLinux

How to reproduce the issue

local function level1()
    local function level2()
        |
    end
end
  1. type zR, foldlevel become 2
  2. change buffer becomes:
local function level1()
    local function level2()
        if true then
            print('level3')
        end
    end
end

and enter normal mode, folds have applied, level3 is closed automatically.

Expected behavior

level 3 fold keeps open.

Actual behavior

image

Fold not working in files open with Telescope

Neovim version (nvim -v | head -n1)

NVIM 0.7.0

Operating system/version

Fedora 36

How to reproduce the issue

  1. Open any lua file in nvim;
  2. Folds working
  3. :Telescope find_files or vim builtin gf
  4. Pick any other lua file
  5. Folds not applied

Expected behavior

Folds should work in the buffer open with Telescope also.

Actual behavior

Folds not applied.
UfoInspect returns

Buffer: 15
Fold Status: start
Main provider: lsp
Fallback provider: indent
Selected provider: lsp

UfoEnableFold has no effect.

If open file with :edit path/to/file folds are working.

LSP Hover mapped to <CR> when leaving a fold preview leads to an UnhandledPromiseRejection exception

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+595-g95c65a6b2

Operating system/version

Debian testing

How to reproduce the issue

cat mini.lua

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])

local package_root = "/tmp/nvim/site/pack"
local packer_install_path = package_root .. "/packer/start/packer.nvim"

local function load_plugins()
    require("packer").startup({
        {
            "wbthomason/packer.nvim",
            "williamboman/nvim-lsp-installer",
            "neovim/nvim-lspconfig",
            "kevinhwang91/nvim-ufo",
            "kevinhwang91/promise-async",
        },
        config = {
            package_root = package_root,
            compile_path = packer_install_path .. "/plugin/packer_compiled.lua",
            display = { non_interactive = true },
        },
    })
end

_G.load_config = function()
    require("nvim-lsp-installer").setup({
        install_root_dir = "/tmp/nvim/lsp_servers" ,
        automatic_installation = true
    })
    local lsp_init = function()
        require("lspconfig").sumneko_lua.setup({
            settings = { Lua = { cmd = { "/tmp/nvim/lsp_servers/sumneko_lua/extension/server/bin/lua-language-server" } } },
            on_attach = function(_, bufnr)
                vim.keymap.set("n", "<CR>", vim.lsp.buf.hover,{ buffer = bufnr })
            end
        })
    end
    lsp_init()
    vim.api.nvim_create_autocmd("ModeChanged", {
        once = true,
        pattern = { "n:i" },
        callback = function()
            package.loaded.lsp = nil
            lsp_init()
        end,
    })

    vim.o.foldcolumn = '1'
    vim.o.foldlevel = 1
    vim.o.foldlevelstart = -1
    vim.o.foldenable = true

    local ufo = require('ufo')
    ufo.setup()
    vim.keymap.set("n", "K", function() ufo.peekFoldedLinesUnderCursor() end)
end

if vim.fn.isdirectory(packer_install_path) == 0 then
    print("Installing plugins and dependencies...")
    vim.fn.system({
        "git",  "clone",   "--depth=1",
        "https://github.com/wbthomason/packer.nvim",
        packer_install_path,
    })
end

load_plugins()
require("packer").sync()
vim.cmd([[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]])

nvim -nu mini.lua mini.lua

  1. Wait until the code has been folded
  2. Preview a fold with K and leave the preview with any key, notice everything is normal.
  3. Enter Insert mode then go back to normal, LSP starts, diagnostics appears
  4. Hover any part of the code (ie vim), hit a LSP popup appear
  5. Now repeat step 2, an exception is thrown each time we leave a folded preview and step 4 does not work anymore

Expected behavior

I can map vim.lsp.buf.hover to <CR> with no exception thrown when leaving a fold preview.
My mapping should be preserved after leaving the preview.

Actual behavior

An exception is thrown each time we leave a folded code preview

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:
...te/pack/packer/start/nvim-ufo/lua/ufo/preview/keymap.lua:33: Expected lua string

The current mapping to vim.lsp.buf.hover is lost.


Note that using the recommended mapping K for vim.lsp.buf.hover fix the issue described.

Some additional notes, commit 27c466886959fad03a09dd62814e126ff8178a1a introduce this issue and replacing k.lhs by k.rhs on this line seems to fix the exception but the mapping is still lost.

Not related but thank you for your very nice plugin :)

Fold Toggle

Feature description

Add a :foldtoggle which opens the fold if closed and close the fold if opened.

Describe the solution you'd like

Toggle fold to the opposite state.

Additional context

No response

navigate to the next/previous closed fold

Feature description

Thanks for the awesome plugin!!
Title is summarized, Could this plugin support navigate to the next/previous closed fold?

Describe the solution you'd like

maybe like [z , ]z

Additional context

No response

Folds opened by `za` or `zo` close recursively when leaving insertmode

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+452-gb2ed439bd5

Operating system/version

Linux 5.18.5-arch1-1 #1 SMP PREEMPT_DYNAMIC (arch linux)

How to reproduce the issue

local function level1()
    local function level2()
        |
    end
end
  1. Place cursor on line 2 local function level2()
  2. Press either za (toggle fold under cursor) or zo (open fold under cursor)
  3. Do edits in insert mode and hit <esc> to go to normal mode
    ...

Expected behavior

local function level1()
    local function level2()
        -- whatever edits I made
    end
end

Folds under the cursor that are opened manually with za or zo remain open (so that i can inspect what I just changed, or any other purpose)

Actual behavior

all folds have been closed

local function level1() -- folds here
end

Customize fold text still have weird numbers

Neovim version (nvim -v | head -n1)

0.7.0

Operating system/version

macos 12.4

How to reproduce the issue

  1. Enter the files
  2. Sign numbers apear

I use CoC nvim with this config for ufo
`
vim.wo.foldcolumn = '1'
vim.wo.foldlevel = 99 -- feel free to decrease the value
vim.wo.foldenable = true

local handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {}
local suffix = ('  %d '):format(endLnum - lnum)
local sufWidth = vim.fn.strdisplaywidth(suffix)
local targetWidth = width - sufWidth
local curWidth = 0
for _, chunk in ipairs(virtText) do
local chunkText = chunk[1]
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
if targetWidth > curWidth + chunkWidth then
table.insert(newVirtText, chunk)
else
chunkText = truncate(chunkText, targetWidth - curWidth)
local hlGroup = chunk[2]
table.insert(newVirtText, { chunkText, hlGroup })
chunkWidth = vim.fn.strdisplaywidth(chunkText)
-- str width returned from truncate() may less than 2nd argument, need padding
if curWidth + chunkWidth < targetWidth then
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
end
break
end
curWidth = curWidth + chunkWidth
end
table.insert(newVirtText, { suffix, 'MoreMsg' })
return newVirtText
end

-- global handler
require('ufo').setup({
fold_virt_text_handler = handler
})

`

Expected behavior

Like the demo
Uploading image.png…

Actual behavior

Uploading image.png…

Add treesitter provider

Feature description

Someone loves treesitter, but I think is fragile for all languages and low perf compared with lsp and indent providers.

Low priority for this feature.

Describe the solution you'd like

borrow code from nvim-treesitter and transform the expr format to lsp foldingrange format for manual.

Additional context

No response

UfoDisable throws an error

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+nightly-652-g2aac5710

Operating system/version

MacOS 12.4

How to reproduce the issue

  1. nvim
  2. UfoDisable

E5108: Error executing lua ...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/main.lua:28: Vim(autocmd):E216: No such group or event: Ufo
stack traceback:
[C]: in function 'cmd'
...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/main.lua:28: in function 'destroyEvents'
...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/main.lua:70: in function 'disable'
...l/share/nvim/site/pack/packer/start/nvim-ufo/lua/ufo.lua:35: in function 'disable'
[string ":lua"]:1: in main chunk

Expected behavior

Throws an error

Actual behavior

Not to throw error :)

Allow to configure open_fold_hl group(UfoFoldedBg)

Feature description

Allow to configure highlight color which is applied when opening folds(UfoFoldedBg)
Currently it is forced to be same as Folded background

Describe the solution you'd like

change
cmd(('hi UfoFoldedBg guibg=#%x'):format(hl.background))
to
cmd(('hi default UfoFoldedBg guibg=#%x'):format(hl.background))

Additional context

Thanks you for the great plugin!

Automatic folds

Feature description

There is https://github.com/Konfekt/FastFold maybe this plugin can integrate the feature itself so we can remove another viml dependence.

Describe the solution you'd like

Auto fold documentation code.

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.