2

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.

Noam E
  • 121
  • 1
  • 1
  • 4

1 Answers1

0

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.

jdhao
  • 24,001
  • 18
  • 134
  • 273