-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 Use JSR instead to support Denops v7
- Loading branch information
1 parent
4e10ba0
commit ab1765b
Showing
16 changed files
with
82 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# API Reference | ||
|
||
There is a standard module [denops_std] to develop denops plugins. It provides | ||
There is a standard module [@denops/std] to develop denops plugins. It provides | ||
various functions to interact with Vim and Neovim and some shorthands to make it | ||
easier to write plugins. | ||
|
||
You can find API references about the module by checking the Deno doc page: | ||
`https://deno.land/x/denops_std/mod.ts`. | ||
`https://jsr.io/@denops/std`. | ||
|
||
[denops_std]: https://deno.land/x/denops_std/mod.ts | ||
[@denops/std]: https://jsr.io/@denops/std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,8 @@ $HOME | |
|
||
Next, write the following TypeScript code in `main.ts`: | ||
|
||
```typescript | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
```typescript:denops/denops-getting-started/main.ts | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,7 @@ easily call. | |
In the Getting Started, we wrote the following code in the `main.ts` file: | ||
|
||
```typescript | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
@@ -107,14 +107,14 @@ Let's break down this code step by step. | |
### About Imports | ||
|
||
```typescript | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
``` | ||
|
||
The first line imports the `Entrypoint` type from the [denops_std] standard | ||
The first line imports the `Entrypoint` type from the [@denops/std] standard | ||
library. You can find detailed information about the library by checking the | ||
URL: `https://deno.land/x/[email protected].0` (remove `/mod.ts`). We fixed the | ||
version in the import URL, so it's recommended to check for details and update | ||
to the latest version URL. | ||
URL: `https://jsr.io/@denops/[email protected].0` (replace `jsr:` to `https://jsr.io/`). | ||
We fixed the version in the import URL, so it's recommended to check for details | ||
and update to the latest version URL. | ||
|
||
Note that we use `import type` syntax, which is part of TypeScript's | ||
[Type-Only Imports and Export](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html). | ||
|
@@ -130,28 +130,11 @@ meaning. Using `import { Entrypoint }` for a type-only import is also valid. | |
> [`denops/@denops-private/denops.ts`](https://github.com/vim-denops/denops.vim/blob/main/denops/%40denops-private/denops.ts), | ||
> but it is not publicly exposed for the reasons mentioned above. | ||
> | ||
> This type information is provided by [denops_core], and [denops_std] simply | ||
> re-exports the type information from [denops_core]. However, [denops_core] is | ||
> intended to be referenced only by [denops.vim] and [denops_std], so Denops | ||
> This type information is provided by [@denops/core], and [@denops/std] simply | ||
> re-exports the type information from [@denops/core]. However, [@denops/core] | ||
> is intended to be referenced only by [denops.vim] and [@denops/std], so Denops | ||
> plugin developers don't need to use it directly. | ||
> [!NOTE] | ||
> | ||
> Prior to denops-std v6.5.0, the `Entrypoint` type was not defined thus | ||
> developers must define the `main` function as like | ||
> | ||
> ```typescript | ||
> import type { Denops } from "https://deno.land/x/[email protected]/mod.ts"; | ||
> | ||
> export function main(denops: Denops): void { | ||
> denops.dispatcher = { | ||
> async hello() { | ||
> await denops.cmd(`echo "Hello, Denops!"`); | ||
> }, | ||
> }; | ||
> } | ||
> ``` | ||
### About Entry Point | ||
|
||
```typescript | ||
|
@@ -162,8 +145,8 @@ export const main: Entrypoint = (denops) => { | |
|
||
The above code exports the `main` function. The `main` function is called by | ||
Denops, and it takes the | ||
[Denops instance](https://deno.land/x/denops_std/mod.ts?s=Denops) (`denops`) as | ||
an argument. Denops plugins use this `denops` to add user-defined APIs or call | ||
[Denops instance](https://jsr.io/@denops/core/doc/~/Denops) (`denops`) as an | ||
argument. Denops plugins use this `denops` to add user-defined APIs or call | ||
Vim's features. | ||
|
||
### About User-Defined APIs | ||
|
@@ -222,17 +205,17 @@ several methods: | |
| `eval` | Evaluate a Vim expression and returns the result. If `ctx` is provided, it is expanded as local variables. | | ||
| `dispatch` | Calls a user-defined API of another Denops plugin and returns the result. | | ||
|
||
Although `denops` provides low-level interfaces, [denops_std] combines these | ||
Although `denops` provides low-level interfaces, [@denops/std] combines these | ||
low-level interfaces to offer higher-level interfaces. Therefore, it's | ||
recommended to use [denops_std] to call Vim's features in actual plugin | ||
recommended to use [@denops/std] to call Vim's features in actual plugin | ||
development. | ||
|
||
For example, use | ||
[`function` module](https://deno.land/x/[email protected].0/function/mod.ts) to | ||
call Vim's function instead of `denops.call` like: | ||
[`function` module](https://jsr.io/@denops/[email protected].0/doc/function/~) to call | ||
Vim's function instead of `denops.call` like: | ||
|
||
```typescript | ||
import * as fn from "https://deno.land/x/[email protected].0/function/mod.ts"; | ||
import * as fn from "jsr:@denops/[email protected].0/function"; | ||
|
||
// Bad (result1 is `unknown`) | ||
const result1 = await denops.call("expand", "%"); | ||
|
@@ -251,8 +234,8 @@ plugin. | |
|
||
- [Tutorial (Hello World)](../tutorial/helloworld/README.md) | ||
- [Tutorial (Maze)](../tutorial/maze/README.md) | ||
- [API reference](https://deno.land/x/denops_std/mod.ts) | ||
- [API reference](https://jsr.io/@denops/std) | ||
|
||
[denops.vim]: https://github.com/vim-denops/denops.vim | ||
[denops_std]: https://deno.land/x/denops_std | ||
[denops_core]: https://deno.land/x/denops_core | ||
[@denops/std]: https://jsr.io/@denops/std | ||
[@denops/core]: https://jsr.io/@denops/core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ Open `denops/denops-helloworld/main.ts` and rewrite the content with the | |
following code: | ||
|
||
```typescript:denops/denops-helloworld/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { assert, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
import { assert, is } from "jsr:@core/unknownutil@3.18.1"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
@@ -29,8 +29,8 @@ for details about User-Defined APIs. | |
> | ||
> While Vim script does not facilitate types, Denops uses `unknown` types on the | ||
> interface between Vim and Denops. That's why we use | ||
> [unknownutil](https://deno.land/x/unknownutil) to ensure that the `name` is of | ||
> type `string` in the above code. | ||
> [unknownutil](https://jsr.io/@core/unknownutil) to ensure that the `name` is | ||
> of type `string` in the above code. | ||
Once you've updated the file, restart Vim, and execute the following command, | ||
you will see the message "Hello, Your name!". | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ the `denops` instance passed to the plugin's `main` function. You can rewrite | |
`main.ts` as follows to register the `DenopsHello` as a Vim command: | ||
|
||
```ts:denops/denops-helloworld/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { assert, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
import { assert, is } from "jsr:@core/unknownutil@3.18.1"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
@@ -61,4 +61,4 @@ In the next step, follow the tutorial to learn how to develop a real Denops | |
plugin. | ||
|
||
- [Tutorial (Maze)](../tutorial/maze/README.md) | ||
- [API reference](https://deno.land/x/denops_std/mod.ts) | ||
- [API reference](https://jsr.io/@denops/std) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ denops-helloworld | |
Here is the content of the `denops/denops-helloworld/main.ts` file: | ||
|
||
```typescript:denops/denops-helloworld/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
console.log("Hello, Denops from TypeScript!"); | ||
|
@@ -45,7 +45,7 @@ export const main: Entrypoint = (denops) => { | |
> `console.error`, etc.) for debug output. The content will be echoed to Vim. | ||
> However, it is not recommended to use `console.log` in production code. | ||
> Instead, use `denops.cmd("echo '...'")` or the `echo` function in the `helper` | ||
> module of the `denops_std` library. | ||
> module of the `@denops/std` library. | ||
Once you've created the file, restart Vim, and "Hello, Denops from TypeScript!" | ||
will be displayed on Vim startup. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,9 @@ Let's modify the plugin to ensure the generated maze fits the current window | |
size. | ||
|
||
```typescript:denops/denops-helloworld/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import * as fn from "https://deno.land/x/[email protected].0/function/mod.ts"; | ||
import { Maze } from "https://deno.land/x/maze_generator@v0.4.0/mod.js"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
import * as fn from "jsr:@denops/[email protected].0/function"; | ||
import { Maze } from "npm:@thewizardbear/maze_generator@0.4.0"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
@@ -31,10 +31,10 @@ export const main: Entrypoint = (denops) => { | |
}; | ||
``` | ||
|
||
In this code, we utilize the `function` module (aliased to `fn`) of `denops_std` | ||
(Denops Standard Library) to call `winwidth()`, `winheight()`, and `setline()` | ||
functions. Then, we create a maze that fits the current window size and write it | ||
to the buffer. | ||
In this code, we utilize the `function` module (aliased to `fn`) of | ||
`@denops/std` (Denops Standard Library) to call `winwidth()`, `winheight()`, and | ||
`setline()` functions. Then, we create a maze that fits the current window size | ||
and write it to the buffer. | ||
|
||
So why do we use the `function` module instead of `denops.call`? With | ||
`denops.call`, developers must know the function name, arguments, return type, | ||
|
@@ -44,13 +44,13 @@ checking, etc. It is more convenient and safe to use the `function` module. | |
|
||
> [!TIP] | ||
> | ||
> The `function` module of the `denops_std` library provides a set of functions | ||
> The `function` module of the `@denops/std` library provides a set of functions | ||
> that are available on both Vim and Neovim. If you'd like to use Vim or Neovim | ||
> only functions, use the `vim` or `nvim` module under the `function` module | ||
> instead. | ||
> | ||
> See the | ||
> [function module of denops_std API document](https://doc.deno.land/https/deno.land/x/denops_std/function/mod.ts) | ||
> [function module of @denops/std API document](https://jsr.io/@denops/[email protected]/doc/function/~) | ||
> for more details. | ||
Restart Vim, rerun the `:Maze` command, and then you can see: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,12 +33,12 @@ opener, generate a maze that fits the current window size, configure the buffer | |
options to make it non-file readonly buffer, etc. | ||
|
||
```ts:denops/denops-maze/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { batch, collect } from "https://deno.land/x/[email protected].0/batch/mod.ts"; | ||
import * as fn from "https://deno.land/x/[email protected].0/function/mod.ts"; | ||
import * as op from "https://deno.land/x/[email protected].0/option/mod.ts"; | ||
import { Maze } from "https://deno.land/x/maze_generator@v0.4.0/mod.js"; | ||
import { assert, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
import { batch, collect } from "jsr:@denops/[email protected].0/batch"; | ||
import * as fn from "jsr:@denops/[email protected].0/function"; | ||
import * as op from "jsr:@denops/[email protected].0/option"; | ||
import { Maze } from "npm:@thewizardbear/maze_generator@0.4.0"; | ||
import { assert, is } from "jsr:@core/unknownutil@3.18.1"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
@@ -68,16 +68,15 @@ export const main: Entrypoint = (denops) => { | |
}; | ||
``` | ||
|
||
In above code, we utilize the following denops_std modules: | ||
In above code, we utilize the following `@denops/std` modules: | ||
|
||
- `batch` and `collect` functions in a `batch` module to execute multiple | ||
commands in a single RPC | ||
- `function` module to call Vim's functions | ||
- `option` module to get and set Vim's options | ||
|
||
See the | ||
[denops_std API document](https://doc.deno.land/https/deno.land/x/denops_std/mod.ts) | ||
for more details about each modules. | ||
See the [denops_std API document](https://jsr.io/@denops/std) for more details | ||
about each modules. | ||
|
||
That's it. Now you can see a smaller maze shown on the window with `:Maze` | ||
command. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ the maze to a buffer so that users can yank the maze with daily Vim operations! | |
Let's modify the code to make the generated maze output to a buffer. | ||
|
||
```ts:denops/denops-maze/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { Maze } from "https://deno.land/x/maze_generator@v0.4.0/mod.js"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
import { Maze } from "npm:@thewizardbear/maze_generator@0.4.0"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,11 @@ buffer after closure. Open the `main.ts` file and modify the `maze` method as | |
follows: | ||
|
||
```typescript:denops/denops-maze/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import * as buffer from "https://deno.land/x/[email protected].0/buffer/mod.ts"; | ||
import * as fn from "https://deno.land/x/[email protected].0/function/mod.ts"; | ||
import * as op from "https://deno.land/x/[email protected].0/option/mod.ts"; | ||
import { Maze } from "https://deno.land/x/maze_generator@v0.4.0/mod.js"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
import * as buffer from "jsr:@denops/[email protected].0/buffer"; | ||
import * as fn from "jsr:@denops/[email protected].0/function"; | ||
import * as op from "jsr:@denops/[email protected].0/option"; | ||
import { Maze } from "npm:@thewizardbear/maze_generator@0.4.0"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,15 @@ For example, if a user executes the `:edit` command on the buffer, the maze will | |
disappear. This is because Vim does not know how to reload the buffer content, | ||
and we must inform Vim about the content of the buffer when it is reloaded. | ||
|
||
In this section, we will use the `buffer` module of `denops_std` to create a | ||
In this section, we will use the `buffer` module of `@denops/std` to create a | ||
proper virtual buffer that concretizes the buffer content. Let's modify the | ||
`main.ts` file as follows: | ||
|
||
```typescript:denops/denops-maze/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import * as buffer from "https://deno.land/x/[email protected].0/buffer/mod.ts"; | ||
import * as fn from "https://deno.land/x/[email protected].0/function/mod.ts"; | ||
import { Maze } from "https://deno.land/x/maze_generator@v0.4.0/mod.js"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
import * as buffer from "jsr:@denops/[email protected].0/buffer"; | ||
import * as fn from "jsr:@denops/[email protected].0/function"; | ||
import { Maze } from "npm:@thewizardbear/maze_generator@0.4.0"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,15 @@ | |
As Denops employs RPC to interact with Vim, the volume of RPC calls | ||
significantly influences the plugin's performance. In this section, we aim to | ||
enhance performance by reducing the number of RPC calls using the `batch` module | ||
from `denops_std`. Let's revise the `main.ts` file as follows: | ||
from `@denops/std`. Let's revise the `main.ts` file as follows: | ||
|
||
```typescript:denops/denops-maze/main.ts | ||
import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { batch, collect } from "https://deno.land/x/[email protected].0/batch/mod.ts"; | ||
import * as buffer from "https://deno.land/x/[email protected].0/buffer/mod.ts"; | ||
import * as fn from "https://deno.land/x/[email protected].0/function/mod.ts"; | ||
import * as op from "https://deno.land/x/[email protected].0/option/mod.ts"; | ||
import { Maze } from "https://deno.land/x/maze_generator@v0.4.0/mod.js"; | ||
import type { Entrypoint } from "jsr:@denops/[email protected]"; | ||
import { batch, collect } from "jsr:@denops/[email protected].0/batch"; | ||
import * as buffer from "jsr:@denops/[email protected].0/buffer"; | ||
import * as fn from "jsr:@denops/[email protected].0/function"; | ||
import * as op from "jsr:@denops/[email protected].0/option"; | ||
import { Maze } from "npm:@thewizardbear/maze_generator@0.4.0"; | ||
|
||
export const main: Entrypoint = (denops) => { | ||
denops.dispatcher = { | ||
|
@@ -96,7 +96,7 @@ properly with `batch` and `collect`. | |
|
||
In the next step, read API references or real-world plugins | ||
|
||
- [API reference](https://deno.land/x/denops_std/mod.ts) | ||
- [API reference](https://jsr.io/@denops/std) | ||
- [lambdalisue/gin.vim](https://github.com/lambdalisue/gin.vim) | ||
- [vim-skk/skkeleton](https://github.com/vim-skk/skkeleton) | ||
- [Shougo/ddu.vim](https://github.com/Shougo/ddu.vim) | ||
|
Oops, something went wrong.