dracula / vim

πŸ§›πŸ»β€β™‚οΈ Dark theme for Vim
https://draculatheme.com/vim
MIT License
1.34k stars 454 forks source link

Treesitter Markdown highlighting #317

Closed GNOMES closed 8 months ago

GNOMES commented 9 months ago

I currently have Treesitter installed in Neovim, which suggests disabling Neovim's native highlighting for performance (additional_vim_regex_highlighting = false) vs duplicating highlights.

When using the Treesitter "Markdown" parser and Dracula.vim, all of the text is white, while tables are pink dash lines (note I have replaced the colors with Van Helsing Pro colors):

Screenshot 2024-02-02 at 23 13 14

It appears that Dracula.vim is not support Treesitter highlight groups for Markdown files.

Running "set syntax=markdown" to turn the native highlighting back on introduces coloring, but it is not very contextually aware beyond headings types and bulleted lists.

I ran across this thread that mentions that themes need to support the parser highlight groups, or it will not work: https://www.reddit.com/r/neovim/comments/rg97j4/comment/hoiwnbj/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

As noted by one of the users, I installed Cattpucin to test this implementation, and it does appear to be improved for headings for example:

Screenshot 2024-02-02 at 23 10 57

Should this context aware highlighting already be working? Are there suggestions on how to implement this for a possible future PR or my own personal dotfiles?

benknoble commented 9 months ago

I'm not sure why the treesitter version isn't working (though pro doesn't yet have many of the updates here), but the regular syntax looks correct. If you want different colors for the header levels, that's pretty easy to customize once you know the highlight groups (which you can find in the code or by using the syntax APIs).

stnley commented 9 months ago

Could you confirm which version of neovim you're on? I'm currently working on a patch to add new TS groups introduced in neovim master.

GNOMES commented 9 months ago

Currently 0.9.5 via homebrew

On Sat, Feb 3, 2024, 12:17 stnley @.***> wrote:

Could you confirm which version of neovim you're on? I'm currently working on a patch to add new TS groups introduced in neovim master.

β€” Reply to this email directly, view it on GitHub https://github.com/dracula/vim/issues/317#issuecomment-1925420236, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABY5ZHVNLPSHG5QCWUUA7GTYRZ5NDAVCNFSM6AAAAABCXWH5QOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVGQZDAMRTGY . You are receiving this because you authored the thread.Message ID: @.***>

stnley commented 9 months ago

Looking at highlight_group.c in the neovim 0.9.5 release, I do not see any tree-sitter groups which are undefined (either by this theme directly, or by this theme modifying the default group linked by neovim).

This is what I see when using neovim 0.9.5, nvim-treesitter HEAD, and additional_vim_regex_highlighting = false.

dracula-master-without-regex

If you put your cursor on a markdown heading and run :TSHighlightCapturesUnderCursor what is the result?

This is mine: 1707087880_grimshot

Now, because nvim-treesitter and neovim have been changing their captures/groups my thought was to write a patch to add what is missing from nvim-treesitter to this theme. I wanna make sure I include anything you're missing too.

GNOMES commented 9 months ago

Hmm, I don't have :TSHighlightCapturesUnderCursor. Can you confirm the exact command you are running?

I see references to this command online in the now archived nvim-treesitter/playground, which says the functionality was merged into Nvim itself.

Trying the merged :Inspect command, I see the following on headings:

:Inspect
Treesitter
  - @markup.heading.2.marker.markdown links to @markup markdown

For a level 2 "##" headings.

stnley commented 8 months ago

@GNOMES would you mind updating this plugin and providing feedback? New treesitter groups were just merged.

GNOMES commented 8 months ago

Working great!

On Fri, Feb 23, 2024, 08:21 stnley @.***> wrote:

@GNOMES https://github.com/GNOMES would you mind updating this plugin and providing feedback? New treesitter groups were just merged.

β€” Reply to this email directly, view it on GitHub https://github.com/dracula/vim/issues/317#issuecomment-1961410620, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABY5ZHXQE5SW6R4WW2T4KZ3YVCQVBAVCNFSM6AAAAABCXWH5QOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRGQYTANRSGA . You are receiving this because you were mentioned.Message ID: @.***>

benknoble commented 8 months ago

Great, can we close this?