Skip to content

Commit

Permalink
fixes for Neovim 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
lyokha committed May 23, 2024
1 parent d7814e2 commit 6d2ffdc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ Starting from **version 0.6**, *MakeHtmlCodeHighlight* uses the same
highlighting engine as *MakeTexCodeHighlight* by default. To switch back to the
*TOhtml* engine, set variable *g:PhHtmlEngine = 'tohtml'*.

Output of *TOhtml* may differ from that of default highlighting engine: it
Output of *TOhtml* may differ from that of the default highlighting engine: it
renders buffers in a very verbose way and may content folds, bold text etc.,
whereas default engine normally ignores view details of the buffer.

Note that in *Neovim* *0.10* plugin *TOhtml* was rewritten in a non-compatible
way and therefore the *TOhtml* engine was disabled in this version of *Neovim*.

### MakeTexCodeHighlight

Basically, this command is a twin of the previous one, only it produces a TeX
Expand Down
2 changes: 1 addition & 1 deletion autoload/publish_helper.vim
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ fun! publish_helper#make_tex_code_highlight(fst_line, last_line, ...)
endfun

fun! publish_helper#make_html_code_highlight(fst_line, last_line, ...)
if g:PhHtmlEngine == 'tohtml'
if g:PhHtmlEngine == 'tohtml' && !has('nvim-0.10')
call call(function('s:make_tohtml_code_highlight'),
\ [a:fst_line, a:last_line] + a:000)
else
Expand Down
7 changes: 6 additions & 1 deletion doc/publish_helper.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ Starting from version 0.6 MakeHtmlCodeHighlight uses same highlighting engine
as MakeTexCodeHighlight by default. To switch back to TOhtml engine set
variable g:PhHtmlEngine = 'tohtml'.

Output of TOhtml may differ from that of default highlighting engine: it
Output of TOhtml may differ from that of the default highlighting engine: it
renders buffers in a very verbose way and may content folds, bold text etc.
whereas default engine normally ignores view details of the buffer.

Note that in Neovim 0.10 plugin TOhtml was rewritten in a non-compatible
way and therefore the TOhtml engine was disabled in this version of Neovim.

------------------------------------------------------------------------------
*publish_helper-cmd-tex*
3.2 MakeTexCodeHighlight~
Expand Down Expand Up @@ -584,6 +587,8 @@ A. Change History~
- escape single quotes in command MakeHtmlCodeHighlight
- 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

Expand Down
13 changes: 5 additions & 8 deletions lua/publish-helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ function M.get_node_hl(bufnr, row, col)
return
end

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

for capture, node, _ in iter do
local hl = query.hl_cache[capture]
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]
Expand All @@ -45,11 +46,7 @@ function M.get_node_hl(bufnr, row, col)
if cur_hlid ~= 0 then
local _, _, end_row, end_col = ts.get_node_range(node)
hlid = cur_hlid
if end_row > row0 then
len = 0
else
len = end_col - col0
end
len = end_row > row0 and 0 or end_col - col0
end
end
end
Expand Down

0 comments on commit 6d2ffdc

Please sign in to comment.