def run(self, edit):
s = sublime.load_settings('phpfmt.sublime-settings')
php_bin = s.get("php_bin", "php")
formatter_path = os.path.join(dirname(realpath(sublime.packages_path())), "Packages", "phpfmt", "fmt.phar")
cmd_passes = [php_bin,formatter_path,'--list-simple'];
print_debug(cmd_passes)
if os.name == 'nt':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
p = subprocess.Popen(cmd_passes, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, startupinfo=startupinfo)
else:
p = subprocess.Popen(cmd_passes, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
out, err = p.communicate()
descriptions = out.decode("utf-8").strip().split(os.linesep)
def on_done(i):
if i >= 0 :
s = sublime.load_settings('phpfmt.sublime-settings')
excludes = s.get('excludes', [])
chosenPass = descriptions[i].split(' ')
option = chosenPass[0]
passDesc = option
if option in excludes:
excludes.remove(option)
msg = "phpfmt: "+passDesc+" disabled"
print_debug(msg)
sublime.status_message(msg)
else:
excludes.append(option)
msg = "phpfmt: "+passDesc+" enabled"
print_debug(msg)
sublime.status_message(msg)
s.set('excludes', excludes)
sublime.save_settings('phpfmt.sublime-settings')
self.view.window().show_quick_panel(descriptions, on_done, sublime.MONOSPACE_FONT)
评论列表
文章目录