|
| 1 | +# option |
| 2 | + |
| 3 | +`option`, `option/vim`, and `option/nvim` are modules to provide accessors of |
| 4 | +Vim and Neovim native options. |
| 5 | + |
| 6 | +- [API documentation](https://doc.deno.land/https/deno.land/x/denops_std/option/mod.ts) |
| 7 | +- [API documentation (Vim)](https://doc.deno.land/https/deno.land/x/denops_std/option/vim/mod.ts) |
| 8 | +- [API documentation (Neovim)](https://doc.deno.land/https/deno.land/x/denops_std/option/nvim/mod.ts) |
| 9 | + |
| 10 | +Most of codes are automatically generated by |
| 11 | +[`gen-option.ts`](../../scripts/gen-option/gen-option.ts) from `options.txt` in |
| 12 | +minimal supported Vim and Neovim versions. |
| 13 | + |
| 14 | +## Example |
| 15 | + |
| 16 | +```typescript |
| 17 | +import * as op from "https://deno.land/x/denops_std/option/mod.ts"; |
| 18 | +import * as vimOp from "https://deno.land/x/denops_std/option/vim/mod.ts"; |
| 19 | +import * as nvimOp from "https://deno.land/x/denops_std/option/nvim/mod.ts"; |
| 20 | + |
| 21 | +export async function main(denops) { |
| 22 | + // Get value of the option. |
| 23 | + // `get` is available on any options |
| 24 | + // `getGlobal` is available on only global options |
| 25 | + // `getLocal` is available on only local options |
| 26 | + console.log(await op.filetype.get(denops)); |
| 27 | + console.log(await op.filetype.getGlobal(denops)); |
| 28 | + console.log(await op.filetype.getLocal(denops)); |
| 29 | + |
| 30 | + // Set value of the option. |
| 31 | + // `set` is available on any options |
| 32 | + // `setGlobal` is available on only global options |
| 33 | + // `setLocal` is available on only local options |
| 34 | + await op.filetype.set(denops, "hello"); |
| 35 | + await op.filetype.setGlobal(denops, "hello"); |
| 36 | + await op.filetype.setLocal(denops, "hello"); |
| 37 | + |
| 38 | + // Reset the option. |
| 39 | + // `reset` is available on any options |
| 40 | + // `resetGlobal` is available on only global options |
| 41 | + // `resetLocal` is available on only local options |
| 42 | + await op.filetype.reset(denops); |
| 43 | + await op.filetype.resetGlobal(denops); |
| 44 | + await op.filetype.resetLocal(denops); |
| 45 | + |
| 46 | + // vimOp has options only exist in Vim |
| 47 | + console.log(await vimOp.compatible.get(denops)); |
| 48 | + |
| 49 | + // nvimOp has options only exist in Neovim |
| 50 | + console.log(await nvimOp.shada.get(denops)); |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +## How to add options manually |
| 55 | + |
| 56 | +To add options manually, create or modify corresponding module under `option`, |
| 57 | +`option/vim`, or `option/nvim` module then make sure that module is listed in |
| 58 | +`_manual.ts` under corresponding module. After that, execute `make gen` on the |
| 59 | +repository top so that `gen-option.ts` automatically remove duplicated options |
| 60 | +from `_generated.ts`. |
0 commit comments