Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Gist Insert support - by @dlazic88

  • Loading branch information...
commit ab7f5ee316074786d5040d6d94cf93f785219106 1 parent b3bf295
Stefan authored
View
3  Default (Linux).sublime-keymap
@@ -2,5 +2,6 @@
{ "keys": ["ctrl+k", "ctrl+i"], "command": "gist" },
{ "keys": ["ctrl+k", "ctrl+l"], "command": "gist_private" },
{ "keys": ["ctrl+k", "ctrl+s"], "command": "gist_update_file" },
- { "keys": ["ctrl+shift+g"], "command": "gist_list" }
+ { "keys": ["ctrl+shift+g"], "command": "gist_list" },
+ { "keys": ["ctrl+shift+alt+g"], "command": "insert_gist_list" }
]
View
3  Default (OSX).sublime-keymap
@@ -2,5 +2,6 @@
{ "keys": ["super+k", "super+i"], "command": "gist" },
{ "keys": ["super+k", "super+l"], "command": "gist_private" },
{ "keys": ["super+k", "super+s"], "command": "gist_update_file" },
- { "keys": ["ctrl+super+g"], "command": "gist_list" }
+ { "keys": ["ctrl+super+g"], "command": "gist_list" },
+ { "keys": ["ctrl+shift+super+g"], "command": "insert_gist_list" }
]
View
3  Default (Windows).sublime-keymap
@@ -2,5 +2,6 @@
{ "keys": ["ctrl+k", "ctrl+i"], "command": "gist" },
{ "keys": ["ctrl+k", "ctrl+l"], "command": "gist_private" },
{ "keys": ["ctrl+k", "ctrl+s"], "command": "gist_update_file" },
- { "keys": ["ctrl+shift+g"], "command": "gist_list" }
+ { "keys": ["ctrl+shift+g"], "command": "gist_list" },
+ { "keys": ["ctrl+shift+alt+g"], "command": "insert_gist_list" }
]
View
4 Gist.sublime-commands
@@ -12,6 +12,10 @@
"command": "gist_list"
},
{
+ "caption": "Gist: Insert Gist",
+ "command": "insert_gist_list"
+ },
+ {
"caption": "Gist: Add File to Gist",
"command": "gist_add_file"
},
View
1  Main.sublime-menu
@@ -12,6 +12,7 @@
{ "command": "gist", "caption": "Create Public Gist…" },
{ "command": "gist_private", "caption": "Create Private Gist…" },
{ "command": "gist_list", "caption": "Open Gist…" },
+ { "command": "insert_gist_list", "caption": "Insert Gist…" },
{ "command": "gist_add_file", "caption": "Add File to Gist…" },
{ "caption": "-" },
{ "command": "gist_copy_url", "caption": "Copy Gist URL" },
View
5 README.md
@@ -81,6 +81,11 @@ Use the `Gist` / `Add File To Gist` command to see a list of your Gists. Selecti
* Windows and Linux: `Ctrl+Shift+G`
* OS X: `Ctrl+Cmd+G`
+## Insert Gist
+
+* Windows and Linux: "ctrl+shift+alt+g"
+* OS X: "ctrl+shift+super+g"
+
# Information
Source: https://github.com/condemil/Gist
View
20 gist.py
@@ -223,6 +223,18 @@ def open_gist(gist_url):
if os.path.exists(new_syntax_path):
view.set_syntax_file( new_syntax_path )
+def insert_gist(gist_url):
+ gist = api_request(gist_url)
+ files = sorted(gist['files'].keys())
+ for gist_filename in files:
+ view = sublime.active_window().active_view()
+ edit = view.begin_edit()
+ for region in view.sel():
+
+ view.replace(edit, region, gist['files'][gist_filename]['content'])
+
+ view.end_edit(edit)
+
def get_gists():
return api_request(GISTS_URL)
@@ -471,6 +483,14 @@ def handle_gist(self, gist):
def get_window(self):
return self.window
+class InsertGistListCommand(GistListCommandBase, sublime_plugin.WindowCommand):
+ @catch_errors
+ def handle_gist(self, gist):
+ insert_gist(gist['url'])
+
+ def get_window(self):
+ return self.window
+
class GistAddFileCommand(GistListCommandBase, sublime_plugin.TextCommand):
def is_enabled(self):
return self.view.settings().get('gist_url') is None
Please sign in to comment.
Something went wrong with that request. Please try again.