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

Removing all highlights in open buffer at once #2

Closed
lcrockett opened this issue May 26, 2021 · 2 comments
Closed

Removing all highlights in open buffer at once #2

lcrockett opened this issue May 26, 2021 · 2 comments

Comments

@lcrockett
Copy link

Just for future reference and anyone wondering how to achieve removing all highlights in the open buffer in one go, see below for global function snippet.

function _G.highstr_highlight_remove_all()
  local api = vim.api
  local buffer_current_number = api.nvim_eval([[bufnr('%')]])
  local line_last = vim.fn.line('$')

  api.nvim_buf_clear_namespace(buffer_current_number, 0, 1 - 1, line_last)
end

You can call this function as follows: lua _G.highstr_highlight_remove_all()

Cheers for the great plugin !

@pocco81
Copy link
Owner

pocco81 commented May 26, 2021

Two things:

  1. I just added an opt to remove all the highlights. Looks like this: :HSRmHighlight rm_all
  2. No need to get all those vars, this is enough:
local current_buffer = api.nvim_eval([[bufnr('%')]])
vim.api.nvim_buf_clear_namespace(current_buffer, 0, 0, -1)

I'll release it as soon as I update the README and the doc 👍

@pocco81 pocco81 closed this as completed May 26, 2021
@pocco81
Copy link
Owner

pocco81 commented May 26, 2021

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

2 participants