File tree Expand file tree Collapse file tree 7 files changed +343
-850
lines changed Expand file tree Collapse file tree 7 files changed +343
-850
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @sveltejs/repl ' : minor
3
+ ---
4
+
5
+ add vim keybindings
Original file line number Diff line number Diff line change 75
75
"@lezer/highlight" : " ^1.1.6" ,
76
76
"@neocodemirror/svelte" : " 0.0.15" ,
77
77
"@replit/codemirror-lang-svelte" : " ^6.0.0" ,
78
+ "@replit/codemirror-vim" : " ^6.0.14" ,
78
79
"@rich_harris/svelte-split-pane" : " ^1.1.1" ,
79
80
"@rollup/browser" : " ^3.25.3" ,
80
81
"@sveltejs/site-kit" : " 5.2.2" ,
Original file line number Diff line number Diff line change 24
24
/** @type {boolean} */
25
25
export let autocomplete = true ;
26
26
27
+ /** @type {boolean} */
28
+ export let vim = false ;
29
+
27
30
/** @type {ReturnType<typeof createEventDispatcher<{ change: { value: string } }>>} */
28
31
const dispatch = createEventDispatcher ();
29
32
179
182
/** @type {import('@codemirror/state').Extension[]} */
180
183
let extensions = [];
181
184
185
+ $: getExtensions (vim).then ((resolvedExtensions ) => {
186
+ extensions = resolvedExtensions;
187
+ });
188
+
189
+ /**
190
+ * update the extension if and when vim changes
191
+ * @param {boolean} vimEnabled if vim it's included in the set of extensions
192
+ */
193
+ async function getExtensions (vimEnabled ) {
194
+ let extensions = [watcher];
195
+ if (vimEnabled) {
196
+ const { vim } = await import (' @replit/codemirror-vim' ).then ((vimModule ) => ({
197
+ vim: vimModule .vim
198
+ }));
199
+
200
+ extensions .unshift (
201
+ vim ({
202
+ status: true
203
+ })
204
+ );
205
+ }
206
+ return extensions;
207
+ }
208
+
182
209
let cursor_pos = 0 ;
183
210
184
211
$: {
232
259
lint: diagnostics,
233
260
lintOptions: { delay: 200 },
234
261
autocomplete,
235
- extensions: [watcher] ,
262
+ extensions,
236
263
instanceStore: cmInstance
237
264
}}
238
265
on: codemirror: textChange= {({ detail: value }) => {
Original file line number Diff line number Diff line change 9
9
10
10
/** @type {boolean} */
11
11
export let autocomplete;
12
+ /** @type {boolean} */
13
+ export let vim;
12
14
13
15
export function focus () {
14
16
$module_editor? .focus ();
61
63
bind: this = {$module_editor}
62
64
{errorLoc}
63
65
{autocomplete}
66
+ {vim}
64
67
{diagnostics}
65
68
on: change= {handle_change}
66
69
/ >
Original file line number Diff line number Diff line change 27
27
export let showModified = false ;
28
28
export let showAst = false ;
29
29
export let autocomplete = true ;
30
+ export let vim = false ;
30
31
31
32
export function toJSON () {
32
33
return {
344
345
>
345
346
< section slot= " a" >
346
347
< ComponentSelector show_modified= {showModified} on: add on: remove / >
347
- < ModuleEditor errorLoc= {sourceErrorLoc} {autocomplete} / >
348
+ < ModuleEditor errorLoc= {sourceErrorLoc} {autocomplete} {vim} / >
348
349
< / section>
349
350
350
351
< section slot= " b" style= " height: 100%;" >
Original file line number Diff line number Diff line change 36
36
</script >
37
37
38
38
<main >
39
- <Repl bind:this ={repl } showAst autocomplete ={true } previewTheme =" dark" />
39
+ <Repl vim bind:this ={repl } showAst autocomplete ={true } previewTheme =" dark" />
40
40
</main >
41
41
42
42
<style >
You can’t perform that action at this time.
0 commit comments