https://codemirror.net/5/doc/manual.html#addons
points to a demo of the functionality for hints for JavaScript.
On that page: CodeMirror: Autocomplete Demo
it says “ctrl-space to activate autocompletion”
but I click in the editor on a word, say “function”
then delete the last two chars to get “functi”
then type ctrl-space and nothing happens.
I was expecting to see a menu of possible completions
or maybe for it just to complete to “function”.
I must be missing something.
(I’m using the latest Chrome browser on MacOS, running Ventura.)
Anyway, once this is working (or you tell me what I’m doing wrong)
in order to implement this for my CodeMirror application,
do I just have to load the show-hint and javascript-hint addons files,
and that will automatically do the key binding to ctrl-space or
do I need to also bind the functionality (and if so, how?)
I just did a couple hours work on this.
The problems:
confusion between codemirror 5 and codemirror 6.
For instance: https://codemirror.net/examples/autocompletion/
is, I believe for version 6 but does not explicitly state this.
I am using CM 5.
confusion around anyword-hint.
Most of the examples on the web look like you have to “roll your own”,
but then why does
node_modules/codemirror/addon/hint/anyword-hint.js
exist?
In short, codemirror is better than most open source projects at documentation
because most open source projects have no doc.
(admittedly this is a complex topic with lots of options that you might want,
making the simple stuff COMPLEX.)
and essentially I have this working, with, in place of tags, I have
in my JS code:
import “codemirror/addon/hint/show-hint.css”
import “codemirror/addon/hint/show-hint.js”
import “codemirror/addon/hint/javascript-hint.js”
import “codemirror/addon/hint/anyword-hint.js”
and in place of the keybinding “Ctrl-Space”
I have "Ctrl-/ " (control slash)
because it appears than MacOS (which I’m using)
hogs Ctrl-Space
Also, What I think is supposed to be the anyword-hint
doesn’t appear to work at all.
One commenter said that it would be a good idea if
all the “hint” plugins loaded were searched, not just one.
This is such good idea I wonder if it was attempted
to be implemented. But in my code only actual javascript code
is completed.
If you do manage to get anyword-hint working please let me know how.