simonmclean / triptych.nvim

Directory browser plugin for Neovim, inspired by Ranger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Different color for folders

JoseConseco opened this issue · comments

Hi, great addon. I was wondering if you could implement different color for folders names, ranger for reference:
image

Also, I was thinking maybe instead of 3 equal columns, triptych could use some kind of golden rule ratio - where last column, with buffer preview, is widest.

Here is triptych for comparison :
image

its bit hard to differentiate folder at first glance (I disabled icons). j

And last issue - triptych is bit slow when jumping through files with j,k keys. maybe instead of loading whole buffer for preview, only first 40lines could speed it up. Or, if lag is caused by loading treesitter highlights, when user spams j,k keys, then syntax highlight could be debounced .

Hi Jose. Those are all good suggestions. I think config options for both text colour and column widths would be sensible.

In terms of syntax highlighting affecting performance, I hadn't run into any issues myself, hence why it isn't particularly optimised. I had at one point considered only loading a small number of lines, but wasn't sure if this would cause problems with syntax highlighting. For example if there's a function which spans lines 20 - 60, but only the first 40 lines are loaded, would the correct highlighting be applied? Regardless, I will look into performance.

@simonmclean I did not think about limited lines affecting highlights - for python it seems fine, but python does not have closing statements...

And if u add folder text highlight - maybe by default it could be already linked to something - maybe keyword color.

I'm not sure if the limiting factor for performance is buffer size or highlights generations (probably both), but maybe if u load 200 lines, then it would be enough, for parser to colorize at least visible part of buffer preview correctly. ..
I mean - u would load 200 lines, 50 are visible (more or less) - and with luck they would be colorized ok.

@JoseConseco I've merged a new column_widths option. This should give you plenty of control

Thanks! New default widths are ok for me already.

@JoseConseco I've merged another change which adds a highlights option. So you can style the file and folder names using vim's highlight groups.

I'll tackle the performance issue next

@JoseConseco I've added the following config option (shown with defaults)

{
  options = {
    syntax_highlighting = { enabled = true, debounce_ms  = 100 }
  } 
}

There's a behaviour to the debounce that you may or may not like... I adapted debounce_trailing from the gist you linked, but with one key change. If the amount of time passed since the last function call is greater than the configured debounce time, then the next time it's called it won't be debounced. But subsequent calls will be. This means that if you're spamming k for example, the debouncing won't kick in until after the first call.

Hopefully that makes sense, or will do when you try it.

If you think a more straightforward debounce, without the above functionality would make for better UX, let me know. It would be a simple change to remove a few lines

I just tested, the debounc and all is fluent now. I think this issue can be closed now. Thanks for the fixes.