In short, yes. Git Formats intends to add support for the most commonly used syntaxes of git.
Provided syntaxes
- .gitattributes
- .gitconfig
- .gitmodules (not yet associated filetype)
- .gitignore
- git-rebase-todo
- COMMIT_EDITMSG
- MERGE_MSG
- TAG_EDITMSG
Further improve rebase experience
You could also add the following two files to be able to type f
while cursor is on a commit in a git-rebase-todo
to quickly turn it into a fixup commit. This works for all the other shortcuts, too.
Packages/Git Formats/git_rebase.py
import sublime
import sublime_plugin
class GitRebaseOperationCommand(sublime_plugin.TextCommand):
def run(self, edit, cmd):
# validate command
if cmd not in ("drop", "edit", "exec", "fixup", "pick", "reword", "squash"):
return sublime.error_message("Invalid command")
# validate scope
for sel in self.view.sel():
# find first word of current line
pt = self.view.line(sel).a
while self.view.substr(pt) in ' \t':
pt += 1
# replace first word with command string
self.view.replace(edit, self.view.word(pt), cmd)
Packages/Git Formats/Default.sublime-keymap
[
{
"keys": ["d"], "command": "git_rebase_operation", "args": { "cmd": "drop" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "meta.commit.git.rebase", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
],
},
{
"keys": ["e"], "command": "git_rebase_operation", "args": { "cmd": "edit" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "meta.commit.git.rebase", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
],
},
{
"keys": ["f"], "command": "git_rebase_operation", "args": { "cmd": "fixup" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "meta.commit.git.rebase", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
],
},
{
"keys": ["p"], "command": "git_rebase_operation", "args": { "cmd": "pick" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "meta.commit.git.rebase", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
],
},
{
"keys": ["r"], "command": "git_rebase_operation", "args": { "cmd": "reword" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "meta.commit.git.rebase", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
],
},
{
"keys": ["s"], "command": "git_rebase_operation", "args": { "cmd": "squash" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "meta.commit.git.rebase", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
],
},
{
"keys": ["x"], "command": "git_rebase_operation", "args": { "cmd": "exec" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "meta.commit.git.rebase", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
],
},
]