Skip to content

Draft: implement indentation as virtual text - #584

Open
jakubbortlik wants to merge 1 commit into
harrisoncramer:developfrom
jakubbortlik:feat/implement-indentation-as-virtual-text
Open

Draft: implement indentation as virtual text#584
jakubbortlik wants to merge 1 commit into
harrisoncramer:developfrom
jakubbortlik:feat/implement-indentation-as-virtual-text

Conversation

@jakubbortlik

Copy link
Copy Markdown
Collaborator

This PR re-implements the discussion tree indentation as virtual text. This has several benefits:

  • selections copied from the discussion tree don't contain the indentation characters
  • markdown syntax highlighting works for code blocks that mark the language, e.g., ```python
  • we get rid of most of the syntax regexes in after/syntax/gitlab.vim.

It already works well, but needs a thorough review and should add unit tests.

-- that also wipes the custom GitlabUsername/GitlabDate/etc. groups from
-- after/syntax/gitlab.vim, which aren't defined by the markdown parser. Reload them on top.
vim.bo[bufnr].syntax = "gitlab"
end

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this also reload the markdown syntax? Most of the groups are gone anyway...

@jakubbortlik
jakubbortlik force-pushed the feat/implement-indentation-as-virtual-text branch from a8ec17a to 225d1b5 Compare September 10, 2026 12:04
The indentation is drawn as virtual text and the icon was only ever used
for its display width, which had to be kept in sync by hand with the
width of the expander icons. Take a number of columns instead.

BREAKING CHANGE: discussion_tree.expanders.indentation is replaced by
discussion_tree.indent_width. :checkhealth reports the removed setting.

feat: draw the expander as virtual text

The whole indent region is virtual now, so a buffer line holds nothing
but the note's own text: yanking a header no longer picks up the
expander icon and the cursor cannot sit on it. A node's text starts at
depth * width, with the expander drawn inside the node's own level,
which keeps headers aligned with the bodies and replies under them
whatever the expander icons are. A level grows to fit an expander wider
than indent_width.

feat: add indent guides to the discussion tree

Guides tie a discussion's replies to the note that started it, with the
last reply closing the thread, so that separate discussions can be told
apart at a glance. They are drawn as part of the virtual indentation and
so cost no columns and never enter the buffer. Only a discussion's root
note produces them: a reply's body is not joined to the reply's own
header. Set discussion_tree.indent_guides to false to turn off.

fixup: only insert indents on wrapped lines when 'wrap' is on
@jakubbortlik
jakubbortlik force-pushed the feat/implement-indentation-as-virtual-text branch from 225d1b5 to c7a27ca Compare September 11, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant