Created
December 30, 2016 19:25
-
-
Save nhooyr/8265b5798933388627c34b8836def14f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! man#highlight_backspaced_text() abort | |
set modifiable | |
let b = nvim_get_current_buf() | |
while 1 | |
let pos = searchpos('\%(.\b.\)\+') | |
if pos[0] == 0 | |
break | |
endif | |
let pos[0] -= 1 | |
let pos[1] -= 1 | |
silent keepjumps substitute/\%(.\b.\)\+/\=execute("let match = substitute(submatch(0), '.\\b', '', 'g') | let isUnderline = submatch(0)[0] ==# '_'").match | |
if isUnderline | |
call nvim_buf_add_highlight(b, -1, 'manUnderline', pos[0], pos[1], pos[1]+len(match)) | |
else | |
call nvim_buf_add_highlight(b, -1, 'manBold', pos[0], pos[1], pos[1]+len(match)) | |
endif | |
endwhile | |
set nomodifiable | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment