Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement basic code completion #1189

Merged
merged 31 commits into from
Jun 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
808bb95
Let us begin
gjtorikian Dec 22, 2012
dbca444
Implement keybindings and such
gjtorikian Dec 22, 2012
a640e4c
add autocompleter
nightwing Dec 22, 2012
5fa87f8
Bring in Harutyun's code
gjtorikian Dec 23, 2012
b132200
Merge updates
gjtorikian Dec 23, 2012
dcdcd81
Fix it up
gjtorikian Dec 23, 2012
e43bee0
Get rid of my junk
gjtorikian Dec 23, 2012
ef19fdb
First pass at Haurtyun UI + C9 doc parsing
gjtorikian Dec 24, 2012
818dba5
Some added UX behaviors
gjtorikian Dec 24, 2012
69e4152
Add autocompletion for language keywords
gjtorikian Dec 27, 2012
cd19233
Improve UX, drop dead code
gjtorikian Jan 4, 2013
b811f1d
Fix rerender on text insertion
gjtorikian Jan 4, 2013
6f17611
Fix failing test
gjtorikian Jan 4, 2013
06c10fb
One more test fix
gjtorikian Jan 4, 2013
7293bb1
fix popup
nightwing Jan 7, 2013
5c1db2d
tweak the popup some more
nightwing Apr 11, 2013
dc19834
revert changes to worker
nightwing Apr 12, 2013
68ebf08
cleanup
nightwing Apr 12, 2013
df115ba
add snippets placeholder files for all languages
nightwing Apr 13, 2013
a399d14
cleanup
nightwing Apr 13, 2013
f6f4757
style improvements
nightwing May 28, 2013
c2b7d1f
better style for match highlight in popup
nightwing Jun 1, 2013
c223f59
add scope to snippets.js files
nightwing Jun 3, 2013
36c166b
force using tabs in makefile and snippets modes
nightwing Jun 3, 2013
35a9dc5
hide the popup when editor is scrolled
nightwing Jun 8, 2013
ac9bb72
revert to simpler range tracking model for now
nightwing Jun 8, 2013
b36c4c6
include split in build
nightwing Jun 8, 2013
917e4b9
fix typo in clojure mode
nightwing Jun 8, 2013
af2a2e2
revert change to config.js
nightwing Jun 8, 2013
156d9a7
load snippet files automatically
nightwing Jun 9, 2013
db1118c
fix typo
nightwing Jun 9, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 31 additions & 6 deletions Makefile.dryice.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function ace() {
source: ACE_HOME + "/ChangeLog.txt",
dest: BUILD_DIR + "/ChangeLog.txt"
});

return project;
}

Expand Down Expand Up @@ -211,7 +211,7 @@ function demo(project) {
});

var demo = copy.createDataObject();

