Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/heavenshell/vim-jsdoc

Generate JSDoc to your JavaScript code.
https://github.com/heavenshell/vim-jsdoc

jsdoc vim

Last synced: 15 days ago
JSON representation

Generate JSDoc to your JavaScript code.

Awesome Lists containing this project

README

        

# jsdoc.vim

![build](https://github.com/heavenshell/vim-jsdoc/workflows/build/badge.svg)

jsdoc.vim generates [JSDoc](http://usejsdoc.org/) block comments based on a function signature.

![jsdoc.vim](./assets/jsdoc.gif)

## Note

jsdoc.vim supports **Vim8**.

Neovim works since v2.1.0, but if something wrong, send me pull requests to fix it.

If you want use old version checkout [1.0.0](https://github.com/heavenshell/vim-jsdoc/releases/tag/1.0.0).

## Requirements

Node v12.x or above.

## Install

### Vim Plug

```
Plug 'heavenshell/vim-jsdoc', {
\ 'for': ['javascript', 'javascript.jsx','typescript'],
\ 'do': 'make install'
\}
```

PlugUpdate error


If you got `yarn.lock` related error,

```console
error: Your local changes to the following files would be overwritten by merge:
lib/yarn.lock
```

Run following command

```
cd /path/to/plugged/vim-jsdoc
git checkout -- yarn.lock
```

and re-run `PlugUpdate`

### Manual Installation

Since version 2.0.0, jsdoc.vim requires a local copy [lehre](https://www.npmjs.com/package/lehre) installed to the plugin directory.

You can install lehre with:

```console
# cd to
make install
```

If you want to update `lehre` use:

```console
make clean
make install
```

If you want to install lehre manually, you can install from npm.

```console
$ yarn add -D lehre
```

Set installed `/path/to/node_modules/.bin/lehre` path to `g:jsdoc_lehre_path`.

#### Installing on Windows

```console
# cd to /lib
npm install
```

If you want to set the path of [lehre](https://www.npmjs.com/package/lehre) manually on Windows, you should use the path with the file extension `.cmd`, such as `/path/to/node_modules/.bin/lehre.cmd`.

## Usage

1. Move cursor on `function` keyword line
1. Type `:JsDoc` to insert JSDoc
1. Insert JSDoc above the `function` keyword line

## Format

1. Type `:JsDocFormat`
1. Insert JSDoc above the all signatures

## Configuration

Option |Default |Description
:--------------------------|:-------------|:-----------------------
**g:jsdoc_templates_path** |'' |Path to custom template.
**g:jsdoc_formatter** |'jsdoc' |Document block formatter, `jsdoc`, `esdoc`, `tsdoc`
**g:jsdoc_lehre_path** |'./lib/lehre' |Path to [`lehre`](https://www.npmjs.com/package/lehre).

## Formatter

You can choose formatter from [JsDoc](https://jsdoc.app/), [ESDoc](https://esdoc.org/), [TSDoc](https://github.com/microsoft/tsdoc).

If you want to create your own template, see [example template](https://github.com/heavenshell/ts-lehre/tree/master/examples).

## Interactive input

Since ver 2.0.0 input `Allow prompt for interactive input` is deprecated.

If you want input Interactively, use snippet plugin.

See [snippet example template](./examples/snippet_template.js).

## Keymap

You can add following setting to .vimrc

```vim
nmap (jsdoc)
```

Alternatively, you could add the following setting to your .vimrc to search for the last `function` declaration
and puts your jsdoc above it:

```vim
nmap ?function:noh(jsdoc)
```

## Thanks

- This plugin based on https://gist.github.com/3903772#file-jsdoc-vim written by [NAKAMURA, Hisashi](https://gist.github.com/sunvisor)

- The idea of npm packages installation is from [vim-lsp-settings](https://github.com/mattn/vim-lsp-settings).
Highly applicate [@mattn](https://github.com/mattn/) and all vim-lsp-settings contributors.

## LICENSE

New BSD LICENSE