Skip to content

Instantly share code, notes, and snippets.

@iamFIREcracker
Last active February 13, 2022 18:46
Show Gist options
  • Save iamFIREcracker/7ada8ebf64d11a63e36bee4cea6a51f0 to your computer and use it in GitHub Desktop.
Save iamFIREcracker/7ada8ebf64d11a63e36bee4cea6a51f0 to your computer and use it in GitHub Desktop.
Lisp / Vim: highlight surrounding expression
augroup vlime_hilight_curr_expr
autocmd!
if empty(prop_type_get('lisp_curr_expr'))
call prop_type_add('lisp_curr_expr', {'highlight': 'LispCurrExpr'})
endif
hi link LispCurrExpr MatchParen
function! s:HilightCurrExpr() abort
call prop_remove({'type': 'lisp_curr_expr', 'all': v:true})
let expr = vlime#ui#CurExpr(1)
if expr[0] == '' || expr[1][0] == 0
return
endif
let [line1, col1] = expr[1]
let [line2, col2] = expr[2]
let l:options = {
\ 'type': 'lisp_curr_expr',
\ 'end_lnum': line2,
\ 'end_col': col2,
\ }
call prop_add(line1, col1, l:options)
endfunction
autocmd CursorMoved,CursorMovedI <buffer> call s:HilightCurrExpr()
augroup end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment