From 08bdb05c3d8e1cf52db53ba386be56ee7953e451 Mon Sep 17 00:00:00 2001 From: Jamie Bainbridge Date: Mon, 13 Feb 2023 12:17:06 +1100 Subject: [PATCH] Don't highlight in terminal buffers When opening a buffer with `:terminal` trailing whitespace is highlighted in there too. However, this doesn't make much sense. Many programs emit trailing whitespace and highlighting it distracts from their output. Even the user's cursor is considered whitespace so there's always a useless highlight. If the user is interested in trailing outspace in the output of programs for later document formatting, they can apply such text formatting in the document's buffer, where this plugin will be active. Detect terminal buffers and consider them not valid for this plugin. Signed-off-by: Jamie Bainbridge --- plugin/trailing-whitespace.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/trailing-whitespace.vim b/plugin/trailing-whitespace.vim index 668b093..d8977ff 100644 --- a/plugin/trailing-whitespace.vim +++ b/plugin/trailing-whitespace.vim @@ -9,13 +9,14 @@ function! ShouldMatchWhitespace() for ft in g:extra_whitespace_ignored_filetypes if ft ==# &filetype | return 0 | endif endfor + if &buftype ==# 'terminal' | return 0 | endif return 1 endfunction " Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces highlight default ExtraWhitespace ctermbg=darkred guibg=darkred autocmd ColorScheme * highlight default ExtraWhitespace ctermbg=darkred guibg=darkred -autocmd BufRead,BufNew,FileType * if ShouldMatchWhitespace() | match ExtraWhitespace /\\\@