Skip to content

Commit

Permalink
lua/publish-helper.lua: use hlid directly from the capture
Browse files Browse the repository at this point in the history
autoload/publish_helper.vim: trans hlid before use in synIDattr()
  • Loading branch information
lyokha committed May 24, 2024
1 parent 6d2ffdc commit ed54670
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
7 changes: 4 additions & 3 deletions autoload/publish_helper.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
" File: autoload/publish_helper.vim
" Author: Alexey Radkov
" Version: 0.15.2
" Version: 0.16
" Description: autoload functions for plugin/publish_helper.vim

" next Xterm2rgb... conversion functions are adopted from plugin Colorizer.vim
" Xterm2rgb... converters were adopted from plugin Colorizer.vim
fun! s:Xterm2rgb16(color)
" 16 basic colors
let r=0
Expand Down Expand Up @@ -220,6 +220,7 @@ fun! s:split_synids(fst_line, last_line, ts, ...)
let sk_trans = synIDtrans(hlID('SpecialKey'))
while cursor[1] <= a:last_line
let old_synId = '^'
let old_trans = 0
let old_start = cursor[2]
let cols = col('$')
if linenr >= 0
Expand Down Expand Up @@ -248,8 +249,8 @@ fun! s:split_synids(fst_line, last_line, ts, ...)
else
let [synIdNmb, len] = [synID(line('.'), col('.'), 1), 1]
endif
let synId = synIDattr(synIdNmb, 'name')
let trans = synIDtrans(synIdNmb)
let synId = synIDattr(trans, 'name')
if len == 0
let len = line('$') - line('.')
endif
Expand Down
20 changes: 12 additions & 8 deletions doc/publish_helper.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
*publish_helper.txt* For Vim version 7.3 and above Last change: 2024 May 19
*publish_helper.txt* For Vim version 7.3 and above Last change: 2024 May 24

------------------------------
Publish Helper (HTML and TeX)
------------------------------

version 0.15.2
version 0.16

Author: Alexey Radkov

Expand Down Expand Up @@ -582,15 +582,19 @@ Christian Brabandt for plugin Colorizer and Xterm2rgb translation functions.
*publish_helper-changes*
A. Change History~

0.15 - 0.15.2
0.16
- fixed handling colors when 'termguicolors' is set
- escape single quotes in command MakeHtmlCodeHighlight
- fixes in script lua/publish-helper.lua, now it also has support for
Neovim 0.10
- set b:current_syntax in syntax/shelloutput.vim which fixes rendering
shelloutput in Neovim via the treesitter fallback
- disable TOhtml rendering engine in Neovim 0.10 because plugin TOhtml was
rewritten in this version of Neovim in a non-compatible way
- vimhl 0.3.0.0 - 0.3.2.0: many improvements (see release notes at github)
- update the sample .vimrc.pandoc to use with Neovim
- disable TOhtml rendering engine in Neovim 0.10 because plugin TOhtml
was rewritten in this version of Neovim in a non-compatible way
- extend the sample .vimrc.pandoc to use with Neovim

0.15
- vimhl 0.3.0.0 - 0.3.2.0: a few improvements and optimizations
- escape single quotes in command MakeHtmlCodeHighlight

0.14
- startup optimization: all functions were moved to autoload/ directory
Expand Down
25 changes: 9 additions & 16 deletions lua/publish-helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,18 @@ function M.get_node_hl(bufnr, row, col)

local iter = query:query():iter_captures(root, bufnr, row0, row0 + 1)

for capture, node, _ in iter do
local hl = vim.fn.has('nvim-0.10') == 1
and query:get_hl_from_capture(capture)
or query.hl_cache[capture]

if hl and ts.is_in_node_range(node, row0, col0) then
local c = query._query.captures[capture]
if c ~= nil and c ~= '' then
local cur_hlid = 0
cur_hlid = vim.fn.hlID(c)
if cur_hlid ~= 0 then
local _, _, end_row, end_col = ts.get_node_range(node)
hlid = cur_hlid
len = end_row > row0 and 0 or end_col - col0
end
for capture, node, _, _ in iter do
if ts.is_in_node_range(node, row0, col0) then
hlid = vim.fn.has('nvim-0.10') == 1
and query:get_hl_from_capture(capture)
or query.hl_cache[capture]
if hlid ~= 0 then
local _, _, end_row, end_col = ts.get_node_range(node)
len = end_row > row0 and 0 or end_col - col0
end
end
end
end, true)
end)
end

if hlid == 0 and vim.b.current_syntax ~= nil then
Expand Down
4 changes: 3 additions & 1 deletion pandoc/.vimrc.pandoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ if has('nvim')
colorscheme gruvbox-material
if g:VimhlNvimUseTreesitter
lua require'nvim-treesitter.configs'.setup
\ { highlight = { enable = true } }
\ { highlight = {
\ enable = true,
\ additional_vim_regex_highlighting = false } }
runtime plugin/nvim-treesitter.lua
let g:PhHighlightEngine = 'treesitter'
endif
Expand Down
2 changes: 1 addition & 1 deletion plugin/publish_helper.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" File: plugin/publish_helper.vim
" Author: Alexey Radkov
" Version: 0.15.2
" Version: 0.16
" Description: two commands for publishing highlighted code in HTML or TeX
" (optionally from pandoc as highlighting engine from filter
" vimhl.hs)
Expand Down

0 comments on commit ed54670

Please sign in to comment.