Skip to content

Commit

Permalink
Merge 267072b into de9caff
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Feb 15, 2019
2 parents de9caff + 267072b commit ec0ebf5
Show file tree
Hide file tree
Showing 69 changed files with 5,124 additions and 345 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Files and directories with the attribute export-ignore won’t be added to
# archive files. See http://git-scm.com/docs/gitattributes for details.

/tests/ export-ignore
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ env:

matrix:
include:
- os: linux
- name: Linux
os: linux
language: python
python: 3.3
- os: osx
- name: OSX
os: osx
language: generic

before_install:
Expand All @@ -26,10 +28,6 @@ before_install:
install:
- sh travis.sh bootstrap
- sh travis.sh install_package_control
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update;
brew install python || brew upgrade python;
fi
- pip3 install python-coveralls pycodestyle;

script:
Expand Down
20 changes: 20 additions & 0 deletions Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},
{
"keys": ["ctrl+z"],
"command": "gs_diff_undo",
"context": [
{ "key": "setting.command_mode", "operator": "equal", "operand": false },
{ "key": "setting.git_savvy.diff_view", "operator": "equal", "operand": true },
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},

//////////////////
// STAGE_DIFF VIEW //
Expand Down Expand Up @@ -174,6 +183,17 @@
{ "key": "selector", "operator": "equal", "operand": "git-savvy.diff" }
]
},
{
"keys": ["ctrl+,"],
"command": "edit_settings",
"args": {
"base_file": "${packages}/GitSavvy/syntax/diff_view.sublime-settings",
"default": "// Override settings for diff syntax-specific.\n{\n\t$0\n}\n"
},
"context": [
{ "key": "selector", "operator": "equal", "operand": "git-savvy.diff_view" }
]
},
{
"keys": ["ctrl+,"],
"command": "edit_settings",
Expand Down
20 changes: 20 additions & 0 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},
{
"keys": ["super+z"],
"command": "gs_diff_undo",
"context": [
{ "key": "setting.command_mode", "operator": "equal", "operand": false },
{ "key": "setting.git_savvy.diff_view", "operator": "equal", "operand": true },
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},

//////////////////
// STAGE_DIFF VIEW //
Expand Down Expand Up @@ -174,6 +183,17 @@
{ "key": "selector", "operator": "equal", "operand": "git-savvy.diff" }
]
},
{
"keys": ["super+,"],
"command": "edit_settings",
"args": {
"base_file": "${packages}/GitSavvy/syntax/diff_view.sublime-settings",
"default": "// Override settings for diff syntax-specific.\n{\n\t$0\n}\n"
},
"context": [
{ "key": "selector", "operator": "equal", "operand": "git-savvy.diff_view" }
]
},
{
"keys": ["super+,"],
"command": "edit_settings",
Expand Down
20 changes: 20 additions & 0 deletions Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},
{
"keys": ["ctrl+z"],
"command": "gs_diff_undo",
"context": [
{ "key": "setting.command_mode", "operator": "equal", "operand": false },
{ "key": "setting.git_savvy.diff_view", "operator": "equal", "operand": true },
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},

//////////////////
// STAGE_DIFF VIEW //
Expand Down Expand Up @@ -174,6 +183,17 @@
{ "key": "selector", "operator": "equal", "operand": "git-savvy.diff" }
]
},
{
"keys": ["ctrl+,"],
"command": "edit_settings",
"args": {
"base_file": "${packages}/GitSavvy/syntax/diff_view.sublime-settings",
"default": "// Override settings for diff syntax-specific.\n{\n\t$0\n}\n"
},
"context": [
{ "key": "selector", "operator": "equal", "operand": "git-savvy.diff_view" }
]
},
{
"keys": ["ctrl+,"],
"command": "edit_settings",
Expand Down
7 changes: 6 additions & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@
"caption": "git: clone",
"command": "gs_clone"
},
{
"caption": "git: clone recursively",
"command": "gs_clone",
"args": { "recursive": true }
},
{
"caption": "git: diff",
"command": "gs_diff"
Expand Down Expand Up @@ -333,7 +338,7 @@
"command": "gs_view_git_log"
},
{
"caption": "git: tags",
"caption": "git: tag",
"command": "gs_show_tags"
},
{
Expand Down
26 changes: 26 additions & 0 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,24 @@
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},
{
"keys": ["c"],
"command": "gs_status_commit",
"context": [
{ "key": "setting.command_mode", "operator": "equal", "operand": false },
{ "key": "setting.git_savvy.diff_view", "operator": "equal", "operand": true },
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},
{
"keys": ["C"],
"command": "gs_status_commit_unstaged",
"context": [
{ "key": "setting.command_mode", "operator": "equal", "operand": false },
{ "key": "setting.git_savvy.diff_view", "operator": "equal", "operand": true },
{ "key": "setting.git_savvy.diff_view.disable_stage", "operator": "equal", "operand": false }
]
},
{
"keys": ["."],
"command": "gs_diff_navigate",
Expand Down Expand Up @@ -587,6 +605,14 @@
{ "key": "setting.git_savvy.diff_view", "operator": "equal", "operand": true }
]
},
{
"keys": ["tab"],
"command": "gs_diff_toggle_cached_mode",
"context": [
{ "key": "setting.command_mode", "operator": "equal", "operand": false },
{ "key": "setting.git_savvy.diff_view", "operator": "equal", "operand": true }
]
},
{
"keys": ["s"],
"command": "gs_diff_toggle_setting",
Expand Down
23 changes: 22 additions & 1 deletion GitSavvy.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
*/
"git_path": "",

/*
Set custom environment variables for git command execution.
*/
"env": {
},

/*
Change this to `true` when doing dev work on GitSavvy.
*/
Expand Down Expand Up @@ -184,12 +190,27 @@

/*
For each command specified, always include the command line flags
indicated in the global_flags hash.
indicated in the global_flags option AFTER the command.
*/
"global_flags": {
// --no-columns is not supported in Git versions <1.7.11. If Git is configured
// to use columns globally, --no-columns should be added here.
// "branch": ["--no-columns"]
//
// or, configure a GPG key to sign commits with a given key
// "commit": ["-S", "--gpg-sign=<key-id>"]
},

/*
For each command specified, always include the command line flags
indicated in the global_flags option BEFORE the command.
*/
"global_pre_flags": {
// for example, override settings via the "-c" option, e.g
// the following configures a gpg.program no-tty wrapper script
// "commit": ["-c", "gpg.program=./scripts/stgpg.sh"]
// and configure every commit to be signed with your key
// "commit": ["-c", "commit.gpgsign=true"]
},

/*
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ environment:
PACKAGE: "GitSavvy"
SUBLIME_TEXT_VERSION : "3"
UNITTESTING_TAG : "master"
PYTHON: "C:\\Python36-x64"

install:
- ps: git config --global user.email gitsavvy@gitsavvy.com
- ps: git config --global user.name GitSavvy
- ps: appveyor DownloadFile "https://raw.githubusercontent.com/SublimeText/UnitTesting/master/sbin/appveyor.ps1"
- ps: .\appveyor.ps1 "bootstrap" -verbose
- ps: .\appveyor.ps1 "install_package_control" -verbose
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- ps: python -m pip install --upgrade pip
- ps: pip install pycodestyle

Expand Down
14 changes: 13 additions & 1 deletion common/commands/view_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ class GsReplaceViewTextCommand(TextCommand):
a single cursor at the start of the file.
"""

def run(self, edit, text, nuke_cursors=False):
def run(self, edit, text, nuke_cursors=False, restore_cursors=False):
cursors_num = len(self.view.sel())

if restore_cursors:
save_cursors = [self.view.rowcol(s.a) for s in self.view.sel()]
self.view.sel().clear()

is_read_only = self.view.is_read_only()
self.view.set_read_only(False)
self.view.replace(edit, sublime.Region(0, self.view.size()), text)
Expand All @@ -43,6 +48,12 @@ def run(self, edit, text, nuke_cursors=False):
pt = sublime.Region(0, 0)
selections.add(pt)

elif restore_cursors:
self.view.sel().clear()
for (row, col) in save_cursors:
cursor = self.view.text_point(row, col)
self.view.sel().add(cursor)


class GsReplaceRegionCommand(TextCommand):

Expand All @@ -69,6 +80,7 @@ def run(self, edit):
if savvy_settings.get("vintageous_friendly", False) is True:
self.view.settings().set("git_savvy.vintageous_friendly", True)
if savvy_settings.get("vintageous_enter_insert_mode", False) is True:
self.view.settings().set("vintageous_reset_mode_when_switching_tabs", False)
self.view.run_command("_enter_insert_mode")


Expand Down
33 changes: 20 additions & 13 deletions common/theme_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
from xml.etree import ElementTree
import json
from collections import OrderedDict

import sublime
Expand Down Expand Up @@ -57,6 +56,9 @@ def __init__(self, original_color_scheme):
break
self.color_scheme_string = sublime.load_resource(paths[0])

def get_theme_name(self, name):
return "GitSavvy.{}.{}".format(name, self.hidden_theme_extension)

def get_theme_path(self, name):
"""
Save the transformed theme to disk and return the path to that theme,
Expand All @@ -65,8 +67,7 @@ def get_theme_path(self, name):
if not os.path.exists(os.path.join(sublime.packages_path(), "User", "GitSavvy")):
os.makedirs(os.path.join(sublime.packages_path(), "User", "GitSavvy"))

return os.path.join(
"User", "GitSavvy", "GitSavvy.{}.{}".format(name, self.hidden_theme_extension))
return os.path.join("User", "GitSavvy", self.get_theme_name(name))

def add_scoped_style(self, name, scope, **kwargs):
"""
Expand All @@ -86,14 +87,7 @@ def apply_new_theme(self, name, target_view):
"""
Apply the transformed theme to the specified target view.
"""

self.write_new_theme(name)

path_in_packages = self.get_theme_path(name)

# Sublime expects `/`-delimited paths, even in Windows.
theme_path = os.path.join("Packages", path_in_packages).replace("\\", "/")
target_view.settings().set("color_scheme", theme_path)
pass


class XMLThemeGenerator(ThemeGenerator):
Expand All @@ -120,6 +114,15 @@ def write_new_theme(self, name):
out_f.write(STYLES_HEADER.encode("utf-8"))
out_f.write(ElementTree.tostring(self.plist, encoding="utf-8"))

def apply_new_theme(self, name, target_view):
self.write_new_theme(name)

path_in_packages = self.get_theme_path(name)

# Sublime expects `/`-delimited paths, even in Windows.
theme_path = os.path.join("Packages", path_in_packages).replace("\\", "/")
target_view.settings().set("color_scheme", theme_path)


class JSONThemeGenerator(ThemeGenerator):
"""
Expand All @@ -130,7 +133,7 @@ class JSONThemeGenerator(ThemeGenerator):

def __init__(self, original_color_scheme):
super().__init__(original_color_scheme)
self.dict = json.loads(self.color_scheme_string, object_pairs_hook=OrderedDict)
self.dict = OrderedDict(sublime.decode_value(self.color_scheme_string))

def add_scoped_style(self, name, scope, **kwargs):
new_rule = OrderedDict([("name", name), ("scope", scope)])
Expand All @@ -142,4 +145,8 @@ def write_new_theme(self, name):
full_path = os.path.join(sublime.packages_path(), self.get_theme_path(name))

with util.file.safe_open(full_path, "wb", buffering=0) as out_f:
out_f.write(json.dumps(self.dict, indent=4).encode("utf-8"))
out_f.write(sublime.encode_value(self.dict, pretty=True).encode("utf-8"))

def apply_new_theme(self, name, target_view):
self.write_new_theme(name)
target_view.settings().set("color_scheme", self.get_theme_name(name))

0 comments on commit ec0ebf5

Please sign in to comment.