Permalink
Browse files

Updated coldfusion formatter

  • Loading branch information...
1 parent dcad942 commit 472ca1ccbf91a002800081be9854c9872380c5d8 @elpeix elpeix committed Jan 20, 2016
Showing with 6,635 additions and 63,231 deletions.
  1. +1 −0 .gitignore
  2. +107 −44 CodeFormatter.py
  3. +18 −0 CodeFormatter.sublime-commands
  4. +172 −134 CodeFormatter.sublime-settings
  5. +21 −35 LICENSE
  6. +200 −122 README.md
  7. +0 −71 codeformatter/coldfusionformater.py
  8. +64 −0 codeformatter/coldfusionformatter.py
  9. +48 −41 codeformatter/cssformatter.py
  10. +137 −86 codeformatter/formatter.py
  11. +40 −41 codeformatter/htmlformatter.py
  12. +110 −79 codeformatter/jsformatter.py
  13. +148 −176 codeformatter/lib/coldfusionbeautifier/__init__.py
  14. +241 −106 codeformatter/lib/cssbeautifier/__init__.py
  15. +121 −142 codeformatter/lib/htmlbeautifier/__init__.py
  16. +1,203 −766 codeformatter/lib/jsbeautifier/__init__.py
  17. +1 −1 codeformatter/lib/jsbeautifier/__version__.py
  18. +838 −0 codeformatter/lib/jsbeautifier/six.py
  19. +25 −0 codeformatter/lib/jsbeautifier/unpackers/README.specs.mkd
  20. +15 −7 codeformatter/lib/jsbeautifier/unpackers/packer.py
  21. +0 −1,993 codeformatter/lib/phpbeautifier/Archive/Tar.php
  22. +0 −1,492 codeformatter/lib/phpbeautifier/Beautifier.php
  23. +0 −382 codeformatter/lib/phpbeautifier/Beautifier/Batch.php
  24. +0 −122 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output.php
  25. +0 −85 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output/Directory.php
  26. +0 −58 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output/DirectoryBz2.php
  27. +0 −58 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output/DirectoryGz.php
  28. +0 −80 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output/DirectoryTar.php
  29. +0 −108 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output/Files.php
  30. +0 −45 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output/FilesBz2.php
  31. +0 −45 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output/FilesGz.php
  32. +0 −88 codeformatter/lib/phpbeautifier/Beautifier/Batch/Output/FilesTar.php
  33. +0 −286 codeformatter/lib/phpbeautifier/Beautifier/Common.php
  34. +0 −74 codeformatter/lib/phpbeautifier/Beautifier/Decorator.php
  35. +0 −38 codeformatter/lib/phpbeautifier/Beautifier/Exception.php
  36. +0 −325 codeformatter/lib/phpbeautifier/Beautifier/Filter.php
  37. +0 −111 codeformatter/lib/phpbeautifier/Beautifier/Filter/ArrayNested.filter.php
  38. +0 −894 codeformatter/lib/phpbeautifier/Beautifier/Filter/Default.filter.php
  39. +0 −72 codeformatter/lib/phpbeautifier/Beautifier/Filter/DocBlock.filter.php
  40. +0 −91 codeformatter/lib/phpbeautifier/Beautifier/Filter/EqualsAlign.filter.php
  41. +0 −79 codeformatter/lib/phpbeautifier/Beautifier/Filter/Fluent.filter.php
  42. +0 −295 codeformatter/lib/phpbeautifier/Beautifier/Filter/IndentStyles.filter.php
  43. +0 −209 codeformatter/lib/phpbeautifier/Beautifier/Filter/ListClassFunction.filter.php
  44. +0 −162 codeformatter/lib/phpbeautifier/Beautifier/Filter/Lowercase.filter.php
  45. +0 −114 codeformatter/lib/phpbeautifier/Beautifier/Filter/NewLines.filter.php
  46. +0 −294 codeformatter/lib/phpbeautifier/Beautifier/Filter/Pear.filter.php
  47. +0 −148 codeformatter/lib/phpbeautifier/Beautifier/Filter/phpBB.filter.php
  48. +0 −59 codeformatter/lib/phpbeautifier/Beautifier/Licenses/apache.txt
  49. +0 −32 codeformatter/lib/phpbeautifier/Beautifier/Licenses/bsd.txt
  50. +0 −23 codeformatter/lib/phpbeautifier/Beautifier/Licenses/lgpl.txt
  51. +0 −47 codeformatter/lib/phpbeautifier/Beautifier/Licenses/pear.txt
  52. +0 −19 codeformatter/lib/phpbeautifier/Beautifier/Licenses/php.txt
  53. +0 −156 codeformatter/lib/phpbeautifier/Beautifier/StreamWrapper.php
  54. +0 −328 codeformatter/lib/phpbeautifier/Beautifier/StreamWrapper/Tarz.php
  55. +0 −59 codeformatter/lib/phpbeautifier/Beautifier/Tokenizer.php
  56. +0 −520 codeformatter/lib/phpbeautifier/CompatInfo.php
  57. +0 −633 codeformatter/lib/phpbeautifier/CompatInfo/Cli.php
  58. +0 −47 codeformatter/lib/phpbeautifier/CompatInfo/PDO_class_array.php
  59. +0 −25 codeformatter/lib/phpbeautifier/CompatInfo/PDO_func_array.php
  60. +0 −1,926 codeformatter/lib/phpbeautifier/CompatInfo/Parser.php
  61. +0 −96 codeformatter/lib/phpbeautifier/CompatInfo/Reflection_class_array.php
  62. +0 −424 codeformatter/lib/phpbeautifier/CompatInfo/Renderer.php
  63. +0 −266 codeformatter/lib/phpbeautifier/CompatInfo/Renderer_/Array.php
  64. +0 −296 codeformatter/lib/phpbeautifier/CompatInfo/Renderer_/Csv.php
  65. +0 −454 codeformatter/lib/phpbeautifier/CompatInfo/Renderer_/Html.php
  66. +0 −98 codeformatter/lib/phpbeautifier/CompatInfo/Renderer_/Null.php
  67. +0 −498 codeformatter/lib/phpbeautifier/CompatInfo/Renderer_/Text.php
  68. +0 −438 codeformatter/lib/phpbeautifier/CompatInfo/Renderer_/Xml.php
  69. +0 −320 codeformatter/lib/phpbeautifier/CompatInfo/SPL_class_array.php
  70. +0 −97 codeformatter/lib/phpbeautifier/CompatInfo/SPL_func_array.php
  71. +0 −47 codeformatter/lib/phpbeautifier/CompatInfo/SQLite_class_array.php
  72. +0 −174 codeformatter/lib/phpbeautifier/CompatInfo/SQLite_const_array.php
  73. +0 −286 codeformatter/lib/phpbeautifier/CompatInfo/SQLite_func_array.php
  74. +0 −26 codeformatter/lib/phpbeautifier/CompatInfo/SimpleXML_class_array.php
  75. +0 −37 codeformatter/lib/phpbeautifier/CompatInfo/SimpleXML_func_array.php
  76. +0 −89 codeformatter/lib/phpbeautifier/CompatInfo/apache2handler_sapi_array.php
  77. +0 −79 codeformatter/lib/phpbeautifier/CompatInfo/bcmath_func_array.php
  78. +0 −79 codeformatter/lib/phpbeautifier/CompatInfo/bz2_func_array.php
  79. +0 −124 codeformatter/lib/phpbeautifier/CompatInfo/calendar_const_array.php
  80. +0 −127 codeformatter/lib/phpbeautifier/CompatInfo/calendar_func_array.php
  81. +0 −26 codeformatter/lib/phpbeautifier/CompatInfo/cgi_sapi_array.php
  82. +0 −65 codeformatter/lib/phpbeautifier/CompatInfo/class_array.php
  83. +0 −26 codeformatter/lib/phpbeautifier/CompatInfo/cli_sapi_array.php
  84. +0 −61 codeformatter/lib/phpbeautifier/CompatInfo/com_dotnet_class_array.php
  85. +0 −264 codeformatter/lib/phpbeautifier/CompatInfo/com_dotnet_const_array.php
  86. +0 −211 codeformatter/lib/phpbeautifier/CompatInfo/com_dotnet_func_array.php
  87. +0 −69 codeformatter/lib/phpbeautifier/CompatInfo/const_array.php
  88. +0 −85 codeformatter/lib/phpbeautifier/CompatInfo/ctype_func_array.php
  89. +0 −33 codeformatter/lib/phpbeautifier/CompatInfo/date_class_array.php
  90. +0 −90 codeformatter/lib/phpbeautifier/CompatInfo/date_const_array.php
  91. +0 −608 codeformatter/lib/phpbeautifier/CompatInfo/date_func_array.php
  92. +0 −236 codeformatter/lib/phpbeautifier/CompatInfo/dom_class_array.php
  93. +0 −244 codeformatter/lib/phpbeautifier/CompatInfo/dom_const_array.php
  94. +0 −85 codeformatter/lib/phpbeautifier/CompatInfo/dom_func_array.php
  95. +0 −274 codeformatter/lib/phpbeautifier/CompatInfo/filter_const_array.php
  96. +0 −61 codeformatter/lib/phpbeautifier/CompatInfo/filter_func_array.php
  97. +0 −69 codeformatter/lib/phpbeautifier/CompatInfo/ftp_const_array.php
  98. +0 −223 codeformatter/lib/phpbeautifier/CompatInfo/ftp_func_array.php
  99. +0 −82 codeformatter/lib/phpbeautifier/CompatInfo/func_array.php
  100. +0 −249 codeformatter/lib/phpbeautifier/CompatInfo/gd_const_array.php
  101. +0 −637 codeformatter/lib/phpbeautifier/CompatInfo/gd_func_array.php
  102. +0 −79 codeformatter/lib/phpbeautifier/CompatInfo/gettext_func_array.php
  103. +0 −39 codeformatter/lib/phpbeautifier/CompatInfo/gmp_const_array.php
  104. +0 −259 codeformatter/lib/phpbeautifier/CompatInfo/gmp_func_array.php
  105. +0 −24 codeformatter/lib/phpbeautifier/CompatInfo/hash_const_array.php
  106. +0 −103 codeformatter/lib/phpbeautifier/CompatInfo/hash_func_array.php
  107. +0 −39 codeformatter/lib/phpbeautifier/CompatInfo/iconv_const_array.php
  108. +0 −86 codeformatter/lib/phpbeautifier/CompatInfo/iconv_func_array.php
  109. +0 −344 codeformatter/lib/phpbeautifier/CompatInfo/imap_const_array.php
  110. +0 −439 codeformatter/lib/phpbeautifier/CompatInfo/imap_func_array.php
  111. +0 −334 codeformatter/lib/phpbeautifier/CompatInfo/internal_const_array.php
  112. +0 −37 codeformatter/lib/phpbeautifier/CompatInfo/json_func_array.php
  113. +0 −26 codeformatter/lib/phpbeautifier/CompatInfo/libxml_class_array.php
  114. +0 −119 codeformatter/lib/phpbeautifier/CompatInfo/libxml_const_array.php
  115. +0 −49 codeformatter/lib/phpbeautifier/CompatInfo/libxml_func_array.php
  116. +0 −49 codeformatter/lib/phpbeautifier/CompatInfo/mbstring_const_array.php
  117. +0 −463 codeformatter/lib/phpbeautifier/CompatInfo/mbstring_func_array.php
  118. +0 −145 codeformatter/lib/phpbeautifier/CompatInfo/ming_class_array.php
  119. +0 −284 codeformatter/lib/phpbeautifier/CompatInfo/ming_const_array.php
  120. +0 −55 codeformatter/lib/phpbeautifier/CompatInfo/ming_func_array.php
  121. +0 −54 codeformatter/lib/phpbeautifier/CompatInfo/mysql_const_array.php
  122. +0 −412 codeformatter/lib/phpbeautifier/CompatInfo/mysql_func_array.php
  123. +0 −61 codeformatter/lib/phpbeautifier/CompatInfo/mysqli_class_array.php
  124. +0 −399 codeformatter/lib/phpbeautifier/CompatInfo/mysqli_const_array.php
  125. +0 −700 codeformatter/lib/phpbeautifier/CompatInfo/mysqli_func_array.php
  126. +0 −219 codeformatter/lib/phpbeautifier/CompatInfo/odbc_const_array.php
  127. +0 −433 codeformatter/lib/phpbeautifier/CompatInfo/odbc_func_array.php
  128. +0 −199 codeformatter/lib/phpbeautifier/CompatInfo/openssl_const_array.php
  129. +0 −271 codeformatter/lib/phpbeautifier/CompatInfo/openssl_func_array.php
  130. +0 −89 codeformatter/lib/phpbeautifier/CompatInfo/pcre_const_array.php
  131. +0 −67 codeformatter/lib/phpbeautifier/CompatInfo/pcre_func_array.php
  132. +0 −249 codeformatter/lib/phpbeautifier/CompatInfo/pgsql_const_array.php
  133. +0 −668 codeformatter/lib/phpbeautifier/CompatInfo/pgsql_func_array.php
  134. +0 −29 codeformatter/lib/phpbeautifier/CompatInfo/sapi_array.php
  135. +0 −139 codeformatter/lib/phpbeautifier/CompatInfo/session_func_array.php
  136. +0 −94 codeformatter/lib/phpbeautifier/CompatInfo/snmp_const_array.php
  137. +0 −163 codeformatter/lib/phpbeautifier/CompatInfo/snmp_func_array.php
  138. +0 −45 codeformatter/lib/phpbeautifier/CompatInfo/standard_class_array.php
  139. +0 −1,204 codeformatter/lib/phpbeautifier/CompatInfo/standard_const_array.php
  140. +0 −10,608 codeformatter/lib/phpbeautifier/CompatInfo/standard_func_array.php
  141. +0 −614 codeformatter/lib/phpbeautifier/CompatInfo/tokenizer_const_array.php
  142. +0 −31 codeformatter/lib/phpbeautifier/CompatInfo/tokenizer_func_array.php
  143. +0 −55 codeformatter/lib/phpbeautifier/CompatInfo/wddx_func_array.php
  144. +0 −44 codeformatter/lib/phpbeautifier/CompatInfo/xdebug_const_array.php
  145. +0 −278 codeformatter/lib/phpbeautifier/CompatInfo/xdebug_func_array.php
  146. +0 −154 codeformatter/lib/phpbeautifier/CompatInfo/xml_const_array.php
  147. +0 −163 codeformatter/lib/phpbeautifier/CompatInfo/xml_func_array.php
  148. +0 −26 codeformatter/lib/phpbeautifier/CompatInfo/xmlreader_class_array.php
  149. +0 −26 codeformatter/lib/phpbeautifier/CompatInfo/xmlwriter_class_array.php
  150. +0 −271 codeformatter/lib/phpbeautifier/CompatInfo/xmlwriter_func_array.php
  151. +0 −26 codeformatter/lib/phpbeautifier/CompatInfo/xsl_class_array.php
  152. +0 −54 codeformatter/lib/phpbeautifier/CompatInfo/xsl_const_array.php
  153. +0 −26 codeformatter/lib/phpbeautifier/CompatInfo/zip_class_array.php
  154. +0 −257 codeformatter/lib/phpbeautifier/CompatInfo/zip_func_array.php
  155. +0 −29 codeformatter/lib/phpbeautifier/CompatInfo/zlib_const_array.php
  156. +0 −151 codeformatter/lib/phpbeautifier/CompatInfo/zlib_func_array.php
  157. +0 −366 codeformatter/lib/phpbeautifier/Console/Getopt.php
  158. +0 −301 codeformatter/lib/phpbeautifier/Console/_Color.php
  159. +0 −1,123 codeformatter/lib/phpbeautifier/Console/_Getargs.php
  160. +0 −885 codeformatter/lib/phpbeautifier/Console/_Table.php
  161. +0 −159 codeformatter/lib/phpbeautifier/DocBlockGenerator.php
  162. +0 −253 codeformatter/lib/phpbeautifier/DocBlockGenerator/Align.php
  163. +0 −681 codeformatter/lib/phpbeautifier/DocBlockGenerator/Block.php
  164. +0 −166 codeformatter/lib/phpbeautifier/DocBlockGenerator/Cli.php
  165. +0 −430 codeformatter/lib/phpbeautifier/DocBlockGenerator/GetoptPlus.php
  166. +0 −160 codeformatter/lib/phpbeautifier/DocBlockGenerator/License.php
  167. +0 −481 codeformatter/lib/phpbeautifier/DocBlockGenerator/Tokens.php
  168. +0 −618 codeformatter/lib/phpbeautifier/DocBlockGenerator/Type.php
  169. +0 −478 codeformatter/lib/phpbeautifier/Event/Dispatcher.php
  170. +0 −194 codeformatter/lib/phpbeautifier/Event/Notification.php
  171. +0 −496 codeformatter/lib/phpbeautifier/File/Find.php
  172. +0 −868 codeformatter/lib/phpbeautifier/Log.php
  173. +0 −274 codeformatter/lib/phpbeautifier/Log/composite.php
  174. +0 −222 codeformatter/lib/phpbeautifier/Log/console.php
  175. +0 −235 codeformatter/lib/phpbeautifier/Log/daemon.php
  176. +0 −181 codeformatter/lib/phpbeautifier/Log/display.php
  177. +0 −160 codeformatter/lib/phpbeautifier/Log/error_log.php
  178. +0 −316 codeformatter/lib/phpbeautifier/Log/file.php
  179. +0 −207 codeformatter/lib/phpbeautifier/Log/firebug.php
  180. +0 −294 codeformatter/lib/phpbeautifier/Log/mail.php
  181. +0 −170 codeformatter/lib/phpbeautifier/Log/mcal.php
  182. +0 −358 codeformatter/lib/phpbeautifier/Log/mdb2.php
  183. +0 −91 codeformatter/lib/phpbeautifier/Log/null.php
  184. +0 −129 codeformatter/lib/phpbeautifier/Log/observer.php
  185. +0 −294 codeformatter/lib/phpbeautifier/Log/sql.php
  186. +0 −225 codeformatter/lib/phpbeautifier/Log/sqlite.php
  187. +0 −238 codeformatter/lib/phpbeautifier/Log/syslog.php
  188. +0 −286 codeformatter/lib/phpbeautifier/Log/win.php
  189. +0 −1,063 codeformatter/lib/phpbeautifier/PEAR.php
  190. +0 −2,097 codeformatter/lib/phpbeautifier/PEAR/Config.php
  191. +0 −769 codeformatter/lib/phpbeautifier/PEAR/DependencyDB.php
  192. +0 −389 codeformatter/lib/phpbeautifier/PEAR/Exception.php
  193. +0 −7 codeformatter/lib/phpbeautifier/PEAR/FixPHP5PEARWarnings.php
  194. +0 −276 codeformatter/lib/phpbeautifier/PEAR/Installer/Role.php
  195. +0 −106 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Cfg.php
  196. +0 −15 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Cfg.xml
  197. +0 −174 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Common.php
  198. +0 −28 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Data.php
  199. +0 −15 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Data.xml
  200. +0 −28 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Doc.php
  201. +0 −15 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Doc.xml
  202. +0 −28 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Ext.php
  203. +0 −12 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Ext.xml
  204. +0 −28 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Php.php
  205. +0 −15 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Php.xml
  206. +0 −28 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Script.php
  207. +0 −15 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Script.xml
  208. +0 −34 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Src.php
  209. +0 −12 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Src.xml
  210. +0 −28 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Test.php
  211. +0 −15 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Test.xml
  212. +0 −28 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Www.php
  213. +0 −15 codeformatter/lib/phpbeautifier/PEAR/Installer/Role/Www.xml
  214. +0 −2,395 codeformatter/lib/phpbeautifier/PEAR/Registry.php
  215. +0 −253 codeformatter/lib/phpbeautifier/PEAR/XMLParser.php
  216. +0 −33 codeformatter/lib/phpbeautifier/PEAR5.php
  217. +0 −629 codeformatter/lib/phpbeautifier/System.php
  218. BIN codeformatter/lib/phpbeautifier/fmt.phar
  219. +0 −281 codeformatter/lib/phpbeautifier/php_beautifier
  220. +0 −4 codeformatter/lib/phpbeautifier/php_beautifier.bat
  221. +333 −0 codeformatter/lib/scssbeautifier/__init__.py
  222. +1 −0 codeformatter/lib/scssbeautifier/__version__.py
  223. +126 −0 codeformatter/lib/vbscriptbeautifier/__init__.py
  224. +1 −0 codeformatter/lib/vbscriptbeautifier/__version__.py
  225. +0 −40 codeformatter/phpbeautifier/__init__.py
  226. +86 −96 codeformatter/phpformatter.py
  227. +4 −5 codeformatter/pybeautifier/__init__.py
  228. +285 −280 codeformatter/pyformatter.py
  229. +7 −4 codeformatter/reloader.py
  230. +72 −0 codeformatter/scssformatter.py
  231. +79 −0 codeformatter/vbscriptformatter.py
  232. +5 −1 messages.json
  233. +7 −0 messages/2.4.3.txt
  234. +9 −0 messages/2.5.0.txt
  235. +9 −0 messages/2.6.0.txt
  236. +14 −0 messages/3.0.0.txt
  237. +182 −124 messages/install.txt
  238. +52 −0 tests/css/test.css
  239. +1,651 −0 tests/js/test.js
  240. +6 −0 tests/php/test1.php
  241. +53 −0 tests/php/test2.php
  242. +143 −0 tests/php/test3.php
