Closed lukoshkin closed 2 years ago
I'm not at all sure what you mean by this. You'll have to provide more information
Update: After receiving a notification, custom highlights (here it is made for trailing whitespace) are cleared with the notification disappearing. So it is not connected to project.nvim directly as I thought originally.
init.lua
local packer = require 'packer'
packer.startup(function (use)
use 'wbthomason/packer.nvim'
use {
'rcarriga/nvim-notify',
config = function ()
vim.notify = require'notify'
end
}
end)
vim.opt.termguicolors = true
vim.cmd [[
highlight! Normal guibg=Black guifg=White
highlight! ExtraWhitespace ctermbg=211 guibg=palevioletred
au! FileType markdown hi ExtraWhitespace ctermbg=brown guibg=rosybrown
au! BufWinEnter *\(_\)\@<! if len(bufname()) > 0
\| match ExtraWhitespace /\s\+$/
\| endif
au! InsertEnter * if len(bufname()) > 0
\| match ExtraWhitespace /\s\+\%#\@<!$/
\| endif
au! InsertLeave * if len(bufname()) > 0
\| match ExtraWhitespace /\s\+$/
\| endif
au! BufWinLeave *\(_\)\@<! call clearmatches()
]]
require'notify'('Hello')
dummy.py (example of a file with trailing spaces)
#%%
<-- Trailing whitespace up to here on the line above -->
#%%
<-- Trailing whitespace up to here on the line above -->
I also show my keystrokes so that you know I do not clear the matches myself :)
Your BufWinLeave
autocmd assumes that the buffer being removed is the current one but that's not the case here. When a notification buffer is hidden, the matches are being cleared for the current window. You need to pass the window to clear matches for
au! BufWinLeave *\(_\)\@<! call clearmatches(bufwinid(expand("<abuf>")))
Oh yes, thanks! I was looking for sth like "clearmatches" in your code but never gave a thought to it that the problem was on my end. Sorry for disturbing you!
Having both project.nvim and this wonderful plugin erases the custom highlighting I made for trailing whitespaces. Commenting out just one of the two solves the problem (at least in some contexts -- I didn't test for all possible situations). I will try to prepare MWE if you are not aware of this problem already.