Skip to content

Instantly share code, notes, and snippets.

@apires
Created March 20, 2014 19:25
Show Gist options
  • Save apires/9671820 to your computer and use it in GitHub Desktop.
Save apires/9671820 to your computer and use it in GitHub Desktop.
Calling GoCode from Atom
var BufferedProcess = require("atom").BufferedProcess;
module.exports = {
activate: function(state) {
me = this;
atom.workspaceView.command("golang:find-line-def", function(){
me.findLineDef()
});
},
findLineDef: function(){
editor = atom.workspace.activePaneItem;
cursor = editor.getCursorBufferPosition();
fileOffset = editor.getBuffer().characterIndexForPosition(cursor)
complete = new BufferedProcess({
command: "/Users/antonio/go/bin/gocode",
args: ['-f=json','autocomplete', fileOffset],
options: {
stdio: "pipe",
},
stdout: function(x) {console.log("out", x); },
stderr: function(x) {console.log("out", x); }
})
foo.process.stdin.write(atom.workspace.activePaneItem.buffer.cachedText);
foo.process.stdin.end();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment