lambdalisue / vim-fern

🌿 General purpose asynchronous tree viewer written in Pure Vim script
MIT License
1.29k stars 49 forks source link

Show additional info like ownership, size, etc., on each line #264

Open srcrip opened 3 years ago

srcrip commented 3 years ago

How doable would it be to add an option to toggle other information on a per line basis, like ranger or dired:

image

lambdalisue commented 3 years ago

Unfortunately, fern doesn't support such a feature (at least for now). I'd dreamed to provide a way to see such information but it's a bit difficult and I don't have enough motivation (yet) to implement that.

srcrip commented 3 years ago

Getting the info itself shouldn't be hard, just requires some system calls (though it might be difficult to make it work on linux/mac/windows at the same time). How hard do you estimate it to be to actually add stuff to functions drawing each line? Where should I look?

lambdalisue commented 3 years ago

How hard do you estimate it to be to actually add stuff to functions drawing each line? Where should I look?

Depends on the design but I'm sure that I'll reject it if the feature would affect the performance. Thus, I'm wondering about providing the feature as a plugin but the current fern itself does not provide enough mech to implement such a plugin (I guess while I haven't designed that feature yet.) Mean that I think I need to design an entire mech to allow such a plugin first.

srcrip commented 3 years ago

Yeah if we could somehow get a function call that would occur per line that would pass in the filename it could be implemented as a plugin outside of fern proper. I would be in favor of that if its doable...

alexandersokolow commented 6 months ago

I have implemented this in my fork, but it relies on an external bash script + C program.

The bash script calls "find" with some arguments to get the file sizes and prints them with the names (separated by some kind of rare unicode character). The CI'm not using those anyways program is called to display the number of files in directories (doing this without C was too slow). The script also prints file type information, to show executable files in green, show symlinks with arrows, etc. (the way I syntax highlight the executables is by displaying some kind of specific invisible character before the names)

The way it works in my fern fork is that this bash script gets called in scheme/file/util instead of "find" (or e.g. "ls") & the node objects get populated with the extra information. The renderer has been adjusted to incorporate that information. It's also handling edge cases like when the file names are too long.

If you are interested, I can send you the script & c program & point you to the locations in my fork that has had changes related to this, though I'm not sure how you'd integrate it into the fern plugin for general use & whether the use of an external C program would align with fern's design philosophy (of just using vimscript). In my case, I just have a symlink to the bash script in my path, but I guess the C program would somehow have to be integrated into the fern folder, which is probably not something that makes sense for fern, though maybe as a plugin! The change does not (significantly) affect the performance (it did before I had the C script).

Here are two screenshots of how it looks: image image

Btw, I have a lot of other cool features that might be worth integrating (e.g. nicer copy / move / delete with popups in the center, extract / compress functionality, expanding / collapsing all nodes at once, regex marking, etc.), but that should probably go into another post / issue.

lambdalisue commented 5 months ago

Thanks for your suggestion but "but it relies on an external bash script + C program" is not acceptable in fern.vim. I'm sorry for that.