Commit Graph

346 Commits

Author SHA1 Message Date
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
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
hedy
bc2b0ff9ac fix: Don't open hover on preview by default
Also updated docs
2023-11-12 14:01:06 +08:00
hedy
a616f44aea feat: Fix markdown provider icon kind
Closes #2
2023-11-12 13:55:22 +08:00
hedy
e5d95ff69a docs: Update readme and rename highlight 2023-11-12 13:30:35 +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
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
f3ad74315d fix: Outline refresh on CursorHold event moving cursor
Closes #7
2023-11-12 08:30:05 +08:00
hedy
6378318f21 fix: Use of old config key bg_hl
Closes #6
2023-11-12 08:00:29 +08:00
hedy
e9ade0ed22 feat: Custom icon sources 2023-11-11 16:01:05 +08:00
hedy
5aa15e9955 feat: Goto and close keybinding 2023-11-11 14:04:26 +08:00
hedy
e9d83e472e feat: Blend cursor color with cursorline 2023-11-11 11:20:14 +08:00
hedy
09b51fa5d5 feat: Print warning when no providers found 2023-11-08 22:24:45 +08:00
hedy
10ee0008ed feat: Winhl options for outline and preview windows 2023-11-08 19:15:29 +08:00
hedy
011f2e6122 Merge upstream PR 130 (preview width control)
simrat39/symbols-outline.nvim#130
2023-11-08 14:23:38 +08:00
hedy
29ed132f07 MAJOR: Refactor configuration structure
The details of the change is documented in the readme.

If your config stops working, I'm fully responsible :)
2023-11-08 13:56:09 +08:00
hedy
6c47ebf0d7 fix: Extra left padding
Please see linked issues

- simrat39/symbols-outline.nvim/165
- simrat39/symbols-outline.nvim/178
- simrat39/symbols-outline.nvim/209
2023-11-08 08:36:17 +08:00
hedy
0e785762f7 feat: Line numbers next to symbols for quick jumping
See reasoning in:
simrat39/symbols-outline.nvim#212

This feature is turned off by default to avoid clutter, and many users
might not want this feature on by default.
2023-11-08 08:02:42 +08:00
hedy
cb1c108a0c fix(markdown): Ensure content is followed by '#'
Before this commit, empty headings are taken into account:

   # a normal heading

   below is not a good heading:

   #

   below is also not a good heading:

   ##

   These should not be listed in the outline.
2023-11-07 21:14:39 +08:00
hedy
9e96b54de9 feat: Add follow_cursor and restore_location
New lua API function: follow_cursor (supports opts.focus_outline).
This sets location in outline to match location in code.

New keymap: restore_location (C-g) by default.
This provides the same functionality as follow_cursor.

I've also refactored other lua API functions for consistency of using
`opts.focus_outline`. If opts is not provided, focus_outline is
defaulted to true. To change this behaviour, set it to false.
2023-11-06 09:20:52 +08:00
hedy
8ddaa13443 Merge upstream PR #229
simrat39/symbols-outline.nvim#229
2023-11-03 09:43:02 +08:00
hedy
7ad4009d17 Update readme and reorganize 2023-11-03 09:28:44 +08:00
hedy
e3d622445e feat: Move and goto_location simultaneously, and highlight
See readme changes
2023-11-02 21:37:40 +08:00
hedy
fe98a8cf8a BREAKING: Rename focus_location -> peek_location
Avoids confusion with other uses of 'focus'.
2023-11-02 21:13:30 +08:00
hedy
a23a0d321f Merge upstream PR #235
simrat39/symbols-outline.nvim#235
2023-11-02 20:18:02 +08:00
hedy
b495ccc3ef Fix invalid buffer id 2023-11-02 20:17:51 +08:00
hedy
23b31c64e8 Merge upstream PR #177
simrat39/symbols-outline.nvim#177
2023-11-02 20:14:32 +08:00
hedy
bbe95d0c58 fix(auto_preview): Instantly preview whenever another node is selected
simrat39/symbols-outline.nvim#119

Rather than using another config option, this should be the default,
expected behaviour for auto_preview.

Also (another difference to the PR implementation is that) there is no
need to subscribe to both CursorHold and CursorMoved.
2023-11-02 20:06:06 +08:00
hedy
a87f73c3b2 BREAKING,feat: Customizable guide markers
See readme
2023-11-02 17:46:27 +08:00
hedy
841825b747 Document border option and publicize has_code_win 2023-11-02 17:31:37 +08:00
hedy
c19b3bd571 feat: Add show_status 2023-11-01 21:09:06 +08:00
hedy
d78d94218a feat: Revamp preview window
Please see README diff for details and implications.
2023-11-01 21:04:26 +08:00
hedy
505e99e870 chore(docs): Update readme 2023-11-01 18:54:40 +08:00
hedy
0ad33c4842 feat(commands): Support bang on commands to force retain focus
See readme
2023-11-01 18:38:18 +08:00
hedy
2df9662290 feat: Focus and unfocus outline window 2023-11-01 16:52:56 +08:00
hedy
0769cfe5c3 feat(cursorline): Add cursorline option 2023-11-01 16:20:51 +08:00
hedy
782e7cb18b Don't use h3 header for 'No info' message
Not sure what the point here is since there isn't anything beneath the
header anyway.
2023-11-01 15:37:17 +08:00
hedy
f7fc1905a4 fix(preview): Empty symbol preview
Fix simrat39/symbols-outline.nvim#176

I was going to pull @enddeadroyal's commit from their
'bugfix/symbol-hover-misplacement' branch in their fork but they changed
indentation so I had to apply the relevant changes myself instead.

However, credits for this fix goes to @enddeadroyal from the issue
commit in 176.

Also fixed the "No info available" markdown as it wasn't rendering
properly for me without a space after the '###'.
2023-11-01 15:33:26 +08:00
hedy
e98041c75f Use lua to create commands 2023-11-01 14:29:56 +08:00
hedy
4f3993627b Merge upstream PR #119
simrat39/symbols-outline.nvim#119
2023-11-01 13:40:24 +08:00
hedy
57c758322b Merge upstream PR #180
simrat39/symbols-outline.nvim#180
2023-11-01 13:20:47 +08:00
hedy
8969e4694c Merge upstream PR #222
simrat39/symbols-outline.nvim#222
2023-11-01 13:19:23 +08:00
hedy
a240ba4483 Merge remote-tracking branch 'rqdmap/master'
simrat39/symbols-outline.nvim#218
simrat39/symbols-outline.nvim#217
2023-11-01 12:57:12 +08:00
hedy
5df2881500 fix(folding): Don't attempt to toggle non-foldable node 2023-10-31 21:06:50 +08:00
hedy
fe34bf0613 feat(folding): Support toggling of folds 2023-10-31 20:29:06 +08:00
hedy
b4798a669b Merge branch 'master' of github.com:beauwilliams/symbols-outline.nvim
simrat39/symbols-outline.nvim#163
2023-10-31 20:22:11 +08:00