Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nvim-treesitter colors doesnt pass to :TOhtml

I'm trying to understand how I can copy code from Neovim as RTF. So far I figured the easiest way is to convert the code to HTML and then convert the HTML to RTF, so using the :TOhtml is supposed to convert the given range to HTML and color it according to the colors in your Nvim editor but when using tree-sitter the colors doesn't convert.

When I convert a code to HTML without treesitter I get:

<style>¬
<!--¬
pre { white-space: pre-wrap; font-family: monospace; color: #e4e4e4; background-color: #000000; }¬
body { font-family: monospace; color: #e4e4e4; background-color: #000000; }¬
* { font-size: 1em; }¬
.Operator { color: #af5f87; }¬
.Repeat { color: #d787d7; font-weight: bold; }¬
.String { color: #d7875f; }¬
.Comment { color: #5f875f; }¬
.LineNr { color: #b2b2b2; }¬
.Include { color: #d75f87; }¬
.Type { color: #5fafaf; }¬
.Number { color: #afd7af; }¬
.Special { color: #5fafff; }¬
.Function { color: #d7d7af; }¬
-->¬
</style>

But when I use treesitter I get:

<style>¬
<!--¬
pre { white-space: pre-wrap; font-family: monospace; color: #e4e4e4; background-color: #000000; }¬
body { font-family: monospace; color: #e4e4e4; background-color: #000000; }¬
* { font-size: 1em; }¬
.LineNr { color: #b2b2b2; }¬
-->¬
</style>

so I need help either getting the :TOhtml to work with the treesitter or any other way to copy as RTF from Neovim on linux.

like image 989
Noam E Avatar asked Nov 20 '25 19:11

Noam E


1 Answers

The TOhtml command is inherited by Neovim from the upstream Vim, and it is written using the traditional Vim syntax highlighting techniques and know nothing about treesitter.

Try to disable treesitter highlighting (TSBufDisable highlight) on the buffer and use traditional highlighting.

like image 181
jdhao Avatar answered Nov 24 '25 00:11

jdhao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!