Skip to content

Instantly share code, notes, and snippets.

@haya14busa
Created November 24, 2016 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haya14busa/7dcd4a2ef5b9c0b84225ca50be3f34a8 to your computer and use it in GitHub Desktop.
Save haya14busa/7dcd4a2ef5b9c0b84225ca50be3f34a8 to your computer and use it in GitHub Desktop.
parse by syntax
function! s:func() abort
" hoge
endfunction
function! ParseBySyntax() abort
let lines = getline(1, '$')
for [lnum, l] in map(lines, {i,l -> [i+1, l]})
echo '---'
echo lnum l
for col in range(1, len(l))
" let synname = synIDattr(synID(lnum, col, 1), 'name')
" let transname = synIDattr(synIDtrans(synID(lnum, col, 1)), 'name')
" echo synname transname
echo getline(lnum)[col-1] map(synstack(lnum, col), {i,id-> synIDattr(id, 'name')})
endfor
endfor
endfunction
call ParseBySyntax()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment