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 7575 "@lezer/highlight" : " ^1.1.6" ,
7676 "@neocodemirror/svelte" : " 0.0.15" ,
7777 "@replit/codemirror-lang-svelte" : " ^6.0.0" ,
78+ "@replit/codemirror-vim" : " ^6.0.14" ,
7879 "@rich_harris/svelte-split-pane" : " ^1.1.1" ,
7980 "@rollup/browser" : " ^3.25.3" ,
8081 "@sveltejs/site-kit" : " 5.2.2" ,
Original file line number Diff line number Diff line change 2424 /** @type {boolean} */
2525 export let autocomplete = true ;
2626
27+ /** @type {boolean} */
28+ export let vim = false ;
29+
2730 /** @type {ReturnType<typeof createEventDispatcher<{ change: { value: string } }>>} */
2831 const dispatch = createEventDispatcher ();
2932
179182 /** @type {import('@codemirror/state').Extension[]} */
180183 let extensions = [];
181184
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+
182209 let cursor_pos = 0 ;
183210
184211 $: {
232259 lint: diagnostics,
233260 lintOptions: { delay: 200 },
234261 autocomplete,
235- extensions: [watcher] ,
262+ extensions,
236263 instanceStore: cmInstance
237264 }}
238265 on: codemirror: textChange= {({ detail: value }) => {
Original file line number Diff line number Diff line change 99
1010 /** @type {boolean} */
1111 export let autocomplete;
12+ /** @type {boolean} */
13+ export let vim;
1214
1315 export function focus () {
1416 $module_editor? .focus ();
6163 bind: this = {$module_editor}
6264 {errorLoc}
6365 {autocomplete}
66+ {vim}
6467 {diagnostics}
6568 on: change= {handle_change}
6669 / >
Original file line number Diff line number Diff line change 2727 export let showModified = false ;
2828 export let showAst = false ;
2929 export let autocomplete = true ;
30+ export let vim = false ;
3031
3132 export function toJSON () {
3233 return {
344345 >
345346 < section slot= " a" >
346347 < ComponentSelector show_modified= {showModified} on: add on: remove / >
347- < ModuleEditor errorLoc= {sourceErrorLoc} {autocomplete} / >
348+ < ModuleEditor errorLoc= {sourceErrorLoc} {autocomplete} {vim} / >
348349 < / section>
349350
350351 < section slot= " b" style= " height: 100%;" >
Original file line number Diff line number Diff line change 3636 </script >
3737
3838<main >
39- <Repl bind:this ={repl } showAst autocomplete ={true } previewTheme =" dark" />
39+ <Repl vim bind:this ={repl } showAst autocomplete ={true } previewTheme =" dark" />
4040</main >
4141
4242<style >
You can’t perform that action at this time.
0 commit comments