Closed Shatur closed 4 years ago
Unfortunately no. But actions are just mapping (https://github.com/lambdalisue/fern.vim/blob/master/doc/fern.txt#L108-L112) so you can list it.
Yes, I know that I can hardcode it, but I thought maybe there is more portable way :( Thanks!
What if split s:map_help
function into two? The first is public that returns a list of actions with shortcuts, and the second is private (s:
) that displays them in echo.
Hum... It's technically possible but it's inconsistent with a current specification.
I assumed that any APIs in internal#
namespace are private. That means, at least for now, APIs for actions are assumed as private. Thus, even your suggestion had applied, I'd suggest you copy the part of the code instead of relying on the private (technically public but private in the specification) function. Or maybe APIs for actions should be moved out from internal#
namespace to make it public in the specification (but it's a kind tough work.)
Note that I said "the specification" but it means like "my current coding rule" thus it might be ignored one day (or maybe already.)
Thanks for the explanations!
Consistency is important.
But I see that s:map_help
not relies at any other functions except s:compare
. So, what if move list generation part from fern#internal#
to just fern#
and reuse this function in s:map_help
?
Just a suggestion. Of course I can just copy this code to get list of actions.
Sorry. I've read and forgot about this issue.
Hum... It's a bit difficult. As you said, s:map_help
does not rely on other functions but it has a context; the function is for building a help text of actions; thus I don't think it's a good idea to expose s:map_help
as-is.
So I'm OK if
fern#action#BRABRA
s:map_help
are extracted as utility functions without its context as fern#util#BRABRABRA
One of above is required to change/keep the concept for action in fern but I feel it's kinda overkilling for things you need
The entire action feature become PUBLIC and documented so that 3rd-parties can access it via fern#action#BRABRA
Yes, this is exactly what I suggested. A function that returns a dictionary with Fern actions and can be used by 3rd-parties and inside s:map_help
.
But you are right, this is a bit overkill. I will just copy code and edit for my needs to use inside FZF. Thank you!
Sorry for the inconvenience. I'll put the first one as a "maybe oneday" task.
It would be nice to have, thanks :)
@Shatur95 Now you can get action list by fern#action#list()
https://github.com/lambdalisue/fern.vim/pull/176/commits/ae807617709c83a8d2c92d607adc2274c955335a
Wow, thank you!
Can I execute an action by text in Vimscript? Trying to create action selection via FZF.
Use fern#action#call()
on the fern buffer.
Thanks! I wrote the following, maybe someone will be interested.
I mapped it to A
for Fern buffer.
It would be nice if it's a plugin I guess
This is just a few lines of very opinionated code :) If it is a plugin, it should be more extensible.
I have a question. Is there a way to get list of all fern actions in Vimscript? I would like to wrap in into FZF in my vimrc. Thanks!