project.assumeAllFilesLoaded();
copy({
source: [{
Expand Down Expand Up @@ -309,7 +309,7 @@ var buildAce = function(options) {
for(var key in defaults)
if (!options.hasOwnProperty(key))
options[key] = defaults[key];

generateThemesModule(options.themes);

addSuffix(options);
Expand All @@ -334,7 +334,7 @@ var buildAce = function(options) {
filter: [ copy.filter.moduleDefines ],
dest: ace
});

if (options.coreOnly)
return project;

Expand All @@ -349,6 +349,7 @@ var buildAce = function(options) {
project.assumeAllFilesLoaded();
options.modes.forEach(function(mode) {
console.log("mode " + mode);
addSnippetFile(mode, project, targetDir, options);
copy({
source: [{
project: cloneProject(project),
Expand Down Expand Up @@ -441,7 +442,7 @@ var buildAce = function(options) {
dest: BUILD_DIR + '/ace-min.js'
});
}

return project;
};

Expand All @@ -460,6 +461,30 @@ var buildAce = function(fn) {
}
}(buildAce);

var addSnippetFile = function(modeName, project, targetDir, options) {
var snippetFilePath = ACE_HOME + "/lib/ace/snippets/" + modeName;
if (!fs.existsSync(snippetFilePath + ".js")) {
copy({
source: ACE_HOME + "/tool/snippets.tmpl.js",
dest: snippetFilePath + ".js",
filter: [
function(t) {return t.replace(/%modeName%/g, modeName);}
]
});
}
if (!fs.existsSync(snippetFilePath + ".snippets")) {
fs.writeFileSync(snippetFilePath + ".snippets", "")
}
copy({
source: [{
project: cloneProject(project),
require: [ 'ace/snippets/' + modeName ]
}],
filter: getWriteFilters(options, "mode"),
dest: targetDir + "/snippets/" + modeName + ".js"
});
}

var textModules = {}
var detectTextModules = function(input, source) {
if (!source)
Expand All @@ -469,7 +494,7 @@ var detectTextModules = function(input, source) {
input = input.toString();

var module = source.isLocation ? source.path : source;

input = input.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
if (/\.css$/.test(module)) {
// remove unnecessary whitespace from css
Expand Down
51 changes: 25 additions & 26 deletions demo/kitchen-sink/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ env.editor.commands.addCommands([{
bindKey: "ctrl+enter",
exec: function(editor) {
try {
var r = eval(editor.getCopyText()||editor.getValue());
var r = window.eval(editor.getCopyText()||editor.getValue());
} catch(e) {
r = e;
}
Expand Down Expand Up @@ -196,7 +196,7 @@ commands.addCommand({
exec: function() {alert("Fake Save File");}
});

var keybindings = {
var keybindings = {
ace: null, // Null = use "default" keymapping
vim: require("ace/keyboard/vim").handler,
emacs: "ace/keyboard/emacs",
Expand Down Expand Up @@ -431,7 +431,7 @@ bindDropdown("split", function(value) {
sp.setSplits(1);
} else {
var newEditor = (sp.getSplits() == 1);
sp.setOrientation(value == "below" ? sp.BELOW : sp.BESIDE);
sp.setOrientation(value == "below" ? sp.BELOW : sp.BESIDE);
sp.setSplits(2);

if (newEditor) {
Expand Down Expand Up @@ -517,17 +517,9 @@ net.loadScript("https://rawgithub.com/nightwing/emmet-core/master/emmet.js", fun
})


require("ace/placeholder").PlaceHolder;
// require("ace/placeholder").PlaceHolder;

var snippetManager = require("ace/snippets").snippetManager
var jsSnippets = require("ace/snippets/javascript");
window.snippetManager = snippetManager
saveSnippets()

function saveSnippets() {
jsSnippets.snippets = snippetManager.parseSnippetFile(jsSnippets.snippetText);
snippetManager.register(jsSnippets.snippets, "javascript")
}
var snippetManager = require("ace/snippets").snippetManager;

env.editSnippets = function() {
var sp = env.split;
Expand All @@ -538,25 +530,32 @@ env.editSnippets = function() {
sp.setSplits(1);
sp.setSplits(2);
sp.setOrientation(sp.BESIDE);
var editor = sp.$editors[1]
if (!env.snippetSession) {
var file = jsSnippets.snippetText;
env.snippetSession = doclist.initDoc(file, "", {});
env.snippetSession.setMode("ace/mode/tmsnippet");
env.snippetSession.setUseSoftTabs(false);
var editor = sp.$editors[1];
var id = sp.$editors[0].session.$mode.$id || "";
var m = snippetManager.files[id];
if (!doclist["snippets/" + id]) {
var text = m.snippetText;
var s = doclist.initDoc(text, "", {});
s.setMode("ace/mode/snippets");
doclist["snippets/" + id] = s
}
editor.on("blur", function() {
jsSnippets.snippetText = editor.getValue();
saveSnippets();
m.snippetText = editor.getValue();
snippetManager.unregister(m.snippets);
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
snippetManager.register(m.snippets);
})
sp.$editors[0].once("changeMode", function() {
sp.setSplits(1);
})
editor.setSession(env.snippetSession, 1);
editor.setSession(doclist["snippets/" + id], 1);
editor.focus();
}

ace.commands.bindKey("Tab", function(editor) {
var success = snippetManager.expandWithTab(editor);
if (!success)
editor.execCommand("indent");
require("ace/ext/language_tools");
env.editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true
})

});