quarto-dev / quarto-nvim

Quarto mode for Neovim
Other
315 stars 11 forks source link

Subscript highlighted as strikethrough #122

Open Aman9das opened 3 months ago

Aman9das commented 3 months ago

In quarto markdown format, subscript~1~ creates subscript₁

But in the syntax highlighting, image is shown.

ref: https://quarto.org/docs/authoring/markdown-basics.html#text-formatting

jmbuhr commented 3 months ago

That's a limitation of using the treesitter markdown grammar also for quarto. You can overwrite the highlighting by taking the query file from https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/markdown_inline/highlights.scm , adding it to your own config at queries/markdown_inline/highlights.scm and replacing:

(strikethrough) @markup.strikethrough

with

(strikethrough
(emphasis_delimiter) 
(strikethrough 
  (emphasis_delimiter) 
  (emphasis_delimiter)) 
(emphasis_delimiter))@markup.strikethrough 

such that only double ~~ cause a strikethrough highlight.

Aman9das commented 3 months ago

Can this be implemented only for quarto files. Like inside ftplugin.

Also I saw this about overriding queries, but didn't understand properly where to put what: https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#adding-queries

jmbuhr commented 3 months ago

I got it to work half-way (see commit to my config linked above): On quarto files the window highlighting is overwritten such that strikethrough is no longer strikethrough and only the additional highlight group (should answer your question about where to put those) with two tildes is strikethrough.

Caveat: The highlight group namespace is set per window, not per buffer i.e. if you open a markdown file in the same window as the quarto file it will get the same treatment.