Skip to content

Commit f5bd7ce

Browse files
authored
Merge pull request #37 from vim-denops/gen-functions
👍 Automatically generate `function` module from help of Vim and Neovim
2 parents e0b49a7 + 3989cb2 commit f5bd7ce

File tree

16 files changed

+11107
-2
lines changed

16 files changed

+11107
-2
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ type-check: FORCE ## Type check
2626
test: FORCE ## Test
2727
@deno test --unstable -A
2828

29+
gen: FORCE ## Generate codes
30+
@deno run -A ./scripts/gen-function/gen-function.ts
31+
@make fmt
32+
2933
dlink: FORCE ## Update dlink
3034
(cd denops_std; ${TOOLS}/bin/dlink)
3135
@make fmt

denops_std/function/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# `function`
2+
3+
This module provides entry points of raw Vim and Neovim functions. Most of codes
4+
are automatically generated by
5+
[`gen-function.ts`](../../scripts/gen-function/gen-function.ts) from `eval.txt`
6+
in minimal supported Vim and Neovim versions.
7+
8+
## Example
9+
10+
```typescript
11+
import * as fn from "https://deno.land/x/denops_std/function/mod.ts";
12+
import * as vimFn from "https://deno.land/x/denops_std/function/vim/mod.ts";
13+
import * as nvimFn from "https://deno.land/x/denops_std/function/nvim/mod.ts";
14+
15+
export async function main(denops) {
16+
// fn holds functions exists in both Vim and Neovim
17+
console.log(fn.or(denops, 0, 1));
18+
19+
// vimFn holds functions exists only in Vim
20+
console.log(vimFn.balloon_gettext(denops));
21+
22+
// nvimFn holds functions exists only in Neovim
23+
console.log(nvimFn.api_info(denops));
24+
}
25+
```
26+
27+
## How to add functions manually
28+
29+
To add functions manually, create or modify corresponding module under
30+
`function`, `function/vim`, or `function/nvim` module then make sure that module
31+
is listed in `_manual.ts` uneder corresponding module. After that, execute
32+
`make gen` on the repository top so that `gen-function.ts` automatically remove
33+
duplicated functions from `_generated.ts`.

0 commit comments

Comments
 (0)