-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from akalongman/dev
Fixes & Improvements
- Loading branch information
Showing
39 changed files
with
2,451 additions
and
1,556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
language: python | ||
|
||
dist: trusty | ||
|
||
python: | ||
- 3.3 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import re | ||
|
||
import sublime | ||
import subprocess | ||
|
||
|
||
class GoFormatter: | ||
|
||
def __init__(self, formatter): | ||
self.formatter = formatter | ||
self.opts = formatter.settings.get('codeformatter_go_options') | ||
|
||
def format(self, text): | ||
|
||
stderr = '' | ||
stdout = '' | ||
|
||
try: | ||
p = subprocess.Popen( | ||
['gofmt'], | ||
stdin=subprocess.PIPE, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE | ||
) | ||
stdout, stderr = p.communicate(text) | ||
except Exception as e: | ||
stderr = str(e) | ||
|
||
if (not stderr and not stdout): | ||
stderr = 'Formatting error!' | ||
|
||
return stdout, stderr | ||
|
||
def format_on_save_enabled(self, _): | ||
format_on_save = False | ||
if ('format_on_save' in self.opts and self.opts['format_on_save']): | ||
format_on_save = self.opts['format_on_save'] | ||
if (isinstance(format_on_save, str)): | ||
format_on_save = re.search(format_on_save, file_name) is not None | ||
return format_on_save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.