diff --git a/Preferences.sublime-settings b/Preferences.sublime-settings new file mode 100644 index 0000000..6f908c4 --- /dev/null +++ b/Preferences.sublime-settings @@ -0,0 +1,3 @@ +{ + "gitblame.scheme": "dark" +} diff --git a/git-blame.py b/git-blame.py index b41fd1d..7e344b1 100644 --- a/git-blame.py +++ b/git-blame.py @@ -6,19 +6,35 @@ from subprocess import check_output as shell -blame_cache = {} -template = ''' - +template_scheme = {} +template_scheme['light'] = ''' +''' +template_scheme['dark'] = ''' + +''' + +template = ''' + +{scheme} Git Blame: ({user}) -Updated: {date} {time} | +Updated: {date} {time} | [{sha}] | X  @@ -58,7 +74,7 @@ def parse_blame(self, blame): file_path = None # Fix an issue where the username has a space - # Im going to need to do something better though if people + # Im going to need to do something better though if people # start to have multiple spaces in their names. if not isinstance(date[0], int): user = "{0} {1}".format(user, date) @@ -70,7 +86,7 @@ def on_phantom_close(self, href): if href.startswith('copy'): sha = href.replace('copy-','') sublime.set_clipboard(sha) - + self.view.erase_phantoms('git-blame') @@ -82,13 +98,18 @@ def run(self, edit): line = self.view.line(region) (row, col) = self.view.rowcol(region.begin()) full_path = self.view.file_name() - result = self.get_blame(int(row)+1, full_path) + result = self.get_blame(int(row) + 1, full_path) if not result: # Unable to get blame return sha, user, date, time = self.parse_blame(result) - body = template.format(sha=sha, user=user, date=date, time=time) + + settings = sublime.load_settings('Preferences.sublime-settings') + scheme_color = settings.get('gitblame.scheme') or 'dark' + + body = template.format(sha=sha, user=user, date=date, time=time, + scheme=template_scheme.get(scheme_color, '')) phantom = sublime.Phantom(line, body, sublime.LAYOUT_BLOCK, self.on_phantom_close) phantoms.append(phantom)