|
5 | 5 | import os |
6 | 6 | import tempfile |
7 | 7 | import pathlib |
| 8 | +import platform |
8 | 9 |
|
9 | 10 | SETTINGS_PATH = 'Default.sublime-settings' |
10 | 11 |
|
11 | 12 | resExt = ".res" |
12 | 13 | resiExt = ".resi" |
| 14 | +platformSystem = platform.system() |
| 15 | +# rescript currently supports 3 platforms: darwin, linux, win32. these also |
| 16 | +# happen to be folder names for the location of the bsc binary. We're in |
| 17 | +# python, so we're gonna translate python's output of system to nodejs' |
| 18 | +# Why don't we just use the binary in node_modules/.bin/bsc? Because that |
| 19 | +# one's a nodejs wrapper, which has a startup cost. It makes it so that every |
| 20 | +# time we call it for e.g. formatting, the result janks a little. |
| 21 | +platformInNodeJS = "linux" |
| 22 | +if platformSystem == "Darwin": |
| 23 | + platformInNodeJS = "darwin" |
| 24 | +elif platformSystem == "Windows": |
| 25 | + platformInNodeJS = "win32" |
| 26 | + |
| 27 | +bscPartialPath = os.path.join("node_modules", "bs-platform", platformInNodeJS, "bsc.exe") |
13 | 28 |
|
14 | 29 | def findBsConfigDirFromFilename(filename): |
15 | 30 | currentDir = os.path.dirname(filename) |
@@ -143,8 +158,7 @@ def findFormatter(view, filename): |
143 | 158 | ) |
144 | 159 | return None |
145 | 160 | else: |
146 | | - # TODO: find the right platform binary |
147 | | - bscExe = os.path.join(bsconfigDir, "node_modules", ".bin", "bsc") |
| 161 | + bscExe = os.path.join(bsconfigDir, bscPartialPath) |
148 | 162 | if os.path.exists(bscExe): |
149 | 163 | return bscExe |
150 | 164 | else: |
@@ -194,7 +208,7 @@ def run(self, edit, formatBuffer=True): |
194 | 208 | view.text_point(range_["end"]["line"], range_["end"]["character"]), |
195 | 209 | ) |
196 | 210 | regions.append(region) |
197 | | - html = '<body id="my-plugin-feature"> <style> div.error {padding: 5px; } </style> <div class="error">' + message + '</div> </body>' |
| 211 | + html = '<body> <style> div.error {padding: 5px; border-radius: 8px;} </style> <div class="error">' + message + '</div> </body>' |
198 | 212 | view.add_phantom("errns", region, html, sublime.LAYOUT_BELOW) |
199 | 213 |
|
200 | 214 | view.add_regions('syntaxerror', regions, 'invalid.illegal', 'dot', sublime.DRAW_NO_FILL) |
|
0 commit comments