moe icon indicating copy to clipboard operation
moe copied to clipboard

Outline sidebar

Open tobimensch opened this issue 3 years ago • 0 comments

Many editors offer a feature that is often called minimap, but I think while that looks cool, and it's basically a fancy version of a scrollbar, it doesn't really help to understand the structure of a file/document all that much.

However, the table of contents sidebar, that is offered in many PDF viewers for PDF files that have a table of contents, makes a lot of sense and actually helps to navigate a long document.

I would like a sidebar, preferably on the left by default, that contains an outline(table of contents) of the current buffer's content.

This would, of course, depend on the type of file/document. I'm not suggesting here to make moe into a PDF viewer (for now). But for example for Markdown and Asciidoc documents, and also many different kinds of source files, it's possible to generate such an outline. Either there're headings and subheadings, or there are type definitions and methods/functions (sometimes nested similar to headings).

This would make it easier to jump between different parts of a document/source file.

Here's an extremely simplified mockup of what I'm proposing:

import section         |100  proc openWindow(w: Window) =
type Window            |101    proc butWhy() =
type Door              |102      echo "but Why?"
type Chair             |103    butWhy()
type Wall              |104    w.opened = true
proc openWindow        |105
L proc butWhy          |106  proc openDoor(d: Door) =
proc openDoor          |107    d.opened = true
proc sitOnChair        |108
proc stareAtWall       |109  proc sitOnChair(c: Chair) =
proc closeWindow       |110    c.isUsed = true
proc closeDoor         |111

This proposed outline can be used to navigate the document using the cursor and the Enter or Space key.

I'd also like there to be a preview feature in that outline, that shows you the content of a part of the document, without changing the scroll position of the underlying buffer. This would be useful to take a glance at something, without having to interrupt the workflow too much.

Another feature the outline sidebar should have is the ability to open an item in a new horizontal or vertical split.

But the most important aspect of this idea is that it should work with the same key combinations, and the same general navigational concept, across different types of source files and documents. So it doesn't matter if you're viewing a C++ file, a Markdown document, a Man page or whatever else, you can always rely on this outline feature working in the exact same way.

Last but not least, typical vim navigational features should also work in this sidebar. For example searching with /.

Finally, as you can see in the mockup, it contains the identifiers of procs, but not the full proc prototypes, because that would make the sidebar too big. But there should be a key combination to make the sidebar bigger, or to even let it become the current buffer itself, so that there doesn't need to be any limitations in the lengths of headings or function prototypes.

To sum it up:

  • Sidebar (configurable either on the left or on the right)
  • Can be used to navigate to different parts of any type of document/source file
  • Opening in new window/pane, horizontal/vertical split
  • Preview feature for seeing a part of a document, without actually navigating there
  • Understands nested structures
  • Vim like navigation
  • Keep headings/function prototypes simplified/short/abbreviated by default, so that the sidebar can be slim (1)
  • Allow for a full view mode of the outline, where the sidebar either becomes bigger, or even becomes the current buffer in the current window. (2) For example in order to see full function prototypes.
  • There should be a key combination to toggle between (1) and (2).

tobimensch avatar Aug 06 '20 20:08 tobimensch