You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/getting-started/explanation.md
+33-15Lines changed: 33 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -242,19 +242,28 @@ auto-completion and type checking provided by LSP (Language Server Protocol).
242
242
> Denops v8.0.0 or later. For older versions, use direct URL imports in your
243
243
> TypeScript files.
244
244
245
-
While the examples above use direct URL imports, the recommended approach for Denops plugins is to separate development configuration from runtime dependencies:
246
-
247
-
-**Development configuration**: The root `deno.jsonc` with workspace settings enables development tools (`deno lint`, `deno fmt`, etc.) to work from the project root
248
-
-**Runtime dependencies**: The plugin-specific `deno.jsonc` contains only the import map needed at runtime
249
-
-**No conflicts**: Since each Denops plugin has a unique directory under `denops/`, their configuration files never conflict when installed
250
-
-**Clean separation**: Development tools configuration stays in the repository root, while runtime dependencies are isolated per plugin
251
-
-**Flexible format**: Both `deno.json` and `deno.jsonc` are supported, but `deno.jsonc` is recommended for its comment support
245
+
While the examples above use direct URL imports, the recommended approach for
246
+
Denops plugins is to separate development configuration from runtime
247
+
dependencies:
248
+
249
+
-**Development configuration**: The root `deno.jsonc` with workspace settings
250
+
enables development tools (`deno lint`, `deno fmt`, etc.) to work from the
251
+
project root
252
+
-**Runtime dependencies**: The plugin-specific `deno.jsonc` contains only the
253
+
import map needed at runtime
254
+
-**No conflicts**: Since each Denops plugin has a unique directory under
255
+
`denops/`, their configuration files never conflict when installed
256
+
-**Clean separation**: Development tools configuration stays in the repository
257
+
root, while runtime dependencies are isolated per plugin
258
+
-**Flexible format**: Both `deno.json` and `deno.jsonc` are supported, but
259
+
`deno.jsonc` is recommended for its comment support
252
260
253
261
### Separation of Development and Runtime Configuration
254
262
255
263
The workspace pattern serves two distinct purposes:
256
264
257
-
1.**Development Time**: The root `deno.jsonc` enables development commands to work properly:
265
+
1.**Development Time**: The root `deno.jsonc` enables development commands to
266
+
work properly:
258
267
```json
259
268
{
260
269
"workspace": [
@@ -271,7 +280,8 @@ The workspace pattern serves two distinct purposes:
271
280
}
272
281
```
273
282
274
-
2.**Runtime**: The plugin's `deno.jsonc` contains only what's needed for execution:
283
+
2.**Runtime**: The plugin's `deno.jsonc` contains only what's needed for
284
+
execution:
275
285
```json
276
286
{
277
287
"imports": {
@@ -282,7 +292,9 @@ The workspace pattern serves two distinct purposes:
282
292
283
293
### Why This Separation Matters
284
294
285
-
When Vim/Neovim loads plugins, it merges all plugin directories into the runtime path. If runtime dependencies were in the root configuration file, they would conflict:
295
+
When Vim/Neovim loads plugins, it merges all plugin directories into the runtime
296
+
path. If runtime dependencies were in the root configuration file, they would
297
+
conflict:
286
298
287
299
```
288
300
# After installation, plugins are merged:
@@ -338,13 +350,15 @@ When Vim/Neovim loads plugins, it merges all plugin directories into the runtime
338
350
```
339
351
340
352
This separation ensures:
353
+
341
354
- Development tools like `deno fmt` and `deno lint` work from your project root
342
355
- Runtime dependencies are properly resolved when the plugin is installed
343
356
- No conflicts occur between multiple installed Denops plugins
344
357
345
358
### Alternative: Using import_map.json(c)
346
359
347
-
While the examples above use `deno.jsonc`, Denops also supports `import_map.json(c)` files in the plugin directory:
360
+
While the examples above use `deno.jsonc`, Denops also supports
361
+
`import_map.json(c)` files in the plugin directory:
348
362
349
363
```
350
364
denops/your-plugin-name/
@@ -354,12 +368,13 @@ denops/your-plugin-name/
354
368
355
369
However, there are important differences:
356
370
357
-
1.**Import Maps Standard** (import_map.json) requires both entries for submodules:
371
+
1.**Import Maps Standard** (import_map.json) requires both entries for
372
+
submodules:
358
373
```json
359
374
{
360
375
"imports": {
361
376
"@denops/std": "jsr:@denops/std@^7.0.0",
362
-
"@denops/std/": "jsr:@denops/std@^7.0.0/"// Required for submodules
377
+
"@denops/std/": "jsr:@denops/std@^7.0.0/"// Required for submodules
363
378
}
364
379
}
365
380
```
@@ -368,14 +383,15 @@ However, there are important differences:
368
383
```json
369
384
{
370
385
"imports": {
371
-
"@denops/std": "jsr:@denops/std@^7.0.0"// Handles both cases
386
+
"@denops/std": "jsr:@denops/std@^7.0.0"// Handles both cases
372
387
}
373
388
}
374
389
```
375
390
376
391
> [!IMPORTANT]
377
392
>
378
393
> We recommend using `deno.jsonc` over `import_map.jsonc` because:
394
+
>
379
395
> - It requires less verbose configuration
380
396
> - It's the standard Deno configuration format
381
397
> - It supports additional configuration options beyond imports
@@ -422,7 +438,9 @@ import { Maze } from "maze_generator";
422
438
423
439
### Import Map Structure
424
440
425
-
The `deno.json` file in your Denops plugin directory should contain all the dependencies your plugin needs. This keeps dependency management isolated to each plugin while avoiding conflicts in the merged runtime directory.
441
+
The `deno.json` file in your Denops plugin directory should contain all the
442
+
dependencies your plugin needs. This keeps dependency management isolated to
443
+
each plugin while avoiding conflicts in the merged runtime directory.
426
444
427
445
For example, if your plugin uses additional npm packages:
0 commit comments