Commit Graph

435 Commits

Author SHA1 Message Date
hedy
d78d0a0b50 docs: Fix typo on issue reference 2023-11-15 11:23:06 +08:00
hedyhli
f5365560be Auto generate vim docs 2023-11-15 03:21:54 +00:00
hedy
f356c29578 feat: Allow disabling icons 2023-11-15 11:21:20 +08:00
hedy
ddd4fe4359 fix(guides): Respect config.guides.enabled = false
oopsie
2023-11-13 21:31:19 +08:00
hedy
78ad5cb583 Merge branch 'main' of github.com:hedyhli/outline.nvim 2023-11-13 21:15:40 +08:00
hedy
9c70b96b36 fix(highlight-hover): Set cursor in parent if child is folded
Hopefully this commit fixes #1.

- Improved algorithm that finds the items to set hover-highlight
- Now we can set cursor on the nearest parent if the leaf node is folded
  in the outline.
- Set cursor column appropriate depending on whether lineno is enabled.

API:
- parser.preorder_iter now supports an optional argument as function,
  which determines whether to explore children. By default, folded
  parents will not explore children. This can now be overridden.

Behaviour:
- If you fold a nested node and hit <C-g>, you can go back to the
  nearest parent
- The column that cursor goes to is no longer arbitrarily chosen

It appears that simrat or whoever wrote this code thought the column was
1-indexed, however it is 0-indexed, so the old code was always putting
the cursor on the 2nd column.

Now, we put it in the first column. If lineno is enabled, we set the
cursor the be at the column of lineno padding, this makes both the
lineno and the markers visible.

Unfortunately the so-called 'improved' algorithm for
_highlight_current_item is still not the best. The most optimal would be
O(n). However, to make sure we stop refactoring now that it works OK and
can already fix an issue, I will leave this to posterity.

Tested to work (for me).
2023-11-13 21:07:30 +08:00
hedyhli
35a27c6820 Auto generate vim docs 2023-11-13 10:27:46 +00:00
hedy
3f0025af3d docs: Use one screenshot only for hide_cursor 2023-11-13 18:27:13 +08:00
hedy
aba398af54 docs: Fix typo
OMG
2023-11-13 18:26:34 +08:00
hedyhli
b04f3b55f8 Auto generate vim docs 2023-11-13 10:26:30 +00:00
hedy
bb006be6f6 docs: Fix image placement 2023-11-13 18:25:56 +08:00
hedyhli
df850949af Auto generate vim docs 2023-11-13 10:24:56 +00:00
hedy
40a41b7d18 docs: Add another screenshot 2023-11-13 18:24:22 +08:00
hedyhli
c210f8d5ea Auto generate vim docs 2023-11-13 10:15:38 +00:00
hedy
1446bdd135 fix: Lineno alignment, hl_mode, config options
- Config
  - Renamed auto_goto -> auto_jump (because goto implies change of
    cursor focus)
  - Renamed down/up_and_goto -> down/up_and_jump

Existing config that use the old keys *WILL STILL WORK*. But users are
recommended to update to avoid inconsistency. I promise the number of
config changes like this will decrease inverse-exponentially after the
plugin refactor :)

- Docs
  - Improved wording

- Lineno
  - Fixed alignment (no way I was taking max line num of the *Outline*
    buf this whole time!)
  - Fixed appearance of lineno column hl blending if hide_cursor is one
    (please see the comment added)
2023-11-13 18:07:52 +08:00
hedy
fd22263c32 fix: Guide and fold highlight offsets
Was a silly mistake due to copying code from previous implementation.
2023-11-13 16:48:06 +08:00
hedy
7713536d28 refactor: make_outline function and left padding of lineno 2023-11-13 15:41:54 +08:00
hedy
60e8cadb46 fix: lineno left prefix padding 2023-11-13 15:20:54 +08:00
hedyhli
df8f24a52a Auto generate vim docs 2023-11-13 06:46:38 +00:00
hedy
91b027cb91 Merge branch 'main' of github.com:hedyhli/outline.nvim 2023-11-13 14:46:10 +08:00
hedy
c6438a21e1 docs: Update readme on new highlight groups 2023-11-13 14:46:01 +08:00
hedy
66aecc7636 MAJOR: Complete rewrite of outline parsing into buffer lines
Scope:
- Parsing of symbol tree
- Producing the flattened tree
- Producing the lines shown in the outline based on the symbol tree
- API of exported functions for parser.lua and writer.lua

Note that the formatting of the outline remains the same as before.

Fixes:
- Guide highlights sometimes cover fold marker areas (may be related to
  the issue brought up by @silvercircle on reddit)
- Guide highlights do not work when using guide markers of different
  widths than the default (such as setting all markers to ascii chars)

All of these issues are now fixed after integrating the a parser
algorithm.

This commit introduces:
1. A better algorithm for flattening & parsing the tree in one go
2. `OutlineFoldMarker` highlight group
3. Fixed inconsistent highlighting of guides and legacy (somewhat weaker
   code), through (1).
4. Minor performance improvements
5. Type hints for the symbol tree
6. Removed several functions from writer.lua and parser.lua due to them
   being merged into writer.make_outline

This can be seen as a breaking change because functions that were
exported had altered behaviours. However I doubt these functions
actually have any critical use outside of this plugin, hence it isn't
really a breaking change as the user-experience remains the same.

