Skip to content
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

refactor: simplify event handling #250

Open
justinmk opened this issue Dec 21, 2024 · 0 comments
Open

refactor: simplify event handling #250

justinmk opened this issue Dec 21, 2024 · 0 comments

Comments

@justinmk
Copy link
Owner

Use simpler approach suggested by @matveyt vim/vim#16259 (comment)

All one has to do is to trap BufNew and if it's isdirectory() then set up BufReadCmd for this particular buffer. No need to add any extra autocommands.

If anyone is interested the code example is here.

caveat?:

No VimEnter. It is enough to iterate through all pre-loaded buffers once on plugin startup.
I've no idea why everyone likes to pollute BufEnter. In my implementation I go without it.
P.S. The only problem I'm aware of that might force usage of BufEnter or similar is that some window-local options might not be synchronized properly. Suppose you have one directory buffer opened in several different windows. Then &concealcursor or such may be not set in some of them. This is unfortunate but kind of expected, as long as we're doing only "per buffer init" and never "per window init". Personally, I opted just to ignore that small issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant