Skip to content

Commit

Permalink
add settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbzhong committed Dec 5, 2011
1 parent 97c77e3 commit 4be7738
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
14 changes: 14 additions & 0 deletions Default.sublime-commands
Expand Up @@ -6,5 +6,19 @@
{
"caption": "Closure Linter: Show Closure Linter Result",
"command": "show_closure_linter_result"
},
{
"caption": "Preferences: Closure Linter Settings – Default",
"command": "open_file", "args":
{
"file": "${packages}/sublime-closure-linter/sublime-closure-linter.sublime-settings"
}
},
{
"caption": "Preferences: Closure Linter Settings – User",
"command": "open_file", "args":
{
"file": "${packages}/User/sublime-closure-linter.sublime-settings"
}
}
]
35 changes: 35 additions & 0 deletions Main.sublime-menu
Expand Up @@ -19,5 +19,40 @@
]
}
]
},
{
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"id": "package-settings",
"children":
[
{
"caption": "Closure Linter",
"children":
[
{
"caption": "Settings – Default",
"command": "open_file",
"args":
{
"file": "${packages}/sublime-closure-linter/sublime-closure-linter.sublime-settings"
}
},
{
"caption": "Settings – User",
"command": "open_file",
"args":
{
"file": "${packages}/User/sublime-closure-linter.sublime-settings"
}
}
]
}
]
}
]
}
]
17 changes: 11 additions & 6 deletions gjslint.py
Expand Up @@ -6,6 +6,7 @@
from asyncprocess import *

RESULT_VIEW_NAME = 'gjslint_result_view'
SETTINGS_FILE = "sublime-closure-linter.sublime-settings"

class ShowClosureLinterResultCommand(sublime_plugin.WindowCommand):
"""show closure linter result"""
Expand All @@ -14,11 +15,15 @@ def run(self):

class ClosureLinterCommand(sublime_plugin.WindowCommand):
def run(self):
s = sublime.load_settings(SETTINGS_FILE)

file_path = self.window.active_view().file_name()
file_name = os.path.basename(file_path)
cmd = '/usr/local/bin/gjslint "' + file_path + '"'
cmd = s.get('gjslint_path', 'jslint') + ' ' + s.get('gjslint_flags', '') + ' "' + file_path + '"'

if s.get('debug', False) == True:
print "DEBUG: " + str(cmd)

print "DEBUG: " + str(cmd)
self.buffered_data = ''
self.file_path = file_path
self.file_name = file_name
Expand Down Expand Up @@ -68,7 +73,7 @@ def append_data(self, proc, data, flush=False):
selection_was_at_end = (len(self.output_view.sel()) == 1 and self.output_view.sel()[0] == sublime.Region(self.output_view.size()))
self.output_view.set_read_only(False)
edit = self.output_view.begin_edit()
self.output_view.insert(edit, self.output_view.size(), str.strip())
self.output_view.insert(edit, self.output_view.size(), str)
if selection_was_at_end:
self.output_view.show(self.output_view.size())
self.output_view.end_edit(edit)
Expand Down Expand Up @@ -101,7 +106,9 @@ def on_deactivated(self, view):
if view.name() != RESULT_VIEW_NAME:
return
self.previous_resion = None
self.file_view.erase_regions(RESULT_VIEW_NAME)

if self.file_view:
self.file_view.erase_regions(RESULT_VIEW_NAME)

def on_selection_modified(self, view):
if ClosureLinterEventListener.disabled:
Expand Down Expand Up @@ -143,5 +150,3 @@ def on_selection_modified(self, view):

# highlight file_view line
file_view.add_regions(RESULT_VIEW_NAME, [file_region], "string")


10 changes: 10 additions & 0 deletions sublime-closure-linter.sublime-settings
@@ -0,0 +1,10 @@
{
// Path to the gjslint.
"gjslint_path": "gjslint",

// Flags pass to gjslint.
"gjslint_flags": "",

// debug flag.
"debug": false
}

0 comments on commit 4be7738

Please sign in to comment.