-
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: add highlight open files #838
Conversation
I love this idea :) That said, honestly I feel like (IMO) looping over the buffers each time isn't that big of a deal, especially if we only perform said change on a Buffer Change event (such as BufDelete/BufAdd event). At the end of the day, lua is fast and a loop operation (even over several thousand items) per event loop iteration is still effectively instant. Thats not to say that thinking about "caching" or reducing the work is a bad thing, just that its probably not going to have a massive performance impact. Even less of an impact if we tie it only to event changes. One thing I would be curious about, this will highlight all open files with the same highlight right? Is there a way we can highlight the currently focused file different if its one of the files visible in Neotree? |
@miversen33 Thanks for your insights! I also think that caching might not result in a noticeable impact in performance, and adding the buffer list into Regarding the focused file, are you talking about the |
Yes. Does the proposed highlighting overrule that option? I am at work so I cannot test this right now lol. My main concern is that while having all open files highlighted makes a ton of sense, I wouldn't want this to supersede other options (such as |
@miversen33 it doesn't seem so. The focused file will both has the |
Reading code is hard lol. It looks like you are already using the event system for triggering the highlight logic. As long as the current focused file is distinct from the other open files, LGTM :) |
@cseickel I have refactored the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, there's just one more thing. Technically, the utils
module is part of the public api and changing the signature or return type of a function in the utils module that does not start with a _
is a breaking change that is not allowed within a major version: https://github.com/nvim-neo-tree/neo-tree.nvim#what-is-a-breaking-change
To work around that, can you just add a function that mimics the old get_modified_buffers()
? It can be marked as deprecated using a comment:
--- DEPRECATED: This will be removed in v3
---Gets a lookup of all open buffers keyed by path with the modifed flag as the value
---@return table
M.get_modified_buffers = function()
Internally, it should just call the new function and convert it to the simple table of booleans that was returned before.
@cseickel Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
Added highlight open file feature as described in #743. I'm not sure if there is any better way to cache this so that we do not have to loop over all buffers every time. Do you think adding to
state
is a good idea?