Giter Site home page Giter Site logo

Comments (20)

heavenshell avatar heavenshell commented on May 12, 2024

No, but let g:jsdoc_input_description = 1 allows you to input description interactively.
Is this solve your problem?

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

I know that, but I would like this feature: some default things for repetitive things (e.g. callback).

Temporary, I hacked it this way:

 if (l:arg == "callback")
    let l:argType = "Function"
    let l:argDescription = "The callback function."
else
    let l:argType = input('Argument "' . l:arg . '" type: ', '', 'custom,jsdoc#listDataTypes')
    let l:argDescription = input('Argument "' . l:arg . '" description: ')
endif

from vim-jsdoc.

ryanoasis avatar ryanoasis commented on May 12, 2024

@IonicaBizau I can see what you mean. Maybe there is a place for something like this. A user configurable mapping to allow defaults such as the one you describe.

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

ah, now I see what you mean.

1.Set let g:jsdoc_allow_input_prompt = 0 to .vimrc
2.Write following JavaScript code

function foo(callback) {
}

3.Type :JsDoc

Then you want to insert custom description instead of default description.

Huuum, I think your hack is not a good idea and I can't include to jsdoc.vim

function foo(callback, cb, errorCallback) {
}

For example If args are all callback, your hack ignore second and third callback.
So, maybe we should think something like hook structure.

Note following is a just idea.

let g:jsdoc_custom_arg_hooks = {
  \  'callback|cb': {
  \    'description': 'cutsom description',
  \    'type': 'custom type'
  \  },
  \  'error*': {
  \    'description': 'Error callback',
  \  }
\}

Dict key is regex and if key matched to defined signature, description and type would be replaced to default value.

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

@heavenshell A setting like g:jsdoc_custom_arg_hooks in .vimrc is exactly what I imagine as well! Can you implement it? That will increase my productivity a lot. πŸ˜„

You know that joke:

Over 1 year, the average Vim user saves 11 minutes in productivity.

However, they lose 27 hours through evangelising Vim to non-users.

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

OK, I'll add my ToDo list, so stay tuned.
If you can't wait my implementation, send me PR πŸ˜„

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

@heavenshell Cool!

If you can't wait my implementation, send me PR

Right now, I don't know to write VimL code (the snippet I posted above was the first two lines written in VimL in my life). πŸ˜„

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

@IonicaBizau
Try feature_custom_args branch.

Set following setting to your .vimrc

let g:jsdoc_custom_args_hook = {
  \ 'callback\|cb': {
  \   'type': ' {Function} ',
  \   'description': 'Callback function'
  \ }
\}

If above setting(dict) key matched to function signature,
type and description would replaced.

/**
 * foo
 *
 * @param bar
 * @param callback {Function} Callback function
 * @param cb {Function} Callback function
 * @return {undefined}
 */
function foo(bar, callback, cb) {
}

This is an experimental implementation.
So, if you catch bugs or problems, let me know.

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

@heavenshell For some reason it doesn't work for me. I updated the autoload/jsdoc.vim file and set the following in .vimrc:

let g:jsdoc_custom_args_hook = {
  \ 'callback\|cb': {
  \   'type': ' {Function} ',
  \   'description': 'The callback function.'
  \ },
  \ 'progress': {
  \   'type': ' {Function} ',
  \   'description': 'The progress function.'
  \ }
\}

:echo g:jsdoc_custom_args_hook outputs {'progress': {'description': 'The progress function.', 'type': ' {Function} '}, 'callback\|cb': {'description': 'The callback function.', 'type': ' {Function} '}}

But when I press CTRL + L, I see no difference.

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

ah, sorry currently it's only run at let g:jsdoc_allow_input_prompt=0.

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

@heavenshell Almost there. πŸ˜„

/**
 * foo
 *
 * @name foo
 * @function
 * @param input
 * @param input
 * @param callback
 * @param callback {Function}  The callback function.
 * @param cb
 * @param cb {Function}  The callback function.
 * @param progress {Function}  The progress function.
 * @param progress
 * @return {undefined}
 */
function foo(input, callback, cb, progress) {

}

As you see, the fields are duplicated.

But I want to have the following: to be able to insert description, but if I just press enter (empty string), then search the default description.

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

Thx for reporting problem.
Strange...I'll look into it.

Would you show me your .vimrc(related jsdoc.vim settings).

But I want to have the following: to be able to insert description, but if I just press enter (empty string), then search the default description.

So, you mean JsDoc.vim(interactive mode) might behave overwrite default description when press enter if dict key matched.
Please wait a while 😺

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

Here and the following (not committed yet):

let g:jsdoc_custom_args_hook = {
  \ 'callback\|cb': {
  \   'type': ' {Function} ',
  \   'description': 'The callback function.'
  \ },
  \ 'progress': {
  \   'type': ' {Function} ',
  \   'description': 'The progress function.'
  \ }
\}

So, you mean JsDoc.vim(interactive mode) might behave overwrite default description when press enter if dict key matched.

Yes! If I write something, then it has a greater priority than the default description.

Thanks! 🍰

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

Thx. reproduced.
Huum, maybe takes a while to fix.
I should reconsider implementation.

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

@IonicaBizau
Fixed duplication and now you can use in interactive mode.
Could you try this?

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

Awww, this is soooo nice! ✨

However, there is one little thing that still should be fixed: it puts two spaces instead of one. Example:

...
* @param a  {Function}  The callback function.
...

This is probably the last thing to fix from my side. πŸ˜„ Really great work.

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

However, there is one little thing that still should be fixed: it puts two spaces instead of one (e.g. * @param a {Function} The callback function.).

Yep, expected behavior.
I Fixed to insert one space automatically.

Could you change your vimrc?

-'type': ' {Function} ',
+'type': '{Function}',

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

Could you change your vimrc?

Hahaha! Cool! ❇️ Exactly what I needed. Thanks again!

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 12, 2024

Merged to master.

from vim-jsdoc.

IonicaBizau avatar IonicaBizau commented on May 12, 2024

πŸ‘ πŸŽ‰

from vim-jsdoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.