Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commands.sublime-commands
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"caption": "Gitignore: New gitingore",
"command": "rungibo"
"caption": "Gitignore: New gitignore",
"command": "run_gibo"
}
]
17 changes: 9 additions & 8 deletions gitignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os


class rungiboCommand(sublime_plugin.WindowCommand):
class RunGiboCommand(sublime_plugin.WindowCommand):

path = os.path.join(os.path.dirname(__file__), 'boilerplates')

Expand All @@ -15,26 +15,27 @@ def select(self, index):
if index < 0: return

if index == 0 and self.list[0] == 'Done':
self.write_file()
sublime.active_window().active_view().run_command("write_gibo", {"chosen": self.chosen})
return

self.chosen.append(self.list.pop(index))

if self.list[0] != 'Done':
self.list = ['Done'] + self.list
sublime.set_timeout(lambda: self.window.show_quick_panel(self.list, self.select), 10)

self.window.show_quick_panel(self.list, self.select)
class WriteGiboCommand(sublime_plugin.TextCommand):

path = os.path.join(os.path.dirname(__file__), 'boilerplates')

def write_file(self):
def run(self, edit, chosen):
final = ''

for boilerplate in self.chosen:
for boilerplate in chosen:
path = os.path.join(self.path, boilerplate + '.gitignore')
contents = open(path).read()
final += '### %s ###\n\n%s\n\n' % (boilerplate, contents)

view = sublime.active_window().new_file()
edit = view.begin_edit()
view.insert(edit, 0, final)
view.set_name('.gitignore')
view.end_edit(edit)
view.set_name('.gitignore')