From e0c75ff4872bb54ef330d0931153b010199e1247 Mon Sep 17 00:00:00 2001 From: Steve Dunham Date: Sun, 22 Dec 2024 14:52:26 -0800 Subject: [PATCH] improvements to editor support --- TODO.md | 2 +- newt-vscode/language-configuration.json | 4 +++- playground/src/main.ts | 7 +++++-- playground/src/monarch.ts | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 7835ee4..2990c3e 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ More comments in code! This is getting big enough that I need to re-find my bearings when fixing stuff. -- [ ] editor - idnent newline on let with no in +- [ ] editor - indent newline on let with no in - [x] Move on to next decl in case of error - [x] for parse error, seek to col 0 token and process next decl - [ ] record initialization sugar, e.g. `{ x := 1, y := 2 }` diff --git a/newt-vscode/language-configuration.json b/newt-vscode/language-configuration.json index 63b9b08..1a5c092 100644 --- a/newt-vscode/language-configuration.json +++ b/newt-vscode/language-configuration.json @@ -1,4 +1,6 @@ { + // see singleton in Tokenizer.idr + "wordPattern": "[^()\\{}\\[\\],.@\\s]+", "comments": { // symbol used for single line comment. Remove this entry if your language does not support line comments "lineComment": "--", @@ -18,7 +20,7 @@ ["[", "]"], ["(", ")"], ["\"", "\""], - ["'", "'"], + // ["'", "'"], causes problems with foo'' ["/-", "-/"] ], // symbols that can be used to surround a selection diff --git a/playground/src/main.ts b/playground/src/main.ts index ae9a930..64e232f 100644 --- a/playground/src/main.ts +++ b/playground/src/main.ts @@ -256,7 +256,10 @@ function Editor({ initialValue }: EditorProps) { let last = ev.changes[ev.changes.length - 1]; const model = editor.getModel(); // figure out heuristics here, what chars do we want to trigger? - if (model && last.text && " ')_".includes(last.text)) { + // the lean one will only be active if it sees you type \ + // and bail if it decides you've gone elsewhere + // it maintains an underline annotation, too. + if (model && last.text && " ')\\".includes(last.text)) { console.log('LAST', last) let { startLineNumber, startColumn } = last.range; const text = model.getValueInRange( @@ -454,7 +457,7 @@ const processOutput = ( let lineNumber = +line + 1; let column = +col + 1; // FIXME - pass the real path in - if (fn && fn == file) { + if (fn && fn !== file) { lineNumber = column = 0; } let start = { column, lineNumber }; diff --git a/playground/src/monarch.ts b/playground/src/monarch.ts index 9f27735..c1e8c4c 100644 --- a/playground/src/monarch.ts +++ b/playground/src/monarch.ts @@ -1,6 +1,8 @@ import * as monaco from "monaco-editor"; export let newtConfig: monaco.languages.LanguageConfiguration = { + // see singleton in Tokenizer.idr + wordPattern: /[^()\\{}\[\],.@\s]+/, comments: { // symbol used for single line comment. Remove this entry if your language does not support line comments lineComment: "--", @@ -19,7 +21,7 @@ export let newtConfig: monaco.languages.LanguageConfiguration = { { open: "[", close: "]" }, { open: "(", close: ")" }, { open: '"', close: '"' }, - { open: "'", close: "'" }, + // { open: "'", close: "'" }, causes problems with foo'' { open: "/-", close: "-/" }, ], // symbols that can be used to surround a selection