Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchParen(Cur) Highlight persists in virtual fold text #333

Open
ribru17 opened this issue Dec 13, 2023 · 0 comments
Open

MatchParen(Cur) Highlight persists in virtual fold text #333

ribru17 opened this issue Dec 13, 2023 · 0 comments
Labels

Comments

@ribru17
Copy link

ribru17 commented Dec 13, 2023

Explain the issue

Basically, when using a plugin like nvim-ufo which captures the highlights of a line for the folding text, the MatchParen/MatchParenCur highlight persists in the fold text until the user moves the cursor over the specific corresponding bracket, then moves back off of it.

  1. What vim version are you using? NVIM v0.9.4
    Build type: Release
    LuaJIT 2.1.1700008891
    Using Tree-sitter vim-matchup
  2. Steps to reproduce: Fold some lines of code while the cursor is on an open bracket character
  3. Expected behavior: The MatchParen highlight will be cleared upon folding (as it would when moving the cursor)
  4. Observed behavior: The highlight remains in the fold text, and stays when the cursor moves anywhere, only disappearing if, say, the cursor was on the closing bracket in the first place, then folded, such that the cursor would eventually move off of the bracket properly. This bug only affects when folding while the cursor is over an open bracket, for some reason.

Minimal working example

Please provide a minimal working example, e.g.,

print {
  'hi',
}

print('hi')

Observe that when folding from the last character of line 1, the fold text keeps the MatchParen highlight when the cursor moves anywhere. If folding from line 3, the highlight is also applied initially but disappears properly upon moving the cursor anywhere.

Minimal vimrc file

Minimal setup (derived from the lazy.nvim package manager):

local root = vim.fn.fnamemodify('./.repro', ':p')

-- set stdpaths to use .repro
for _, name in ipairs { 'config', 'data', 'state', 'cache' } do
  vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end

-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    'git',
    'clone',
    '--filter=blob:none',
    '--single-branch',
    'https://github.com/folke/lazy.nvim.git',
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

vim.o.foldlevel = 99
vim.o.foldlevelstart = 99

-- install plugins
local plugins = {
  {
    'nvim-treesitter/nvim-treesitter',
    build = ':TSUpdate',
    event = { 'BufReadPost', 'BufNewFile' },
    config = function()
      require('nvim-treesitter.configs').setup {
        ensure_installed = {
          'lua',
        },
        highlight = {
          enable = true,
        },
      }
    end,
  },
  'ribru17/bamboo.nvim',
  'andymass/vim-matchup',
  {
    'kevinhwang91/nvim-ufo',
    dependencies = {
      'kevinhwang91/promise-async',
    },
    opts = {
      provider_selector = function(_, _, _)
        return { 'treesitter' }
      end,
    },
  },
  -- add this to your lua/plugins.lua, lua/plugins/init.lua,  or the file you keep your other plugins:
}
require('lazy').setup(plugins, {
  root = root .. '/plugins',
})

vim.cmd.colorscheme('bamboo')

Additional Context

This bug is not present when folding lines while the cursor is on a closing bracket, only when the cursor is on the first folded line.

Edit: an image example
matchupfoldbug

@ribru17 ribru17 added the bug label Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant