From a99b1be42af216814e5a2483d295b7d3b108bba9 Mon Sep 17 00:00:00 2001 From: Sandeep Rao Date: Mon, 11 May 2015 16:09:05 +0530 Subject: [PATCH 1/2] Format only Py files --- PyYapf.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/PyYapf.py b/PyYapf.py index 0eab468..049eafa 100644 --- a/PyYapf.py +++ b/PyYapf.py @@ -250,3 +250,18 @@ def run(self, edit): self.view.show_at_center(region) print('PyYapf Completed') + + def is_visible(self): + fName = self.view.file_name() + vSettings = self.view.settings() + syntaxPath = vSettings.get('syntax') + syntax = "" + ext = "" + + if (fName != None): # file exists, pull syntax type from extension + ext = os.path.splitext(fName)[1][1:] + if(syntaxPath != None): + syntax = os.path.splitext(syntaxPath)[0].split('/')[-1].lower() + + return ext == 'py' or "Python" in syntax + From 99ac2bf156367fd5b8e8641b16e0607e1810529b Mon Sep 17 00:00:00 2001 From: Sandeep Rao Date: Mon, 11 May 2015 16:09:38 +0530 Subject: [PATCH 2/2] Inserted Context menu entry --- Context.sublime-menu | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Context.sublime-menu diff --git a/Context.sublime-menu b/Context.sublime-menu new file mode 100644 index 0000000..0586857 --- /dev/null +++ b/Context.sublime-menu @@ -0,0 +1,7 @@ +[ + { + "id": "yapf", + "caption": "PyYapf: Reformat Python", + "command": "yapf" + } +] \ No newline at end of file