Auto completion suggestions for user defined macros

Hi all,

One of the things I like the most of TW is its integrated character. We can do most of the functionality it provides, even including writing plugins inside the TW single file, without a lot of external requirement and in that sense is pretty much like Smalltalk: a self-referential metatool to be used and extended inside itself. Well, there is the issue of running it from the huge NodeJS installation… you know, because of the web mess, but you can keep the web “contained and connected” pretty elegantly inside/between TW files.

Despite of that, I miss the auto-completion in the editing tiddlers experience that most IDE offer.
As one creates macros to customize TW usage and syntax, would be pretty cool to have auto-completion suggestions for user defined macros. For example, you would write “<<fi” and you would get “<<firstLetters” and so on.

Do you know if there is something like that currently available in the Code Mirror or Monaco editors? (or maybe via some plugin). If not, how difficult could be to create that?

1 Like

At least for Monaco, you’d probably have to implement a language server.

I don’t know that anyone’s done it. It wouldn’t be immensely difficult for a seasoned developer, but it would definitely be time-consuming.

I have had limited success with edit-comp edit.

I was able to add a configuration pattern and filter to do macros. Do you want the macro’s parameter list to appear on screen to? This tool is not going to do that.

1 Like

Thanks. Just auto-completion for macros macros names is a pretty good start a more that enough for now. Regarding your approach limitation: what would need for showing macro parameters list or at least the amount of them to be filled?

The autocomplete integration itself would be pretty easy to add to tw5-monaco. However where my TW knowledge is lacking is in how to actually get a list of all available macros? If there’s an e.g. filter for that then it shouldn’t be too much work.

1 Like

I’m not sure. To be complete I’d want it to work on all types of macros. Since non-JavaScript macros are variable-like a solution might work for variables too.

I would look a little further for prior work on autocompletion. It has being raised a number of occasions.

For example one equivalent that comes to mind is the Command Palette but there are others. This allows crtl-p t search and insert almost anything.

1 Like

Umm… I don’t know about the TW internals. But @TW_Tones regarding command palette seems pretty interesting. Maybe that could be a starting point to get completions.

I would absolutely go for Gk0Wk/TW5-CodeMirror-Enhanced: An enhanced for CodeMirror framework in TiddlyWiki, including TW5 highlight, WikiLink auto-completion, expandable hint, snippets, etc. (github.com)

1 Like

Yes, for example, we recently add a “The Brain view” snippet to the echarts plugin, then it show up in the “/” menu

(But its search feature seems broken, but I’m working on WYSIWYG editor so don’t plan to fix that…)

1 Like

@linonetwo are the codemirror enhancements ready t go, they look good. Or how can I find out when they are in “Production”.

I just want to point out, although not macro names windows 11 now an any browser at least has a predictive text but one I like is win+. which allows you to insert a range of things including special characters.

I am yet to find out if we could add to the dictionary or an additional custom language however it may be a way to delineate special features.

I think it is the final version, and we use it in our daily note taking. We decided to implement GitHub - tiddly-gittly/slate-write: A WYSIWYG editor for TiddlyWiki. (WIP) instead in the future, so codemirror-enhanced is “ready” I think…