CodeMirror 6 plugin Beta

Hi dear TiddlyWikians

I’ve marked the CodeMirror 6 plugin as beta with version 0.1.0

I did that after fixing some problems with edit-text operations, cleaning up the code and refactoring it, and after adding colors for all core palettes


For my use cases this plugin is very useful and the configuration options are many

Note: if you used the plugin in its alpha phase you might probably need to delete all modified configuration tiddlers $:/config/codemirror-6/... for the configuration options to show up in the ControlPanel


From now on I’ll invest my time in adding code highlighting for text/vnd.tiddlywiki tiddlers

I have a separate (private) branch on github for that where I implemented the markdown highlighter in javascript plus the html lezer parser (tiddlywiki highlighting needs a modified combination of both)


Here’s the link to the github project of the CodeMirror 6 plugin:


I hope you have fun with the plugin and that you’re triggering many actions using character sequences :grin:

With best wishes from Southtyrol,
Simon

6 Likes

Hi all,

I’ve now removed unneeded packages from the plugin library which should have decreased the size of the plugin significantly

I’ve made selectOnOpen optional (no by default) so that completion options are not selected by default and the Enter key is not trapped. But this can be changed in the Control Panel

Best wishes,
Simon

@BurningTreeC I will have a deep dive into the beta plugin, thanks for your effort with this milstone update. Unlike previously where there were a number of different plugins, they are combined into one. This suits me but it does mean there is a little less visibility of the wealth of features.

  • Perhaps we can crowd source a bit more documentation on these features?

@BurningTreeC Great work, I really like it!
Is there a way to only include tiddlers in the autocomplete popup list if the autocomplete text starts with [[?
I tried adding \[\[ in front of the autocomplete regexp, but that throws an RSoE JavaScript error.

Yaisog

Hi @Yaisog

arrrg, that RSoE should not appear, I’ll check that…
There should be a way to make your request possible, I’ll think about it!
I’ll report back

Hello @Yaisog

what’s the preferred behavior when entering [[ in the editor? When you autocomplete, should the [[ be replaced by the tiddler title or should they stay?

I can imagine that’s a behavior users might want to configure…

Hi @TW_Tones

What would you like to see documented?

Hi @BurningTreeC, in my personal workflow, I’d only need tiddler title autocomplete (AC) when I want to create a link to that tiddler, without needing the wikilink popup. For that, the [[ should remain after the AC result is inserted, followed by the link-closing ]]. The closing brackets might have already been inserted by CM6 itself at that point, depending on how auto-closing of brackets is configured, in which case it need not be inserted by AC or manually.

I do find it slightly distracting if AC with a list of tiddler titles pops up upon typing the start of every word in a prose text. That’s why I’d like the [[ to trigger that. For others it might be perfectly normal, though…

Basicaly the features now available and as listed in the old seperate plugins and in your “try this tiddler” examples. With a few more words in the use and values of the config options.

Expanding this to a list and possibly about a paragraph in each.

I can infer a few and write some examples of you would like. The main help I need is identifying the features so I dont leave any out.

Hi @Yaisog

could you make a test in 5 minutes with version 0.1.7 ?

In the configuration panel you can disable auto-open while typing and you can define [[ as your prefix that should trigger tiddler autocompletion

you should also disable closing brackets

Ah - wait a moment, something’s not working

@Yaisog

now it should work like you want

  • disable closing of brackets
  • set [[ as autocompletion prefix
  • disable “Autocompletion open on typing”

Hi @BurningTreeC: It works in the sense that if I combine the options you mention, the tiddler AC indeed only pops up when the prefix is detected. But then, the useful widget and filter ACs won’t work, only other words from the text. If I enable “AC open on typing” then the prefix is ignored and tiddler AC is always active.

I’m not sure how to best tackle this. I think it might be useful to be able to define a prefix for each AC (e.g. < or <$ for widgets). But then again the rules for e.g. filters seem to be more complicated, since those only pop up when I really do want them, i.e. when writing filter expressions. So those rules should be used when no explicit prefix for filters is defined?

I believe that the implementation could be guided by @Maurycy’s Autocomplete Plugin, to minimize friction when switching between the two. However, I am embarassed to admit that I haven’t installed this plugin yet, though it’s on my long list of things to do, so I cannot really give you details. The feedback I sensed for that plugin was very positive, though.

Have a nice day
Yaisog

@Yaisog the best shortcuts I found in the auto complete plugin were symbol or symbols followed by back tick. This is opposite in order to show we usualy use backticks but can trigger them with the same pattern you would type followed by backtick, which is easy an unshifted on my keyboard…


{`
{{`
{{{`
[`
[[`
<`
<$`

Etc...

1 Like

Hi @Yaisog

Yes I’m not yet fully satisfied with how this is working

What would you like to autocomplete when you type your prefix? Everything? Tiddlers, widgets, filters…?

@Yaisog @TW_Tones

the possibilities for autocompletion in the codemirror 6 plugin are many and I kept them simple in the beginning. Now it’s getting more complicated.

But I wanna tackle the challenge and implement autocompletion in a way that uses configurable triggers to open the autocompletion tooltips.

What makes it more difficult is, that one might also want to remove the trigger characters after autocompletion, another user may want to keep them. So it might be a separate configuration for each trigger, and of course a separate trigger for each category.

I’ll need to think more about this and test but I’m positive that I can make this work.

Best wishes,
Simon

Simon,

Would it not be better to look at ensuring the auto complete plugin can work with code mirror 6

Well, since [[Title]] is the TW syntax for a link to tiddler Title, the [[ prefix should primarily trigger AC of tiddler titles. A prefix of <$ should trigger AC of widgets. Filters would be triggered by e.g. filter=", {{{\s*[ and maybe others. Widgets and filters already trigger correctly in the current implementation, I think.

@TW_Tones’ idea of an extra “trigger character” for manual triggering seems intriguing, too. The backtick is weird on my keyboard, but this could be any other symbol. But this would be independent of your implementation.

1 Like

@TW_Tones

that’s problematic because of the already integrated autocompletion functionality of the codemirror 6 plugin

Hey, I am the author of aforementioned Auto Complete plugin. Different behavior in different contexts is exactly why I opted for adding customizability for my triggers and even with all the options that I already have there is still need for more. Giving the power to the users is certainly a good way to go, though…

…I’d think using a native CM6 plugin would give you way more flexibility, like better contextual completion to for macro attributes based on the macro used, filter auto completion etc. Things that could be difficult to allow customization for the user but also things that are second nature in any serious programming IDE. Food for thought?

Hi @Maurycy

Thank you for your thoughts about this.
I’m currently facing two decisions. Either I make the current implementation more context aware or I focus on the tiddlywiki syntax recognition by implementing a tiddlywiki language mode which would finally be context aware.

I’m currently doing the first and it’s getting better, not yet ready for a release though

But at some point I’ll have to go down the rabbit hole of implementing that language mode.

I think I now finish the work on point one, then freeze the development of the plugin and focus on the tiddlywiki mode even if it’s a difficult task