guess-indent.nvim icon indicating copy to clipboard operation
guess-indent.nvim copied to clipboard

Turn off Notifications?

Open chrisgrieser opened this issue 1 year ago • 5 comments

I noticed that the plugin seems to creates a prints a notification every time it sets the indentation.

While that may be useful for when you manually run :GuessIndent or when the indentation values have been changed, it is a bit annoying when the notification appears every time you enter a new buffer, even if the indentation was already set correctly?

chrisgrieser avatar Apr 26 '23 08:04 chrisgrieser

Are you seeing a notification every time you enter a buffer? Because when guess-indent sets up the autocommand, it should get executed silently.

NMAC427 avatar May 06 '23 22:05 NMAC427

ah yes, I use nvim-notify to redirect all print commands to a notification. (noice.nvim does a similar thing).

For whatever reason, it seems silent notifications still get redirected. Maybe the notification could be skipped alltogether when guess-indent is triggered via autocmd? Would save users like me the complications

chrisgrieser avatar May 07 '23 10:05 chrisgrieser

I assume you overwrite the lua print function to achieve this (similar to this reddit post)? If this is the case, then I would suggest you to just filter out any messages that start with "Did set indentation to" and "Failed to detect indentation style.".

The way noice.nvim redirects print/echo to notifications is using the vim.ui_attach API, which does not suffer from this issue. Instead of overriding print you could use noice.nvim in conjunction with nvim-notify.

NMAC427 avatar May 07 '23 15:05 NMAC427

I'm actually getting this issue too, but only when I navigate using default Telescope file finders (e.g. :e doesn't trigger this) and only when I have cmdheight = 0 set. But I don't get this issue when guess-indent.nvim isn't installed; seems to be due to auto_cmd being true and the print statements in set_indentation. I'm not using any redirection of print, nvim-notify, or the like (that I know of). I'm using Neovim v0.9.4.

Seems like this is probably a Neovim issue, and not a guess-indent.nvim issue.

AlexSWall avatar Dec 11 '23 13:12 AlexSWall

My workaround will be to set auto_cmd to false and implement my own setup_autocommands, where instead of triggering on BufReadPost the autocmd triggers on InsertEnter. Not ideal, it obviously won't run before I've entered insert mode, but it fixes my issue and I just need something that isn't immediate, it seems.

AlexSWall avatar Dec 11 '23 14:12 AlexSWall