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

IlluminatePause command doesn't work properly #211

Open
ronandalton opened this issue Aug 9, 2024 · 1 comment
Open

IlluminatePause command doesn't work properly #211

ronandalton opened this issue Aug 9, 2024 · 1 comment

Comments

@ronandalton
Copy link

When hovering over a reference and executing the :IlluminatePause command, existing highlights are not immediately cleared.

To Reproduce

  1. Open Neovim.
  2. Press i to enter insert mode and enter the text abc def abc.
  3. Press escape to return to normal mode.
  4. Press 0 to position the cursor at the start of the line.
  5. Observe both references to abc are now highlighted.
  6. Execute the command :IlluminatePause
  7. Observe that the references to abc flicker but then stay in a highlighted state until the cursor is moved.

Minimal config: (save as init.lua)

-- Start nvim with the command: `nvim -nu init.lua`
-- To cleanup once finished: `rm -rf ./.repro`

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.uv.fs_stat(lazypath) then
  vim.fn.system {
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    'RRethy/vim-illuminate',
    opts = {
      providers = {
        'regex',
      },
    },
    config = function(_, opts)
      require('illuminate').configure(opts)
    end,
  }
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Output from :IlluminateDebug

buf_should_illuminate 1 false
config {
  case_insensitive_regex = false,
  delay = 100,
  filetype_overrides = {},
  filetypes_allowlist = {},
  filetypes_denylist = { "dirbuf", "dirvish", "fugitive" },
  min_count_to_highlight = 1,
  modes_allowlist = {},
  modes_denylist = {},
  providers = { "regex" },
  providers_regex_syntax_allowlist = {},
  providers_regex_syntax_denylist = {},
  under_cursor = true
}
started true
provider table: 0x7486e8650c58 regex
`termguicolors` true

Expected behavior
All currently highlighted references should be cleared when :IlluminatePause is issued, without having to move the cursor.

Additional context
Issue seen on Neovim 0.10.1 and 0.9.5.

@ronandalton
Copy link
Author

I think this is happening because buf_highlight_references is being called even when buf_should_illuminate(bufnr) is false (in engine.lua). There is a check for this at the start of the refresh_references function but the value that buf_should_illuminate evaluates to must be different when the callback for the internal timer is executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant