Scan for syntax stack for autoformat

A fix for #11 where there wasn't any syntax stack at the end of a line containing text where we don't want to initiate autoformat.
This commit is contained in:
Reed Esau
2014-08-27 21:32:29 -06:00
parent afbcf2bdff
commit 4880c4b1e1

View File

@@ -56,7 +56,16 @@ endf
fun! s:enable_autoformat()
" don't enable autoformat if in a code block or table
let l:okay_to_enable = 1
for l:sid in synstack(line('.'), col('.'))
let l:col = col('.')
" at end of line there may be no synstack, so scan back
while l:col > 0
let l:stack = synstack(line('.'), l:col)
if l:stack != []
break
en
let l:col -= 1
endw
for l:sid in l:stack
if match(synIDattr(l:sid, 'name'),
\ g:pencil#autoformat_blacklist_re) >= 0
let l:okay_to_enable = 0