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

Is it possible to support HighlightColorsOff on a specific buffer only? #31

Closed
nyngwang opened this issue Jan 30, 2023 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@nyngwang
Copy link

nyngwang commented Jan 30, 2023

As title. I'm trying to support large files in nvim, and it will be good if this plugin can be disabled only on those large files.

update:

Is this plugin enabled by default? I have tried the following autocmd but it doesn't work. I still need to uninstall this plugin so that my Neovim won't get frozen after opening those large files.

vim.api.nvim_create_autocmd({ 'BufReadPre', 'FileReadPre' }, {
  pattern = '*',
  callback = function ()
    if vim.fn.getfsize(vim.fn.expand('%')) > 1024 * 1024 -- file size > 1 MB.
    then
      vim.cmd([[
        syntax off
        HighlightColorsOff
        " TSBufDisable highlight indent autotag incremental_selection
      ]])
    end
  end
})
@brenoprata10
Copy link
Owner

Are you sure my plugin is the one at fault? My plugin will only process stuff that is being displayed by the buffer, so no matter if the file has millions of colors or millions of lines, the plugin should work blazing fast.

@nyngwang
Copy link
Author

nyngwang commented Jan 30, 2023

Sure. This is a little part of the log: (generated after opening a binary file that has a wrong extension .ts). I was using an example from nvim-treesitter/nvim-treesitter#1530. So to generate the file:

cat /dev/urandom | head -c 5242880 > bin.ts
   Error  23:11:43 msg_show.lua_error Error detected while processing WinScrolled Autocommands for "*":
23:11:43 msg_show Error executing lua callback: Vim:E976: using Blob as a String
stack traceback:
	[C]: in function 'match'
	...hlight-colors/lua/nvim-highlight-colors/buffer_utils.lua:29: in function 'get_positions_by_regex'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:84: in function 'show_visible_windows'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:114: in function 'update_windows_visibility'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:167: in function <...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:163>
   Error  23:11:43 msg_show.lua_error Error detected while processing WinScrolled Autocommands for "*":
23:11:43 msg_show Error executing lua callback: Vim:E976: using Blob as a String
stack traceback:
	[C]: in function 'match'
	...hlight-colors/lua/nvim-highlight-colors/buffer_utils.lua:29: in function 'get_positions_by_regex'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:84: in function 'show_visible_windows'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:114: in function 'update_windows_visibility'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:167: in function <...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:163>
   Error  23:11:44 msg_show.lua_error Error detected while processing WinScrolled Autocommands for "*":
23:11:44 msg_show Error executing lua callback: Vim:E976: using Blob as a String
stack traceback:
	[C]: in function 'match'
	...hlight-colors/lua/nvim-highlight-colors/buffer_utils.lua:29: in function 'get_positions_by_regex'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:84: in function 'show_visible_windows'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:114: in function 'update_windows_visibility'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:167: in function <...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:163>
   Error  23:11:44 msg_show.lua_error Error detected while processing WinScrolled Autocommands for "*":
23:11:44 msg_show Error executing lua callback: Vim:E976: using Blob as a String
stack traceback:
	[C]: in function 'match'
	...hlight-colors/lua/nvim-highlight-colors/buffer_utils.lua:29: in function 'get_positions_by_regex'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:84: in function 'show_visible_windows'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:114: in function 'update_windows_visibility'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:167: in function <...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:163>
   Error  23:11:46 msg_show.lua_error E5108: Error executing lua: ...rs/ningwang/.config/nvim/lua/ningwang/config/keymaps.lua:117: nvim_exec()..BufEnter Autocommands for "*": Vim(append):Error executing lua callback: Vim:E976: using Blob as a String
stack traceback:
	[C]: in function 'match'
	...hlight-colors/lua/nvim-highlight-colors/buffer_utils.lua:29: in function 'get_positions_by_regex'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:84: in function 'show_visible_windows'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:124: in function 'turn_on'
	...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:174: in function <...nvim-highlight-colors/lua/nvim-highlight-colors/init.lua:172>

@brenoprata10
Copy link
Owner

Is it possible to share this file with me? Or is it something private?
This seems to be an actual plugin crash and not really related to performance 😅

@brenoprata10 brenoprata10 added the bug Something isn't working label Jan 30, 2023
@nyngwang
Copy link
Author

nyngwang commented Jan 30, 2023

Is it possible to share this file with me? Or is it something private?

You can generate it via this command: (assuming you have a linux system, in my case it's macOS)

cat /dev/urandom | head -c 5242880 > bin.ts

@brenoprata10
Copy link
Owner

Great! Thanks for reporting, i will check it when I have some free time 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants