linrongbin16 / fzfx.nvim

A Neovim fuzzy finder that updates on every keystroke.
https://linrongbin16.github.io/fzfx.nvim/
MIT License
122 stars 5 forks source link

feat(previewer): add nvim buffer previewer #556

Closed linrongbin16 closed 7 months ago

linrongbin16 commented 7 months ago

relate: #491 .

Regresion test

Platforms

Tasks

linrongbin16 commented 7 months ago

The builtin nvim buffer previewer has much better syntax highlighting (since it's native nvim buffer), but the performance is unacceptable for me when scrolling up/down (in the left side).

This PR will need a lot of improvements to make it better, not only the performance, also the whole structure is ugly now.

https://github.com/linrongbin16/fzfx.nvim/assets/6496887/56320d6b-6970-4177-8c7f-2da1b81e2ca9

linrongbin16 commented 7 months ago

Also, I noticed bat can custom new themes: https://github.com/sharkdp/bat?tab=readme-ov-file#adding-new-themes.

I am thinking retrieve RGB color codes from vim syntax highlighting, and create a custom theme for bat. Just like already did for fzf theme.

bat theme uses the .tmTheme: https://www.sublimetext.com/docs/color_schemes_tmtheme.html

linrongbin16 commented 7 months ago

performance is good (on macOS) now, but still laggy on Windows. It should be related to Windows cmd.exe /C echo.

maybe could try to detect if there's external echo command, and use it first?

Windows user can use the improved bat theme in #557 .

codecov[bot] commented 7 months ago

Codecov Report

Attention: 376 lines in your changes are missing coverage. Please review.

Comparison is base (29d2217) 80.13% compared to head (4d371c6) 76.60%.

Files Patch % Lines
lua/fzfx/detail/general.lua 8.28% 166 Missing :warning:
lua/fzfx/detail/popup/buffer_popup_window.lua 67.77% 155 Missing :warning:
lua/fzfx/detail/popup.lua 49.15% 30 Missing :warning:
lua/fzfx/detail/popup/popup_helpers.lua 76.81% 16 Missing :warning:
lua/fzfx/detail/fzf_helpers.lua 96.10% 6 Missing :warning:
lua/fzfx/detail/popup/fzf_popup_window.lua 98.14% 2 Missing :warning:
lua/fzfx/helper/parsers.lua 87.50% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #556 +/- ## ========================================== - Coverage 80.13% 76.60% -3.53% ========================================== Files 45 48 +3 Lines 4526 5425 +899 ========================================== + Hits 3627 4156 +529 - Misses 899 1269 +370 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

linrongbin16 commented 7 months ago

Now the performance is quite good as well, even in Windows it's good.

I think I could cancel the other improve bat theme PR #557 , we may not need it.

Still something need to do:

  1. Also parse fzf --border option as provider's window border.
  2. Enable the preview window label.
  3. Enable the default key bindings for preview window (alt+p: toggle preview window, ctrl+f/ctrl+b: scroll down/up)
savchenko commented 7 months ago

Massive effort! 🥳 Would you expose some highlight groups or pull everything from the loaded colourscheme?

Some bits seem to be a little off, e.g. cursorline in previewer from :FzfxLiveGrep

image

...and in nVim:

image

I have tried commenting-out fzf_color_opts, but to no effect.

linrongbin16 commented 7 months ago

Massive effort! 🥳 Would you expose some highlight groups or pull everything from the loaded colourscheme?

Some bits seem to be a little off, e.g. cursorline in previewer from :FzfxLiveGrep

image

...and in nVim:

image

I have tried commenting-out fzf_color_opts, but to no effect.

this PR doesn't support 'FzfxLiveGrep' for now, it only affect the 'FzfxFiles' command.

it's only the first step, others will come after this PR get merged.