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

Autommands - Implemented as a plugin #380

Closed
codri opened this issue Sep 18, 2016 · 5 comments
Closed

Autommands - Implemented as a plugin #380

codri opened this issue Sep 18, 2016 · 5 comments

Comments

@codri
Copy link

codri commented Sep 18, 2016

Autocommands are essential for my vim workflow.
Is it possible to recreate them with a plugin?

@ghost
Copy link

ghost commented Sep 18, 2016

There are already some hooks that does the same thing. At the moment there are a very few.

You can see them at Lua API for in-process extension of the REAME.

@codri
Copy link
Author

codri commented Sep 18, 2016

I've had a look at the list. Can't find the events for a file : open/save/close.
I used autocommands to run some tools on save, there doesn't seem to be an event for file save.

Copied from documentation:

events hooks:

  • start()
  • quit()
  • win_open(win)
  • win_close(win)
  • theme_change(name)

@ghost
Copy link

ghost commented Sep 18, 2016

This would have been convenient indeed... Maybe it is not a lot to add: In the C source code, right after opening a file, make a call to a lua function using the lua C API.

@martanne
Copy link
Owner

martanne commented Sep 19, 2016

Hi, the following 3 additional events are now exposed through the Lua API:

  • file_open(file)
  • file_save(file)
  • file_close(file)

Is this good enough for your purpose? The "plugin" interface is still rather young, suggestions for API improvements can also be posted to issue #292.

Note that with the current design the event handlers are executed synchronously, meaning the editor core will block until your event handler terminates. This might change at some point with the introduction of a proper RPC interface #59.

@codri
Copy link
Author

codri commented Sep 19, 2016

@martanne yes. it looks good. will give it a try to make something like autocommands with lua. will keep in mind about the issue #292 .

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

No branches or pull requests

2 participants