-
Notifications
You must be signed in to change notification settings - Fork 55
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
Limit ftplugin to buffer and avoid early lua requires #332
base: master
Are you sure you want to change the base?
Limit ftplugin to buffer and avoid early lua requires #332
Conversation
This changes ftplugin behaviour to: - create user commands confined to the buffer it was triggered on - avoid filesystem lookups of require (they add up) by postponing them until user command gets invoked - skip loading if it has already been executed in a buffer To deduplicate ftplugins, lua's `dofile` is used to load a specific file that holds all shared commands. This is equivalent to vimscript standard `source` approach. These make ftplugin portion of this plugin behave like a good neighbor ftplugin - its changes are buffer local, as it's invoked when a buffer filetype matches. Additionally, ftplugins now read global `disable_typescript_tools` variable, returning early if it's set. Not a common behaviour for ftplugins in general, but a good way to give users fine control over plugin behaviour nonetheless. Not tackled is cleanup in case buffer filetype changes without reloading. I don't think routines for that currently exists, in fact.
This fixes nightly test failures. This also changes behaviour in complex scenarios most likely, as instead of matching just the last node, we now consider all nodes in the match.
35e5ce5
to
2fe5303
Compare
@Slotos Can you please elaborate on the reason why As I see, only
is attributed to And also:
Disclaimer. I can`t make this merging faster. I'm just curious :) |
On the first call for each unique argument,
But, your quote on I’ll push an update in a few hours. |
This eliminates repeated reads of ftplugin implementation file on repeated filetype events. The only reliably persistent store available to ftplugin scripts that I can think of is the global table, which is why I'm using it to store loaded ftplugin "object" in. The prefix is a string gneerated by rolling a fair dice in order to make name collision highly improbable. There might be a more efficient way to do this. Please tear this commit apart if you know of it.
dd9c891
to
600943f
Compare
@Slotos Every plugin adds a directory to lookup, I agree. But isn't it just by the existence of the directory in So, by adding a cache you made the solution even closer to |
This changes ftplugin behaviour to:
them until user command gets invoked
To deduplicate ftplugins, lua's
dofile
is used to load a specificfile that holds all shared commands. This is equivalent to vimscript
standard
source
approach.These make ftplugin portion of this plugin behave like a good neighbor
ftplugin - its changes are buffer local, as it's invoked when a buffer
filetype matches.
Additionally, ftplugins now read global
disable_typescript_tools
variable, returning early if it's set. Not a common behaviour for
ftplugins in general, but a good way to give users fine control over
plugin behaviour nonetheless.
Not tackled is cleanup in case buffer filetype changes without reloading.
I don't think routines for that currently exists, in fact.
Additional housekeeping
ci: use actions/cache@v3 in tests workflow
fix: use non-deprecated iter_matches with all=true
This fixes nightly test failures. This also changes behaviour in complex
scenarios most likely, as instead of matching just the last node, we now
consider all nodes in the match.