home/neovim: highlight non-ascii characters

This commit is contained in:
2026-06-17 14:32:50 +02:00
parent 1104624aa2
commit 336266babe
+21
View File
@@ -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 <Leader><Space> :noh<CR>