-
Notifications
You must be signed in to change notification settings - Fork 102
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
Run editor action on save #118
Comments
Use https://plugins.jetbrains.com/plugin/7177-file-watchers instead
Den 27 okt. 2017 3:58 em skrev "Cyprien Quilici" <notifications@github.com>:
… Hi,
I was wondering if it could be possible to add an option to run an
external tool on the file on save.
### My use-case
I've got a markdown that I edit and a script that parses it to generate
the ToC.
I'd like to run the script each time I save the file.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#118>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABxWR7obBr3Jxxq6GZ7kx7omNigg_Urqks5sweGSgaJpZM4QJGYd>
.
|
I'm not exactly sure file watchers is what I'm looking for, correct me if I'm wrong but what I gathered from looking at both these plugins was that:
When I try to use file watchers, the script execution triggers the file watcher which make a recursive call that crashes IntelliJ. |
Hey @quilicicf, This was already asked for similar purposes see #72, and #61 that was actually implemented by jetbrains. I think what you're asking fits the save-actions plugin: "user modifies file -> save-actions automatically modifies it too -> intellij saves on disk" The problem is that I'm not going to call a random script on disk, this is a security issue (commit a settings file and a script file in a repo that uses save-actions, bam you have remote execution). I don't even know if that would work, because intellij calling a (bash?) script is probably async, so it would probably save before the script ends. The only solutions I see for now is to implement your TOC generation directly in save-actions (nope) or call another plugin in intellij (better, but not great). So I don't really have a solution for you, but I'm not against the idea. Probably @markiewb 's solution is your best way to go for now. PS hey you work at restlet, say hi to jonathan :) |
It looks like I'm gonna keep running the external tool by hand with a shortcut then, it's not that bad. Thanks for taking the time to get into details! I'm not sure if I should close this ticket or if you want to keep it open for reference, I'll let you guys see to it? PS: Jonathan says hi too ;-) |
I never realized that you could launch an external tool from Intellij... You can probably retrieve the Action with I won't have time to implement that anytime soon, but it's definitely possible to do and and you can submit a PR anytime. Check out the https://github.com/dubreuia/intellij-plugin-save-actions#contributing section to get you started. |
I'll get a look (not next month) thanks! |
It would be great to be able to run any webstorm action. This would enable you to use the newly added prettier functionality on save. |
Or any other IDE actions Ctrl + Shift + A |
I'm working on this one right now. |
If someone want to test the feature, I've created a release candidate 1.4.0-RC1. You can configure the plugin to execute on save a "quick list", which is a series of editor actions (pretty much anything that can be executed with "CTRL + SHIFT + A"). For example I've configured the plugin to execute a quick list that launches my test suite when I save. Any feedback welcome. |
My mistake, I'm fixing. |
Reminder set to try that on monday, thanks :) |
Can you guys help me test this version please? I've re-added editor actions in the settings, it looks good and could be released in the next 1.8.0 if it works ok for you. I've changed the order of the quick lists, so you might have to re-choose your quick list in the save action settings page. Here is the jar: intellij-plugin-save-actions-1.8.0-RC1.zip (it will work on 2019.x only, if you need another version I'll change the manifest version) |
It Works What
What Not
Not expecting this to work, but tried anyway:
|
Works for me in Pycharm 2019.3 👍 |
Ok thank you for testing guys. I'm releasing 1.8.0 this weekend. I'll close this issue, but please reopen an issue for specific actions that doesn't work (ie @ozum for ESLint). |
Confirmed working as a charm in Webstorm 2019.3, using prettier from quick lists |
👏 🎉 Thanks all |
Released in 1.8.0. |
Since there can be multiple quicklists defined and there is only a checkbox (experimental) to enable this, how does it know what to run? |
@rcollette Yes, I was about to tell you about the drop down. I can make it show more, I'm using the light theme which makes it more visible. The code has been written to execute multiple quick lists but I haven't coded the UI to support that (I don't know if its useful or not). |
I can't think of a use case for multiple lists. Thanks for the UX consideration. |
@dubreuia maybe you can exchange checkbox with an empty field in list. i.e. when it is empty it means no action. |
Thanks @OlgaLevanova, I've created #292 |
A fix for #292 has been released in 2.0.0 (https://plugins.jetbrains.com/plugin/7642-save-actions/update/77136 / https://github.com/dubreuia/intellij-plugin-save-actions/releases/tag/v2.0.0) |
@dubreuia Works perfect. Thanks! |
Would it be possible to pass the file path that is being saved as an input to the script that would be called by the external tools? (or to setup an environment variable with this?) use case: |
Hi,
I was wondering if it could be possible to add an option to run an external tool on the file on save.
My use-case
I've got a markdown that I edit and a script that parses it to generate the ToC.
I'd like to run the script each time I save the file.
The text was updated successfully, but these errors were encountered: