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

Default message depending on the type #36

Closed
IonicaBizau opened this issue Aug 28, 2015 · 8 comments
Closed

Default message depending on the type #36

IonicaBizau opened this issue Aug 28, 2015 · 8 comments

Comments

@IonicaBizau
Copy link
Contributor

Is it possible to add a way to define default descriptions depending on the type? Like, #24, but after providing the type I want to just press Enter and create the description automagically.

For example: Object, then I press twice Enter and I want to get @param {Object} arg An object containing the following fields: (which is supposed to be configured somewhere in .vimrc).

Btw, do you have a PayPal account? I'm happy to donate you some 💲 for making my life easier using this plugin. 😄

@heavenshell
Copy link
Owner

@IonicaBizau
Very interesting.
I've implemented your idea.
Try this branch(https://github.com/heavenshell/vim-jsdoc/tree/feature_default_message).
This is an experimentation and please report me if you have any problems.

Add following setting to your .vimrc

let g:jsdoc_type_hook = {
  \ 'object': 'An object containing the following fields',
  \ 'function': 'Callback function'
  \ }

If type is obejct, JSDoc.vim insert An object containing the following fields to description.

Btw, do you have a PayPal account? I'm happy to donate you some 💲 for making my life easier using this plugin. 😄

Wow, Thank you very much.
It's very glad to hear that, but I don't have paypal account.
So if it's ok with you, please donate to Vim it self instead of me 😄

You know Vim is charity ware

http://www.vim.org/sponsor/index.php

@IonicaBizau
Copy link
Contributor Author

@heavenshell Thanks! Almost there! ❇️ The thing I still need is to be able to input a custom description (currently it seems that if I configure a hook for Object, then it doesn't ask me for the description).

Anyway, nice work! 😸

@heavenshell
Copy link
Owner

@IonicaBizau

The thing I still need is to be able to input a custom description (currently it seems that if I configure a hook for Object, then it doesn't ask me for the description).

Please explain to me little bit more?

let g:jsdoc_custom_args_hook = {
  \ 'callback\|cb': {
  \   'type': '{function}',
  \   'description': 'The callback function.'
  \ }
  \}
let g:jsdoc_type_hook = {
  \ 'object': 'An object containing the following fields',
  \ 'function': 'Callback function'
  \ }

Followings are steps to reproduce.

function foo(bar, baz, callback) {
}
  • :JsDoc
  • Argument "bar" type:
  • Input object
    • Then JSDoc.vim shows Argument "baz" type:
  • input number
    • Then JSDoc.vim shows Argument "baz" description:
    • Input baz description
    • Then shows Argument "callback" type:
  • hit return
    • Then shows Argument "callback" description:
    • hit return

Generated JSDoc is following.

/**
 * foo
 *
 * @param {object} bar An object containing the following fields
 * @param {number} baz foo
 * @param {function} callback The callback function.
 */
function foo(bar, baz, callback) {
}

@param {function} callback The callback function. is from let g:jsdoc_custom_args_hook.

@IonicaBizau
Copy link
Contributor Author

Then JSDoc.vim shows Argument "baz" type:

Before this I want to get Argument "bar" description:–and if I only press Enter, it will be set to An object containing the following fields, otherwise (if I write something different), it will be set to what I wrote. So, basically, I still want to have the possibility to enter custom descriptions for type hooks. 💫

@heavenshell
Copy link
Owner

@IonicaBizau
OK, I see.
Please wait a while 😄

@heavenshell
Copy link
Owner

@IonicaBizau
Updated.

let g:jsdoc_type_hook = {
  \ 'object': {
  \   'description': 'An object containing the following fields',
  \   'force_override': 1,
  \ },
  \ 'function': 'Function description'
  \ }

If you set 'force_override': 1, skip description prompt.
If you don't set force_override description prompt.

@IonicaBizau
Copy link
Contributor Author

@heavenshell Works nice! Thank you sooooo much! ✨

@heavenshell
Copy link
Owner

Merged to master. a0c8603

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