Closed danihodovic closed 9 years ago
It would definitely be possible to do this, but the current tern_for_sublime code does not implement it.
Do you think it would be easier to write a new Tern plugin or add functionality here?
A new plugin would probably be best. Though if you need to make small changes to the main tern_for_sublime
module in order to be able to reuse its code in another plugin, I'd be fine with accepting such pull requests. (The code is not currently written with external reuse in mind.)
Is it possible to automatically insert function arguments when entering the parenthesis on a function that is going to be called? Right now there is an implementation that hints of the arguments the moment you enter the parenthesis, but it would be very handy to automatically insert them and jump into the selections of the arguments to directly edit the names. The current implementation that hints of the arguments and the possible types has great functionality, but isn't very useful as the panel is barely visible.
I've tried implementing this by hacking render_argument_hints(*args) at line 398 that intends to display the function argument hints. It worked fairly ok, until I realized it needs some sort of context. If a new function is being created, inserting the message that is being hinted is wrong. This is also breaks when you try to edit a functions parameters, it simply inserts them again.
On a side note, would it be possible to implement this auto-insertion for object literals passed to functions (sometimes as optional parameters)? I've tried, and Tern, can read the types of a object literal if annotated with a specific JSDoc format.
Example: