tags: configuration | |
title: $:/config/CodeMirror | |
type: application/json | |
{ | |
"require": [ | |
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js", | |
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js", | |
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js", | |
"$:/plugins/tiddlywiki/codemirror/keymap/vim.js", | |
"$:/plugins/tiddlywiki/codemirror/addon/edit/matchbrackets.js", | |
"$:/plugins/tiddlywiki/codemirror/addon/edit/closebrackets.js", | |
"$:/plugins/tiddlywiki/codemirror/keymap/sublime.js" | |
], | |
"configuration": { | |
"keyMap": "sublime", | |
"showCursorWhenSelecting": true, | |
"matchBrackets":true, | |
"autoCloseBrackets" : true, | |
"theme": "erlang-dark" | |
} | |
} |
I checked again the codemirror plugin documentation.
Did you read it? Try to create the $:/config/CodeMirror tiddler as descirbed and try to edit a javascript, html or JSON tiddler.
You should see a big difference.
And what does it say about the documentation if a reasonably competent user can't find it?
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.
Here is a codemirror plugin version where I included some themes and some useful tools like match-bracketI don't know if it works with never versions of TW5, just try it with tw5.0.15 or so.
simply drag the .tid into your TW5 that runs inside the browser. Tid files are just TW5's uniform way to store and transport tiddlers. In this case you don't need to worry about Node.js. A .tid file contains either a single tiddler or a plugin and the plugin in turn contains multiple (shadow) tiddlers.
Regards,
TheDiveO
Please download this repository as zip and check it out. There are several ready to test tiddlywiky files with different implementations of Codemirror :
https://github.com/danielo515/TW5-CodemirrorPluginTest
They are pretty old, but maybe can help you to see it is useful for you.
The reason you can not write is probably because you have vim mode selected. Try hitting the i key. Or you can just remove the key mapping from the config Codemirror plugin.
I oopened a thread at tiddlywiky Dev with that exact idea: to make tiddlywiky its own development environment. No one was interested. I made some experiments including more libraries into Codemirror from the official Codemirror repository, so maybe I can help you to include it in your plugin. Check this repo and let me know what do you think :
https://www.dropbox.com/sh/xl7k4qe0ef8p14z/AAA0pKVOD95oM8ud8VYQAJEka?dl=0
hint/javascript-hint.js
for example.So I'll just start describing the configurations I have found now.
Convention
$:/plugins/tiddlywiki/codemirror/addon/edit/closebrackets.js"
for codemirror with this code : http://codemirror.net/addon/edit/closebrackets.js , that will mean :$:/plugins/tiddlywiki/codemirror/addon/edit/closebrackets.js".
Add a field : "module-type", and fill it with "library".
Configuration:
{
"require": [
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js"
],
"configuration": {
"showCursorWhenSelecting": true
}
}
$:/config/CodeMirror" and put the given configuration in the text field. You also have to set the type of the tiddler to : "application/json". Finally, you have to reload the page to apply the new configuration.
Basic configuration
Configuration:
{
"require": [
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js",
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js",
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js",
"$:/plugins/tiddlywiki/codemirror/addon/edit/matchbrackets.js"
],
"configuration": {
"matchBrackets":true,
"showCursorWhenSelecting": true
}
}
When editing a tiddler, no matter what the type of the tiddler is set to, you should see matching brackets being highlighted whenever the cursor is next to one of them.
Adding closing brackets
Add a tiddler "$:/plugins/tiddlywiki/codemirror/addon/edit/closebrackets.js"
for codemirror with this code : http://codemirror.net/addon/edit/closebrackets.js
Configuration:
{
"require": [
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js",
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js",
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js",
"$:/plugins/tiddlywiki/codemirror/addon/edit/matchbrackets.js",
"$:/plugins/tiddlywiki/codemirror/addon/edit/closebrackets.js"
],
"configuration": {
"showCursorWhenSelecting": true,
"matchBrackets":true,
"autoCloseBrackets":true
}
}
Consequences:
(),[],{},'' and ""
Adding HTML coloring
Add a tiddler "$:/plugins/tiddlywiki/codemirror/
for codemirror with this code : https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/xml/xml.js mode/xml/xml.js
"
Configuration:
{
"require": [
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js",
"$:/plugins/tiddlywiki/codemirror/mode/xml/xml.js",
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js",
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js"
],
"configuration": {
"showCursorWhenSelecting": true
}
}
Edit a tiddler, set the type to : "text/html", and add this text :
<html>
<body>
<div id="test">
</div>
</body>
</html>
You should see the tags being coloured in green.
Adding closing tags
"$:/plugins/tiddlywiki/codemirror/addon/edit/closetags.js" for codemirror with this code :
http://codemirror.net/addon/edit/closetag.js Configuration:
{
"require": [
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js",
"$:/plugins/tiddlywiki/codemirror/mode/xml/xml.js",
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js",
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js",
"$:/plugins/tiddlywiki/codemirror/addon/edit/closetags.js"
],
"configuration": {
"showCursorWhenSelecting": true,
"autoCloseTags":true
}
}
If you edit a tiddler with the type "text/html" and write :
<html>
Then the closing tag </html> should appear.
Adding matching tags
Add the tiddler : "$:/plugins/tiddlywiki/codemirror/addon/edit/matchtags.js" for codemirror with this code:
http://codemirror.net/addon/edit/matchtags.js
Configuration:
{
"require": [
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js",
"$:/plugins/tiddlywiki/codemirror/mode/xml/xml.js",
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js",
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js",
"$:/plugins/tiddlywiki/codemirror/addon/edit/matchtags.js"
],
"configuration": {
"showCursorWhenSelecting": true,
"matchTags": {"bothTags": true},
"extraKeys": {"Ctrl-J": "toMatchingTag"}
}
}
If you edit a tiddler that has the type : "text/html" and write this code :
<html>
<div id="click here and press CTRL+J">
<ul>
<li>
</li>
</ul>
</div>
</html>
Then if you click on a tag and press CTRL+J, your cursor will select the matching tag. Supposedly, it should highlight the pair when clicking a tag. However, that part doesn't work, I don't know why yet. I suspect this is because of some missing css, but I haven't found it.
Adding folding tags
Add the following tiddlers for codemirror :
- "$:/plugins/tiddlywiki/codemirror/addon/fold/foldcode.js" with this code :
http://codemirror.net/addon/fold/foldcode.js
- "$:/plugins/tiddlywiki/codemirror/addon/fold/xml-fold.js" with this code :
https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/fold/xml-fold.js
- "$:/plugins/tiddlywiki/codemirror/addon/fold/foldgutter.js" with this code :
http://codemirror.net/addon/fold/foldgutter.js
Then add the following tiddler "$:/plugins/tiddlywiki/codemirror/addon/fold/foldgutter.css" BUT IT IS NOT FOR CODEMIRROR.
Add the tag : "$:/tags/Stylesheet" to it and fill the text field with this code : http://codemirror.net/addon/fold/foldgutter.css.
Configuration:
{
"require": [
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js",
"$:/plugins/tiddlywiki/codemirror/mode/xml/xml.js",
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js",
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js",
"$:/plugins/tiddlywiki/codemirror/addon/fold/foldcode.js",
"$:/plugins/tiddlywiki/codemirror/addon/fold/xml-fold.js",
"$:/plugins/tiddlywiki/codemirror/addon/fold/foldgutter.js"
],
"configuration": {
"showCursorWhenSelecting": true,
"matchTags": {"bothTags": true},
"foldGutter": true,
"gutters": ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
}
}
Consequences:
Now if you type the below code in a tiddler with the type : "text/html" :
<html>
<div>
<ul>
</ul>
</div>
</html>
You should see little arrows just next to the line numbers. Clicking on it will have the effect to fold the code (or unfold it).
That's it for today. I hope this helps some of you.
Kind Regards,
Erwan
Adding syntax colouring for C
$:/plugins/tiddlywiki/codemirror/mode/clike/clike.js
with this code : https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/clike/clike.js
Configuration:
{
"require": [
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js",
"$:/plugins/tiddlywiki/codemirror/mode/clike/clike.js",
"$:/plugins/tiddlywiki/codemirror/mode/xml/xml.js",
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js",
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js",
"$:/plugins/tiddlywiki/codemirror/addon/fold/foldcode.js",
"$:/plugins/tiddlywiki/codemirror/addon/fold/xml-fold.js",
"$:/plugins/tiddlywiki/codemirror/addon/fold/foldgutter.js"
,
"$:/plugins/tiddlywiki/codemirror/addon/fold/brace-fold.js",
"$:/plugins/tiddlywiki/codemirror/addon/fold/comment-fold.js",
"$:/plugins/tiddlywiki/codemirror/addon/fold/indent-fold.js"
],
"configuration": {
"showCursorWhenSelecting": true,
"matchTags": {"bothTags": true},
"foldGutter": true,
"gutters": ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
}
}
$:/config/EditorTypeMappings/text/x-csrc
and fill the text field with : codemirror.Consequences:
You should see your code being coloured.For your particular use Hugo, you should use this code https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/tiddlywiki/tiddlywiki.js instead of the clike/clike.js I gave.
And you should also add a css sheet (a tiddler with the tag $:/tags/Stylesheet containing the css code) with this code : https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/tiddlywiki/tiddlywiki.css
I haven tested it with the tiddlywiki mode though.
Is not as difficult as you think. On the info section of each tiddler you have a link to github. You can edit that tiddler on GitHub at it will create a fork for you. Regards
all the best