Skip to content

Conversation

@uplus
Copy link
Contributor

@uplus uplus commented Jan 18, 2022

Problem

When highlight link is nested, caw.vim fails to uncomment.

Cause

In the current implementation, s:comment_detectable.has_syntax uses synIDtrans to get the terminal syntax name.
If the terminal syntax name does not contain Comment, s:comment_detectable.has_syntax will return 0.

if synIDattr(synIDtrans(id), 'name') =~# a:synpat

For exacmple.

hi! link vimLineComment Comment
hi! link Comment hogeColor
hi! hogeColor ctermfg=8

let id = hlID('vimLineComment')
echo synIDattr(synIDtrans(id), 'name') " 'hogeColor'

For example, it will succeed if the highlight settings are as follows.

hi! link vimLineComment Comment
hi! Comment ctermfg=8

let id = hlID('vimLineComment')
echo synIDattr(synIDtrans(id), 'name') " 'Comment'

Solution

Use both synIDattr(id, 'name') and synIDattr(synIDtrans(id), 'name').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant