nvim-orgmode / nvim-orgmode/orgmode

Some feedback on the Org parsing

Open
#159 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

tree-sitter-issue
Dominant language
Lua
Stars
3.9k
Forks
190
Avg merge
2d 13h
Merged PRs (30d)
7

Description

Hello,

This is a bit of a drive-by issue as I'm not really a neovim user but I thought I'd check out the tree-sitter parsing since I think it looks cool. I've only had a little look, but a few rough spots have become apparent in the three files I checked out.

System setup

config.org

This is the first file I looked at, it's my Emacs config file, and it's massive.

Experience

File took a few seconds to open, then I got hit with

Error detected while processing CursorHold Autocommands for "*.org":
E5108: Error executing lua ...ack/packer/start/orgmode.nvim/lua/orgmode/utils/init.lua:297: too many results to unpack

The header keywords are all grey and underlined, and the rest of the document is red and underlined.

image

Thesis.org (file available on request)

This is the second Org file I tried, it's a ~60 page Thesis I wrote this year. A fair bit is going on, but it's smaller and less complicated than config.org.

Experience

Upon opening the file I immediately see the warning gutentags: ctags job failed, returned: 1.

While there's no error being blasted in my face like with config.org, unfortunately, the results don't look great here either.
All of the header keywords are underlined grey, except for the commented out subtitle which is red for some reason.
The first header, * LaTeX setup :ignore: is also red for some reason.
A few lines later we have the first source code block, and from then on the rest of the document is underlined red except for headings.

image

image

2021-04-26-Welcome.org

This is the first file that wasn't mostly underlined red text! 🎉 It's a fairly short and simple file, the first blog post I published.

Experience
Links

I notice that concel can cause some funny visual results with links

image

For reference, this is how that looks in Emacs,

image

Quite a few links also seem to be incorrectly parsed, such as

image

I tried changing the link target to see what was happening and this threw another error

Error detected while processing TextChangedI Autocommands for "*"
E5108: Error while executing lua ....e/pack/packer/start/cmp_luasnip/lua/cmp_luasnip/init.lua:65: attempted to call field 'get_snippet_filetypes' (a nil value)

image

Ignoring this and trying a few different link targets, it becomes apparent that this issue occurs when the link target spreads over multiple lines.

Inline source blocks

These don't seem to be handled well at the moment.

image

Meanwhile in Emacs,

image

It's worth noting that even if src_*{} constructs weren't special, this still shouldn't be handled as an underline. Say I replace src with hey in the Org file. This is what I then see:

image

Final comments

There are a lot of elements that aren't parsed at all, but I thought it would be best to ignore those for now while there prominent issues with the current parsing.

Lastly, apologies if this isn't as helpful as it could be. As mentioned at the start, I am not at all familiar with neovim (or vim for that matter) and so have just tried to highlight the roughest spots I've noticed. All in all I think it's fantastic to see a genuine effort being made with using tree-sitter based parsing for Org and wish you all the best going forwards. If there's anything I can do to help with a next to no neovim knowledge but a good knowledge of Org and some big/complicated files I'd be happy to assist where I can 🙂.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported parsing and highlighting problems with config.org, Thesis.org, and 2021-04-26-Welcome.org, then inspect lua/orgmode/utils/init.lua:297 where the unpacking error is reported. Compare handling of multiline links, inline source blocks, and large files; done means the reported errors and incorrect highlighting no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.