View
@@ -1 +1,2 @@
*.pyc
+/package-metadata.json
View
@@ -1,86 +1,149 @@
-# @author Avtandil Kikabidze
-# @copyright Copyright (c) 2008-2014, Avtandil Kikabidze aka LONGMAN (akalongman@gmail.com)
-# @link http://long.ge
-# @license GNU General Public License version 2 or later;
+# @author Avtandil Kikabidze
+# @copyright Copyright (c) 2008-2015, Avtandil Kikabidze aka LONGMAN (akalongman@gmail.com)
+# @link http://longman.me
+# @license The MIT License (MIT)
import os, sys, sublime, sublime_plugin
st_version = 2
if sublime.version() == '' or int(sublime.version()) > 3000:
- st_version = 3
+ st_version = 3
reloader_name = 'codeformatter.reloader'
# ST3 loads each package as a module, so it needs an extra prefix
if st_version == 3:
- reloader_name = 'CodeFormatter.' + reloader_name
- from imp import reload
+ reloader_name = 'CodeFormatter.' + reloader_name
+ from imp import reload
if reloader_name in sys.modules:
- reload(sys.modules[reloader_name])
+ reload(sys.modules[reloader_name])
try:
- # Python 3
- from .codeformatter import reloader
- from .codeformatter.formatter import Formatter
+ # Python 3
+ from .codeformatter import reloader
+ from .codeformatter.formatter import Formatter
except (ValueError):
- # Python 2
- from codeformatter import reloader
- from codeformatter.formatter import Formatter
+ # Python 2
+ from codeformatter import reloader
+ from codeformatter.formatter import Formatter
# fix for ST2
cprint = globals()["__builtins__"]["print"]
def plugin_loaded():
- cprint('CodeFormatter: Plugin Initialized')
- if (sublime.platform() != "windows"):
- import stat
- path = sublime.packages_path()+"/CodeFormatter/codeformatter/lib/phpbeautifier/php_beautifier"
- st = os.stat(path)
- os.chmod(path, st.st_mode | stat.S_IEXEC)
+ cprint('CodeFormatter: Plugin Initialized')
+ if (sublime.platform() != "windows"):
+ import stat
+ path = sublime.packages_path()+"/CodeFormatter/codeformatter/lib/phpbeautifier/fmt.phar"
+ st = os.stat(path)
+ os.chmod(path, st.st_mode | stat.S_IEXEC)
if st_version == 2:
- plugin_loaded()
+ plugin_loaded()
class CodeFormatterCommand(sublime_plugin.TextCommand):
- def run(self, edit, syntax=False):
+ def run(self, edit, syntax=False, saving=False):
- if self.view.is_scratch():
- return show_error("File is scratch.")
+ if self.view.is_scratch():
+ return show_error("File is scratch")
- file_name = self.view.file_name()
+ file_name = self.view.file_name()
- # if not file_name:
- # return show_error("File does not exist.")
+ # if not file_name:
+ # return show_error("File does not exist.")
- # if not os.path.exists(file_name):
- # return show_error("File "+file_name+" does not exist.")
+ # if not os.path.exists(file_name):
+ # return show_error("File "+file_name+" does not exist.")
- formatter = Formatter(self.view, file_name, syntax)
- if not formatter.exists():
- return show_error("Formatter for this file type ("+formatter.syntax+") not found.")
+ formatter = Formatter(self.view, file_name, syntax, saving)
+ if not formatter.exists():
+ if saving:
+ return False
+ return show_error("Formatter for this file type ("+formatter.syntax+") not found.")
- file_text = sublime.Region(0, self.view.size())
- file_text_utf = self.view.substr(file_text).encode('utf-8')
- if (len(file_text_utf) == 0):
- return show_error("No code found.")
- stdout, stderr = formatter.format(file_text_utf)
+ if (saving and not formatter.formatOnSaveEnabled()):
+ return False
+
+
+ file_text = sublime.Region(0, self.view.size())
+ file_text_utf = self.view.substr(file_text).encode('utf-8')
+ if (len(file_text_utf) == 0):
+ return show_error("No code found.")
+
+ stdout, stderr = formatter.format(file_text_utf)
+
+ if len(stderr) == 0 and len(stdout) > 0:
+ self.view.replace(edit, file_text, stdout)
+ else:
+ show_error("Format error:\n"+stderr)
+
+class CodeFormatterEventListener(sublime_plugin.EventListener):
+
+ def on_pre_save(self, view):
+ args = {}
+ args['saving'] = True
+ view.run_command('code_formatter', args)
+
+
+class CodeFormatterShowPhpTransformationsCommand(sublime_plugin.TextCommand):
+ def run(self, edit, syntax=False):
+ import subprocess, re
+
+ platform = sublime.platform()
+ settings = sublime.load_settings('CodeFormatter.sublime-settings')
+
+ opts = settings.get('codeformatter_php_options')
+
+ php_path = settings.get('codeformatter_php_path', '');
+ if (php_path == ""):
+ php_path = "php"
+
+
+ cmd = []
+ cmd.append(str(php_path))
+ cmd.append(sublime.packages_path()+"/CodeFormatter/codeformatter/lib/phpbeautifier/fmt.phar")
+ cmd.append("--list")
+
+ stderr = ""
+ stdout = ""
+ try:
+ if (platform == "windows"):
+ startupinfo = subprocess.STARTUPINFO()
+ startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+ startupinfo.wShowWindow = subprocess.SW_HIDE
+ p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, creationflags=subprocess.SW_HIDE)
+ else:
+ p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ except Exception as e:
+ stderr = str(e)
+
+ if (not stderr and not stdout):
+ stderr = "Error while gethering list of php transformations"
+
+ if len(stderr) == 0 and len(stdout) > 0:
+ text = stdout.decode('utf-8')
+ text = re.sub("Usage:.*?PASSNAME", "Available PHP Tranformations:", text)
+ window = self.view.window()
+ pt = window.get_output_panel("paneltranformations")
+ pt.set_read_only(False)
+ pt.insert(edit, pt.size(), text)
+ window.run_command("show_panel", {"panel": "output.paneltranformations"})
+ else:
+ show_error("Formatter error:\n"+stderr.decode('utf-8'))
- if len(stderr) == 0 and len(stdout) > 0:
- self.view.replace(edit, file_text, stdout)
- else:
- show_error("Format error:\n"+stderr)
def console_write(text, prefix=False):
- if prefix:
- sys.stdout.write('CodeFormatter: ')
- sys.stdout.write(text+"\n")
+ if prefix:
+ sys.stdout.write('CodeFormatter: ')
+ sys.stdout.write(text+"\n")
def show_error(text):
@@ -25,6 +25,13 @@
}
},
{
+ "caption": "CodeFormatter: Format as SCSS Syntax",
+ "command": "code_formatter",
+ "args": {
+ "syntax": "scss"
+ }
+ },
+ {
"caption": "CodeFormatter: Format as HTML Syntax",
"command": "code_formatter",
"args": {
@@ -39,6 +46,17 @@
}
},
{
+ "caption": "CodeFormatter: Format as VBScript Syntax",
+ "command": "code_formatter",
+ "args": {
+ "syntax": "vbscript"
+ }
+ },
+ {
+ "caption": "CodeFormatter: Show PHP Transformations",
+ "command": "code_formatter_show_php_transformations"
+ },
+ {
"caption": "CodeFormatter: Format as Coldfusion Syntax",
"command": "code_formatter",
"args": {
Oops, something went wrong.

0 comments on commit 472ca1c

Please sign in to comment.