Created
March 20, 2014 19:25
-
-
Save apires/9671820 to your computer and use it in GitHub Desktop.
Calling GoCode from Atom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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