diff --git a/scripts/syntax-diag.vim b/scripts/syntax-diag.vim new file mode 100644 index 0000000..bfeeaf0 --- /dev/null +++ b/scripts/syntax-diag.vim @@ -0,0 +1,75 @@ +" scripts/syntax-diag.vim — dump highlighting state to /tmp/nuwiki-syndiag.log +" +" Usage: open a .wiki file with VARIED markup (heading, *bold*, _italic_, +" `code`), then: +" :source scripts/syntax-diag.vim +" Then paste /tmp/nuwiki-syndiag.log back. + +redir! > /tmp/nuwiki-syndiag.log + +echo '=== state ===' +echo 'filetype=' . &filetype +echo 'syntax=' . &syntax +echo 'b:current_syntax=' . get(b:, 'current_syntax', '') +echo 'syntax_on=' . exists('g:syntax_on') +echo 'colors_name=' . get(g:, 'colors_name', '') +echo 'background=' . &background +echo 'termguicolors=' . &termguicolors +echo 't_Co=' . &t_Co +echo 'has(nvim)=' . has('nvim') +echo 'g:loaded_nuwiki=' . get(g:, 'loaded_nuwiki', '') +echo 'g:loaded_vimwiki=' . get(g:, 'loaded_vimwiki', '') + +echo '' +echo '=== every syntax/vimwiki.vim in runtimepath (first wins) ===' +for s:p in split(&runtimepath, ',') + let s:f = s:p . '/syntax/vimwiki.vim' + if filereadable(s:f) + echo s:f + endif +endfor + +echo '' +echo '=== :hi for our groups (NO silent — capture into redir) ===' +for s:g in ['nuwikiHeading', 'nuwikiBold', 'nuwikiItalic', 'nuwikiCode', + \ 'nuwikiPlaceholder', 'nuwikiCommentLine', 'nuwikiWikilink', + \ 'Title', 'PreProc', 'String', 'Comment', 'Underlined', 'Normal'] + execute 'highlight ' . s:g +endfor + +echo '' +echo '=== synID walk over current buffer (first 30 lines) ===' +for s:ln in range(1, min([line('$'), 30])) + let s:l = getline(s:ln) + let s:segs = [] + let s:last = '' + let s:start = 1 + for s:c in range(1, len(s:l) + 1) + let s:g = s:c <= len(s:l) ? synIDattr(synIDtrans(synID(s:ln, s:c, 1)), 'name') : '' + if s:g != s:last + if s:start <= s:c - 1 + let s:txt = strpart(s:l, s:start - 1, s:c - s:start) + call add(s:segs, s:last . ':' . s:txt) + endif + let s:last = s:g + let s:start = s:c + endif + endfor + echo printf('L%d %s', s:ln, join(s:segs, ' | ')) +endfor + +echo '' +echo '=== :syntax list (full) ===' +syntax list + +echo '' +echo '=== :scriptnames (filtered) ===' +let s:sn = execute('scriptnames') +for s:line in split(s:sn, '\n') + if s:line =~? 'vimwiki\|nuwiki\|syntax\|colors' + echo s:line + endif +endfor + +redir END +echo 'Wrote /tmp/nuwiki-syndiag.log'