forked from yunabe/lgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement go fmt functionality (fix yunabe#16)
- Loading branch information
Showing
8 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Kernel specific extension for lgo. | ||
// http://jupyter-notebook.readthedocs.io/en/stable/extending/frontend_extensions.html#kernel-specific-extensions | ||
|
||
define(function(){ | ||
var formatCells = function () { | ||
var cells = Jupyter.notebook.get_selected_cells(); | ||
for (var i = 0; i < cells.length; i++) { | ||
(function(){ | ||
var editor = cells[i].code_mirror; | ||
var msg = {code: editor.getValue()}; | ||
var cb = function(msg) { | ||
if (!msg || !msg.content || msg.content.status != 'ok') { | ||
// TODO: Show an error message. | ||
return; | ||
} | ||
editor.setValue(msg.content.code); | ||
}; | ||
Jupyter.notebook.kernel.send_shell_message("gofmt_request", msg, {shell: {reply: cb}}); | ||
})(); | ||
} | ||
}; | ||
|
||
var action = { | ||
icon: 'fa-align-left', // a font-awesome class used on buttons, etc | ||
help : 'Format Go', | ||
handler : formatCells | ||
}; | ||
var prefix = 'lgo-kernel'; | ||
var actionName = 'format-code'; | ||
|
||
var fullActionName = Jupyter.actions.register(action, actionName, prefix); | ||
Jupyter.toolbar.add_buttons_group([fullActionName]); | ||
|
||
return { | ||
onload: function(){} | ||
} | ||
}); |
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
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
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
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
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