The extraneous left padding on the outline window is now a relic of the
past 🎉

The old implementation, parser.get_lines used a flattened tree and was
inefficient, full of off-by-one corrections.

While trying to look for bug fixes in that function I realized it's the
sort of "if it works, don't touch it" portion of code.

Hence, I figured a complete rewrite is necessary.

Now, the function responsible for making the outline lines lives at
writer.make_outline. Building the flattened tree, getting lines, details
and linenos are now done in one go.

This is a tradeoff between modular design and efficiency.

parser.lua still serve important purposes:
- local parse_result function converts the hierarchical tables from
  provider into a nested form tree, used everywhere in outline.nvim. The
  type hint of the return value is now defined -- outline.SymbolNode
- preorder_iter is an iterator that traverses the aforementioned tree in
  pre-order style. First the parents, all the childrens, and so on until
  the last node of the root tree. This is used in writer.make_outline to
  abstract a way the traversal code from the code of making the lines.

Thanks to stack overflow I did not have to consult a DS book to figure
out the cleanest way of this traversal method without using recursion.

This, of course, closes #14 on github.

Note that another minor 'breaking' change is that previously, hl for the
guides where grouped per-character, now they are grouped together for
all the guide markers in the same line. This should not be a problem for
those who only style the fg color for guide hl. However, if you're
styling the bg color, they will now take on that bg collectively rather
than individually.

This change eliminates future maintenance burden because controlling
per-character guide highlights requires careful avoidance of off-by-one
errors.

I have tested most common features to work as before.
I may have missed particular edge cases.

Please take note of "scope" at the top of this commit message.
2023-11-13 14:19:43 +08:00
hedyhli
3e87dd7628 Auto generate vim docs 2023-11-12 23:58:16 +00:00
hedy
bc2b0ff9ac fix: Don't open hover on preview by default
Also updated docs
2023-11-12 14:01:06 +08:00
hedy
fb9875bdcc Merge branch 'main' of github.com:hedyhli/outline.nvim 2023-11-12 13:55:45 +08:00
hedy
a616f44aea feat: Fix markdown provider icon kind
Closes #2
2023-11-12 13:55:22 +08:00
hedyhli
8092c46f83 Auto generate vim docs 2023-11-12 05:31:44 +00:00
hedy
e5d95ff69a docs: Update readme and rename highlight 2023-11-12 13:30:35 +08:00
hedy
c258b7521f Merge branch 'master' of github.com:hedyhli/outline.nvim 2023-11-12 13:18:31 +08:00
hedy
82d47f4b40 docs: Minor readme update 2023-11-12 13:18:25 +08:00
hedyhli
0db100c449 Auto generate vim docs 2023-11-12 05:17:09 +00:00
hedy
ac702039d3 docs: Update readme 2023-11-12 13:16:32 +08:00
hedy
b9dd7a49f5 Merge branch 'master' of github.com:hedyhli/outline.nvim 2023-11-12 12:42:09 +08:00
hedy
a13394b6f5 As part of previous commit but I can't force-push now 2023-11-12 12:41:57 +08:00
hedyhli
a7a5e314fa Auto generate vim docs 2023-11-12 04:41:54 +00:00
hedy
f0ab2cc7b5 Merge branch 'master' of github.com:hedyhli/outline.nvim 2023-11-12 12:41:25 +08:00
hedy
965a3842c8 MAJOR: Project rename and preparation for v1.0.0
I hope I haven't missed any for the renames!
2023-11-12 12:40:32 +08:00
hedyhli
1efb2c538a Auto generate vim docs 2023-11-12 01:44:34 +00:00
hedy
2746f6f423 feat: Option for split command
Idea provided by silvercircle, see issue:

Closes #8
2023-11-12 09:42:19 +08:00
hedy
58b1bee0be fix: Typo introduced in follow_cursor commit for __refresh()
Courtesy of @silvercircle for bringing it up.

Typo introduced in: 9e96b54
2023-11-12 09:09:23 +08:00
hedy
432b84402f Merge branch 'master' of github.com:hedyhli/symbols-outline.nvim 2023-11-12 08:31:33 +08:00
hedy
f3ad74315d fix: Outline refresh on CursorHold event moving cursor
Closes #7
2023-11-12 08:30:05 +08:00
hedyhli
b687e897a0 Auto generate vim docs 2023-11-12 00:03:26 +00:00
hedy
434e2f83e1 Merge branch 'master' of github.com:hedyhli/symbols-outline.nvim 2023-11-12 08:02:48 +08:00
hedy
6378318f21 fix: Use of old config key bg_hl
Closes #6
2023-11-12 08:00:29 +08:00
~hedy
ad9d38293d Update README.md
Clarify purpose
2023-11-11 22:37:17 +08:00
hedyhli
f6d3ce2ee0 Auto generate vim docs 2023-11-11 08:04:55 +00:00
hedy
b9594d80a0 Merge branch 'master' of github.com:hedyhli/symbols-outline.nvim 2023-11-11 16:01:21 +08:00
hedy
e9ade0ed22 feat: Custom icon sources 2023-11-11 16:01:05 +08:00
hedyhli
486e6c502d Auto generate vim docs 2023-11-11 06:42:06 +00:00