-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: setup hooks for sources to provide custom stat
s for nodes
#1121
Conversation
You know @miversen33, I think I have a better idea for this, let me know what you think. What if instead of a source having to providing a single There are several things I like about this method:
|
With your new idea, would the end flow be that when a user requests
I understand the gist of this but I don't know that I fully understand how it would be implemented as a source provider. Would the idea be that I call local function do_stat_thingy(state, node)
print("Fetching Stat for node", node:get_id())
end
M.setup(config, global_conf)
config.do_stat_thingy = do_stat_thing
end Something like this? I think either idea is fine, though I do like the idea of it being easier to maintain as a developer (so you in this case). If you feel that your suggestion would be easier for you to create/maintain/add to, I say we go for it :) I just want to understand how I as a source developer would utilize the new method for stat |
I don't think you are quite getting what I was trying to explain. What I meant was that you would do two things. First, in your setup function, register the stat provider(s):
I don't know if you really need multiple functions or just one, but you can provide as many as you need. Then, when you provide the data to the renderer, you just add an extra field on every item that defines the name of the stat provider to use:
Then inside neo-tree core, we may have any number of stat providers registered and every node will specify by name what stat provider is appropriate for itself. The existing |
I'm tracking. Perfect, I think that will work great :) What will be the behavior shown to the end user when they attempt to view stat results on a node that doesn't have a stat provider? Say they try to view stat results on the An additional architectural question, you have some new columns that are on the filesystem source for displaying stat information (merged with #1107). I notice in your code that you call the My biggest concern (and this is purely a concern with my own interface with neo-tree as opposed to neo-tree in general) is that calling stat a ton of times will get expensive. Especially if done remotely. I have some caching stuff I am already doing so its not a huge deal for me, but I do want to verify that this |
It just renders
Actually, those are just files and directories so it makes perfect sense to show those stats.
The |
1c28fa9
to
4851ac3
Compare
@miversen33 this is ready to use. See the example source project for instructions: https://github.com/nvim-neo-tree/example-source#custom-stat-provider |
This tweaks how file stats are pulled so that sources (internal or external) can provide their own. This is only necessary if the node does not represent an object in the local filesystem.
See here for an example the API to fulfill:
https://github.com/nvim-neo-tree/example-source/blob/1be4d91d94875501cb4db1a61aa5155b6cd654bc/lua/example/init.lua#L19-L49