@@ -52,7 +52,7 @@ Use `windows` (or `w`) to access window variables like:
52
52
53
53
``` typescript
54
54
import { Denops } from " https://deno.land/x/denops_std/mod.ts" ;
55
- import { buffers } from " https://deno.land/x/denops_std/variable/mod.ts" ;
55
+ import { windows } from " https://deno.land/x/denops_std/variable/mod.ts" ;
56
56
57
57
export async function main(denops : Denops ): Promise <void > {
58
58
// Set window variable
@@ -72,7 +72,7 @@ Use `tabpages` (or `t`) to access tabpage variables like:
72
72
73
73
``` typescript
74
74
import { Denops } from " https://deno.land/x/denops_std/mod.ts" ;
75
- import { buffers } from " https://deno.land/x/denops_std/variable/mod.ts" ;
75
+ import { tabpages } from " https://deno.land/x/denops_std/variable/mod.ts" ;
76
76
77
77
export async function main(denops : Denops ): Promise <void > {
78
78
// Set tabpage variable
@@ -100,9 +100,78 @@ export async function main(denops: Denops): Promise<void> {
100
100
101
101
// Get vim variable
102
102
console .log (await vim .get (denops , " version" ));
103
+ }
104
+ ```
103
105
104
- // Remove tabpage variable
105
- // Always throw an error
106
- await vim .remove (denops , " version" );
106
+ ### environment (alias e)
107
+
108
+ Use ` environment ` (or ` e ` ) to access environment variables like:
109
+
110
+ ``` typescript
111
+ import { Denops } from " https://deno.land/x/denops_std/mod.ts" ;
112
+ import { environment } from " https://deno.land/x/denops_std/variable/mod.ts" ;
113
+
114
+ export async function main(denops : Denops ): Promise <void > {
115
+ // Set environment variable
116
+ await environment .set (denops , " DENOPS_HELLO" , " world" );
117
+
118
+ // Get environment variable
119
+ console .log (await environment .get (denops , " DENOPS_HELLO" ));
120
+
121
+ // Remove environment variable
122
+ await environment .remove (denops , " DENOPS_HELLO" );
123
+ }
124
+ ```
125
+
126
+ ### register (alias r)
127
+
128
+ Use ` register ` (or ` r ` ) to access register like:
129
+
130
+ ``` typescript
131
+ import { Denops } from " https://deno.land/x/denops_std/mod.ts" ;
132
+ import { register } from " https://deno.land/x/denops_std/variable/mod.ts" ;
133
+
134
+ export async function main(denops : Denops ): Promise <void > {
135
+ // Set register
136
+ await register .set (denops , " a" , " world" );
137
+
138
+ // Get register
139
+ console .log (await register .get (denops , " a" ));
107
140
}
108
141
```
142
+
143
+ Note that ` register.get() ` returns ` defaultValue ` when the register is falsy.
144
+
145
+ ### options, localOptions, and globalOptions (alias o, lo, and go)
146
+
147
+ Use ` options ` (or ` o ` ), ` localOptions ` (or ` lo ` ), or ` globalOptions ` (or ` go ` )
148
+ to access options like:
149
+
150
+ ``` typescript
151
+ import { Denops } from " https://deno.land/x/denops_std/mod.ts" ;
152
+ import {
153
+ globalOptions ,
154
+ localOptions ,
155
+ options ,
156
+ } from " https://deno.land/x/denops_std/variable/mod.ts" ;
157
+
158
+ export async function main(denops : Denops ): Promise <void > {
159
+ // Set option
160
+ await options .set (denops , " filetype" , " world" );
161
+ await localOptions .set (denops , " filetype" , " world" );
162
+ await globalOptions .set (denops , " filetype" , " world" );
163
+
164
+ // Get option
165
+ console .log (await options .get (denops , " filetype" ));
166
+ console .log (await localOptions .get (denops , " filetype" ));
167
+ console .log (await globalOption .get (denops , " filetype" ));
168
+
169
+ // Reset option
170
+ await options .remove (denops , " filetype" );
171
+ await localOptions .remove (denops , " filetype" );
172
+ await globalOption .remove (denops , " filetype" );
173
+ }
174
+ ```
175
+
176
+ Note that ` options.get() ` , ` localOptions.get() ` , or ` globalOption.get() ` returns
177
+ ` defaultValue ` when the option is falsy.
0 commit comments