@@ -91,42 +91,42 @@ easily call.
91
91
In the Getting Started, we wrote the following code in the ` main.ts ` file:
92
92
93
93
``` typescript
94
- import type { Denops } from " https://deno.land/x/denops_std@v6.0 .0/mod.ts" ;
94
+ import type { Entrypoint } from " https://deno.land/x/denops_std@v6.5 .0/mod.ts" ;
95
95
96
- export function main( denops : Denops ) : void {
96
+ export const main: Entrypoint = ( denops ) => {
97
97
denops .dispatcher = {
98
98
async hello() {
99
99
await denops .cmd (` echo "Hello, Denops!" ` );
100
100
},
101
101
};
102
- }
102
+ };
103
103
```
104
104
105
105
Let's break down this code step by step.
106
106
107
107
### About Imports
108
108
109
109
``` typescript
110
- import type { Denops } from " https://deno.land/x/denops_std@v6.0 .0/mod.ts" ;
110
+ import type { Entrypoint } from " https://deno.land/x/denops_std@v6.5 .0/mod.ts" ;
111
111
```
112
112
113
- The first line imports the ` Denops ` type from the [ denops_std] standard library.
114
- You can find detailed information about the library by checking the URL:
115
- ` https://deno.land/x/denops_std@v6.0 .0 ` (remove ` /mod.ts ` ). We fixed the version
116
- in the import URL, so it's recommended to check for details and update to the
117
- latest version URL.
113
+ The first line imports the ` Entrypoint ` type from the [ denops_std] standard
114
+ library. You can find detailed information about the library by checking the
115
+ URL: ` https://deno.land/x/denops_std@v6.5 .0 ` (remove ` /mod.ts ` ). We fixed the
116
+ version in the import URL, so it's recommended to check for details and update
117
+ to the latest version URL.
118
118
119
119
Note that we use ` import type ` syntax, which is part of TypeScript's
120
120
[ Type-Only Imports and Export] ( https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html ) .
121
- This syntax can be written as ` import { type Denops } ` with the same meaning.
122
- Using ` import { Denops } ` for a type-only import is also valid.
121
+ This syntax can be written as ` import { type Entrypoint } ` with the same
122
+ meaning. Using ` import { Entrypoint } ` for a type-only import is also valid.
123
123
124
124
> [ !NOTE]
125
125
>
126
126
> Denops plugins are dynamically imported, so there might be differences in
127
127
> Denops versions between development and usage. Therefore, to minimize
128
- > differences between Denops versions, only the ` Denops ` type information is
129
- > exposed. The implementation can be found in
128
+ > differences between Denops versions, only type information is exposed. The
129
+ > implementation can be found in
130
130
> [ ` denops/@denops-private/denops.ts ` ] ( https://github.com/vim-denops/denops.vim/blob/main/denops/%40denops-private/denops.ts ) ,
131
131
> but it is not publicly exposed for the reasons mentioned above.
132
132
>
@@ -135,12 +135,29 @@ Using `import { Denops }` for a type-only import is also valid.
135
135
> intended to be referenced only by [ denops.vim] and [ denops_std] , so Denops
136
136
> plugin developers don't need to use it directly.
137
137
138
+ > [ !NOTE]
139
+ >
140
+ > Prior to denops-std v6.5.0, the ` Entrypoint ` type was not defined thus
141
+ > developers must define the ` main ` function as like
142
+ >
143
+ > ``` typescript
144
+ > import type { Denops } from " https://deno.land/x/[email protected] /mod.ts" ;
145
+ >
146
+ > export function main(denops : Denops ): void {
147
+ > denops .dispatcher = {
148
+ > async hello() {
149
+ > await denops .cmd (` echo "Hello, Denops!" ` );
150
+ > },
151
+ > };
152
+ > }
153
+ > ` ` `
154
+
138
155
### About Entry Point
139
156
140
157
` ` ` typescript
141
- export function main( denops : Denops ) : void {
158
+ export const main: Entrypoint = ( denops ) => {
142
159
// Omitted...
143
- }
160
+ };
144
161
```
145
162
146
163
The above code exports the ` main ` function. The ` main ` function is called by
@@ -211,11 +228,11 @@ recommended to use [denops_std] to call Vim's features in actual plugin
211
228
development.
212
229
213
230
For example, use
214
- [ ` function ` module] ( https://deno.land/x/denops_std@v6.0 .0/function/mod.ts ) to
231
+ [ ` function ` module] ( https://deno.land/x/denops_std@v6.5 .0/function/mod.ts ) to
215
232
call Vim's function instead of ` denops.call ` like:
216
233
217
234
``` typescript
218
- import * as fn from " https://deno.land/x/denops_std@v6.0 .0/function/mod.ts" ;
235
+ import * as fn from " https://deno.land/x/denops_std@v6.5 .0/function/mod.ts" ;
219
236
220
237
// Bad (result1 is `unknown`)
221
238
const result1 = await denops .call (" expand" , " %" );
0 commit comments