diff --git a/README.md b/README.md index 7ffaf56..be92733 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,15 @@ jsdoc.vim jsdoc.vim generates JSDoc block comments based on a function signature. +![image](images/vim-jsdoc-screencast-preview.gif) + This plugin based on https://gist.github.com/3903772#file-jsdoc-vim written by [NAKAMURA, Hisashi](https://gist.github.com/sunvisor) Depending on your confuguration, jsdoc.vim will prompt for description, `@return` type and description. It will also prompt you for types and descriptions for each function `@param`. +Data type tab completion supported for parameter and return types +* currently: `boolean`, `null`, `undefined`, `number`, `string`, `symbol`, `object` + ## Usage 1. Move cursor on `function` keyword line. 2. Type `:JsDoc` or `` which is default key mapping to insert JsDoc. @@ -14,7 +19,7 @@ Depending on your confuguration, jsdoc.vim will prompt for description, `@return ## Configuration **g:jsdoc_allow_input_prompt** *default: 0* -Allow prompt for intaractive input. +Allow prompt for interactive input. **g:jsdoc_input_description** *default: 1* Prompt for a function description diff --git a/autoload/jsdoc.vim b/autoload/jsdoc.vim index 4f0b7f4..be01830 100644 --- a/autoload/jsdoc.vim +++ b/autoload/jsdoc.vim @@ -51,6 +51,12 @@ if !exists('g:jsdoc_allow_shorthand') let g:jsdoc_allow_shorthand = 0 endif +" Return data types for argument type auto completion :) +function! jsdoc#listDataTypes(A,L,P) + let l:types = ['boolean', 'null', 'undefined', 'number', 'string', 'symbol', 'object'] + return join(l:types, "\n") +endfunction + function! jsdoc#insert() let l:jsDocregex = '^.\{-}\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\)\s*[:=]\s*function\s*(\s*\([^)]*\)\s*).*$' let l:jsDocregex2 = '^.\{-}\s*function\s\+\([a-zA-Z_$][a-zA-Z0-9_$]*\)\s*(\s*\([^)]*\)\s*).*$' @@ -131,7 +137,7 @@ function! jsdoc#insert() for l:arg in l:args if g:jsdoc_allow_input_prompt == 1 - let l:argType = input('Argument "' . l:arg . '" type: ') + let l:argType = input('Argument "' . l:arg . '" type: ', '', 'custom,jsdoc#listDataTypes') let l:argDescription = input('Argument "' . l:arg . '" description: ') " Prepend space to start of description only if it was provided if l:argDescription != '' @@ -145,7 +151,7 @@ function! jsdoc#insert() endif if g:jsdoc_return == 1 if g:jsdoc_allow_input_prompt == 1 - let l:returnType = input('Return type (blank for no @return): ') + let l:returnType = input('Return type (blank for no @return): ', '', 'custom,jsdoc#listDataTypes') let l:returnDescription = '' if l:returnType != '' if g:jsdoc_return_description == 1 diff --git a/images/vim-jsdoc-screencast-preview.gif b/images/vim-jsdoc-screencast-preview.gif new file mode 100644 index 0000000..68e5bbb Binary files /dev/null and b/images/vim-jsdoc-screencast-preview.gif differ