I want to use tern (to add type for every word in my own language ) so I add to my html page this :
<link rel="stylesheet" href="plugin/codemirror/addon/tern/tern.css">
<link rel="stylesheet" href="plugin/codemirror/addon/dialog/dialog.css">
<script src="plugin/codemirror/addon/tern/tern.js"></script>
<script src="plugin/codemirror/addon/dialog/dialog.js"></script>
what I try : I try alot But nothing work :( , I try to write :
"Ctrl-I": function(cm) { CodeMirror.tern.getServer(cm).showType(cm); }, but not work
and I try to write like demo:
<script>
function getURL(url, c) {
var xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.send();
xhr.onreadystatechange = function() {
if (xhr.readyState != 4) return;
if (xhr.status < 400) return c(null, xhr.responseText);
var e = new Error(xhr.responseText || "No response");
e.status = xhr.status;
c(e);
};
}
var server;
getURL("//ternjs.net/defs/ecma5.json", function(err, code) {
if (err) throw new Error("Request for ecma5.json: " + err);
server = new CodeMirror.TernServer({defs: [JSON.parse(code)]});
editor.setOption("extraKeys", {
"Ctrl-Space": function(cm) { server.complete(cm); },
"Ctrl-I": function(cm) { server.showType(cm); },
"Ctrl-O": function(cm) { server.showDocs(cm); },
"Alt-.": function(cm) { server.jumpToDef(cm); },
"Alt-,": function(cm) { server.jumpBack(cm); },
"Ctrl-Q": function(cm) { server.rename(cm); },
"Ctrl-.": function(cm) { server.selectName(cm); }
})
editor.on("cursorActivity", function(cm) { server.updateArgHints(cm); });
});
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: "javascript"
});
But nothing work
so can any body help me what functions I must to call to add my own tern to my own words ???