Created
July 22, 2014 16:06
-
-
Save rbtnn/0f3b3dd6d22d1a45b63a 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! s:echo_line_with_hl(lnum, sep) | |
let line = getline(a:lnum) | |
let cs = split(line, '\zs') | |
let xs = [] | |
for c in range(1, len(line)) | |
if diff_hlID(a:lnum, c) isnot 0 | |
let name = synIDattr(synIDtrans(diff_hlID(a:lnum, c)), 'name') | |
else | |
let name = synIDattr(synIDtrans(synID(a:lnum, c, 1)), 'name') | |
endif | |
let xs += [[cs[c-1], (empty(name) ? 'None' : name)]] | |
endfor | |
let b = 1 | |
for x in xs | |
echohl None | |
if b | |
echon 'hi: ' | |
let b = 0 | |
endif | |
if x[0] is a:sep | |
echo '' | |
let b = 1 | |
else | |
execute 'echohl ' . x[1] | |
echon x[0] | |
endif | |
endfor | |
echohl None | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment