From 336266babee39ad3a91a17ee9e709786f2d430e5 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Wed, 17 Jun 2026 14:32:50 +0200 Subject: [PATCH] home/neovim: highlight non-ascii characters --- home/neovim.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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