diff --git a/home/neovim.nix b/home/neovim.nix index 03056fe..34290ee 100644 --- a/home/neovim.nix +++ b/home/neovim.nix @@ -130,6 +130,27 @@ in { highlight ExtraWhitespace ctermbg=red guibg=red match ExtraWhitespace /\s\+$/ + " Show non-ascii characters (except norwegian æøå) + highlight nonascii ctermbg=214 guibg=#FFA500 " orange + function! HighlightNonAscii() + " delete the old match if it exists + let s:matchid = get(s:, 'matchid', -1) + if s:matchid != -1 + try + call matchdelete(s:matchid) + catch /E803/ + " matchid does not exist, pass + endtry + endif + " Skip popups like telescope + if &buftype ==# "" + let s:matchid = matchadd('nonascii', '[^\x00-\x7FæøåÆØÅ]', 100) + else + let s:matchid = -1 + endif + endfunction + autocmd BufEnter * call HighlightNonAscii() + " Disable search highlights map :noh