Skip to content

Commit

Permalink
Added documentation to the settings file and updated some of the sett…
Browse files Browse the repository at this point in the history
…ings structures
  • Loading branch information
Allen Ray committed Dec 1, 2016
1 parent 9e6edd5 commit dcc8db4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
13 changes: 7 additions & 6 deletions Grepmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ def run(self, edit, **args):

def _run(self, args, pattern=None):
# Extract variables from args
ui = args['ui'] if 'ui' in args else Settings().get('ui')
globals = Settings().get('global')
ui = args['ui'] if 'ui' in args else globals.get('ui')
pattern = pattern if pattern else args['pattern']
goto_first = args['goto_first'] if 'goto_first' in args else ui['goto_first']
make_selection = args['make_selection'] if 'make_selection' in args else ui['make_selection']
flags = args['search_flags'] if 'search_flags' in args else Settings().get('search_flags', [])
flags = args['search_flags'] if 'search_flags' in args else globals.get('search_flags', [])

# Actually find all of the instances of the pattern
ignore_case = sublime.IGNORECASE if 'ignore_case' in flags else 0
Expand All @@ -51,7 +52,7 @@ def _run(self, args, pattern=None):
sel.add_all(line_regions)

# Use BetterBookmarks if we're configured to
bbsettings = args['better_bookmarks'] if 'better_bookmarks' in args else Settings().get('better_bookmarks')
bbsettings = args['better_bookmarks'] if 'better_bookmarks' in args else globals.get('better_bookmarks')
if bbsettings['use']:
layer = args['layer'] if 'layer' in args else bbsettings['layer']
self.view.run_command('better_bookmarks', {'subcommand': 'mark_line', 'line': HashMarks(line_regions), 'layer': layer})
Expand All @@ -70,10 +71,10 @@ def on_load_async(self, view):
settings = Settings().get('auto_grep')
if settings['enabled']:
extension = Variable('${file_extension}', view.window())
file_patterns = settings['file_patterns']
extensions = settings['extensions']

if extension in file_patterns.keys():
for pattern_object in file_patterns[extension]:
if extension in extensions.keys():
for pattern_object in extensions[extension]:
if 'enabled' in pattern_object and pattern_object['enabled']:
pattern_list = pattern_object['pattern_list']
if len(pattern_list):
Expand Down
40 changes: 30 additions & 10 deletions Grepmark.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,38 +1,58 @@
{
"auto_grep":
{
// Should marks be added to files with matching extensions based on the configured rules
"enabled": true,
"file_patterns":
// A dictionary of file extensions that contain the auto_grep configuration
"extensions":
{
"py":
[
{
// Should this specific search be run
"enabled": false,
// A list of patterns to search for
"pattern_list": ["def.*"],
// See 'better_bookmarks' in the 'global' section
"better_bookmarks":
{
"use": true,
"layer": "functions"
},
// See 'ui' in the 'global' section
"ui":
{
// Should the viewport scroll to the first occurrence
"goto_first": false,
// Should all matches become the active selection
"make_selection": false
},
// See 'search_flags' in the 'global' section
"search_flags": []
},
],
}
},
"ui":
"global":
{
"goto_first": true,
"make_selection": true
},
"search_flags": ["ignore_case", "literal"],
"better_bookmarks":
{
"use": true,
"layer": "bookmarks"
"ui":
{
// Should the viewport scroll to the first occurrence
"goto_first": true,
// Should all matches become the active selection
"make_selection": true
},
// Search flags:
// ignore_case: Searching doesn't care about letter case
// literal: Searches using strings instead of regular expressions
"search_flags": ["ignore_case", "literal"],
"better_bookmarks":
{
// Should Better Bookmarks be used to mark the file
// https://github.com/dusk125/sublime-betterbookmarks
"use": true,
// Which Better Bookmarks layer should be marked
"layer": "bookmarks"
}
}
}

0 comments on commit dcc8db4

Please sign in to comment.