mirror of
https://github.com/preservim/vim-pencil.git
synced 2025-11-13 04:13:46 -05:00
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:
@@ -56,7 +56,16 @@ endf
|
|||||||
fun! s:enable_autoformat()
|
fun! s:enable_autoformat()
|
||||||
" don't enable autoformat if in a code block or table
|
" don't enable autoformat if in a code block or table
|
||||||
let l:okay_to_enable = 1
|
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'),
|
if match(synIDattr(l:sid, 'name'),
|
||||||
\ g:pencil#autoformat_blacklist_re) >= 0
|
\ g:pencil#autoformat_blacklist_re) >= 0
|
||||||
let l:okay_to_enable = 0
|
let l:okay_to_enable = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user