Closed Thanatermesis closed 8 months ago
Not sure how they can handle this for you generally in this repo (differentiating markdown titles requires the creation of custom groups), but I've solved the issue for myself with the following code in highlights.scm
after
queries
markdown
highlights.scm
; extends
(atx_heading (atx_h1_marker) @text.title.h1 (inline) @text.title.h1)
(atx_heading (atx_h2_marker) @text.title.h2 (inline) @text.title.h2)
(atx_heading (atx_h3_marker) @text.title.h3 (inline) @text.title.h3)
(atx_heading (atx_h4_marker) @text.title.h4 (inline) @text.title.h4)
(atx_heading (atx_h5_marker) @text.title.h5 (inline) @text.title.h5)
(atx_heading (atx_h6_marker) @text.title.h6 (inline) @text.title.h6)
Once you've done that, you can set the individual highlight groups for the following groups:
highlight @text.title.h1
highlight @text.title.h2
highlight @text.title.h3
highlight @text.title.h4
highlight @text.title.h5
highlight @text.title.h6
If you use https://github.com/pappasam/papercolor-theme-slim, I've already associated styling to those syntax groups for you.
Note that @punctuation.special
only applies to the #
, not to the title itself (which is @text.title
). You can differentiate markdown titles by just appending .markdown
to the highlight group, like :hi link @text.title.markdown markdownH1
.
But this issue has nothing to do with the parser; please open it at the nvim-treesitter repo (with a clear description how everything should be captured) -- or better yet, open a PR with your proposed changes.
(Well, I say that, but the queries in nvim-treesitter are taken verbatim from this repo, so it's probably best to first make the changes here.)
The suggestion in the previous comment seems taken from Helix' queries, which use a different format than nvim-treesitter. But we're open to align more closely with their format (especially for the @text
groups, which I believe Helix handles better than nvim-treesitter at the moment).
Exactly, the parser differentiates between all levels of headings. The needed changes would be in the highlights.scm
file. The one found in this repo is currently a mix of what helix and neovim, I think. If both editors moved to use more similar capture groups that would be of course amazing and I'd gladly adopt those here.
I'm a bit lost here, so I should open a new issue on "nvim-treesitter" repo or is an issue specific of the markdown parser?
Nvim-treesitter
@clason can you open that issue and reference it on this thread? because I don't understand quite well where is the issue / how it works / what should be made, I just seen the highlighting was better in plain VIM and I reported it here but I don't understand how treesitter or the colorscheme assignations work
Closing this, as it is related to neovim rather than this specific parser.
In vim I had markdown well viewed on its syntax colors, in neovim looks strange, I noticed that the entries like:
are set in vim as:
while as in neovim is just: