pwntester / octo.nvim

Edit and review GitHub issues and pull requests from the comfort of your favorite editor
MIT License
2.28k stars 125 forks source link

Treesitter support for Markdown #329

Closed mattr- closed 1 year ago

mattr- commented 1 year ago

Issue Description

feature request

Describe what happened (or what feature you want)

I'd like octo.nvim to switch from Vim's syntax files to Treesitter for markdown highlighting support. Why? Treesitter's highlighting of markdown is more correct.

For example, if you load mattr-/vigilant-rotary-phone#5 with octo.nvim, you'll notice that the #4 issue reference is highlighted as a heading, since there's a # at the start of the line. However, the (commonmark) markdown spec says that there must be a space after a heading delimiter.

Here's a screenshot showing the issue: image

Describe what you expected to happen

octo.nvim uses tree-sitter for markdown highlight and everybody is happy because tree-sitter is awesome and their parser/highlight is better.

How to reproduce it (as minimally and precisely as possible)

  1. load mattr-/vigilant-rotary-phone#5 with octo.nvim
  2. see similar results based on the screenshot. the line starting with# will be highlighted as a markdown heading with your chosen color scheme

Tell us your environment

macos 12.6, neovim 0.7, octo.nvim e634cd1

Anything else we need to know?

This plugin is great and I use it all the time. thank you writing it and being open to feedback ❤️

pwntester commented 1 year ago

Hi! Did you try this config from the README?

Can I use treesitter markdown parser with octo buffers?

Just add the following lines to your TreeSitter config:

local parser_config = require("nvim-treesitter.parsers").get_parser_configs() parser_config.markdown.filetype_to_parsername = "octo"

pwntester commented 1 year ago

Just checked the official Tree-sitter docs, and it seems like they have changed the code to use to:

local ft_to_parser = require "nvim-treesitter.parsers".filetype_to_parsername
ft_to_parser.octo = "markdown"

Just tried it and it seems to work ok. Will update the README's FAQ.

mattr- commented 1 year ago

🤦 I didn't even see that in the README. I will learn to read better in the future. 😅