improvements to editor support

This commit is contained in:
2024-12-22 14:52:26 -08:00
parent 90b8fd79ae
commit e0c75ff487
4 changed files with 12 additions and 5 deletions

View File

@@ -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 }`

View File

@@ -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

View File

@@ -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 };

View File

@@ -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