Skip to content

Commit 890149f

Browse files
authored
Merge pull request #972 from DisposaBoy/next
Next
2 parents bd0163d + d7d7880 commit 890149f

File tree

241 files changed

+20316
-91668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+20316
-91668
lines changed

CHANGELOG.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,106 @@ https://margo.sh/b/motd - Get notified when GoSublime has a new release.
1010

1111
## Changes
1212

13+
## 20.06.14
14+
15+
This release contains a number of features and bug fixes that have been worked on over the last few months.
16+
17+
_You will need to restart Sublime Text for all changes to take effect_
18+
19+
- Add new GoCmd{} option `Humanize` to make `go test` and `go re/play` (in test mdoe) output more readable (using https://github.com/dustin/go-humanize).
20+
21+
- large numbers are split up using commas
22+
- 123456 ns/op is converted to µs/op, etc.
23+
- 123456 B/op is converted to KiB/op, etc.
24+
25+
To enabled it, use:
26+
27+
&golang.GoCmd{
28+
Humanize: true,
29+
}
30+
31+
e.g. output:
32+
33+
goos: linux
34+
goarch: amd64
35+
pkg: margo.sh/vfs
36+
BenchmarkPoke/Miss-8 388,868 2.952 µs/op
37+
BenchmarkPoke/Hit-8 1,739,704 684 ns/op
38+
PASS
39+
40+
Known bugs:
41+
42+
- The output fields are not aligned
43+
44+
- Add new reducer golang.GoGenerate
45+
46+
It adds a UserCmd (cord `ctrl/cmd+.`,`ctrl/cmd+.c`) named `Go Generate` that calls `go generate` in the closest go package (current dir or parent dirs).
47+
48+
It can be enabled with:
49+
50+
&golang.GoGenerate{
51+
Args: []string{"-v", "-x"},
52+
},
53+
54+
- Auto-completion now works when the line ends with a dot (.)
55+
56+
- Add new reducer golang.AsmFmt
57+
58+
It does code fmt'ing for `.s` files using https://github.com/klauspost/asmfmt
59+
60+
It formats `.s` files when they are saved, or the fmt cord `ctrl+.`,`ctrl.f` is pressed.
61+
62+
- Add new reducer &web.Prettier{}
63+
64+
It does code fmt'ing using https://github.com/prettier/prettier
65+
By default It fmt's CSS, HTML, JS, JSON, JSX, SVG, TS, TSX and XML files.
66+
67+
To specify the list of langs to fmt set the `Langs` field:
68+
69+
&web.Prettier{
70+
// Langs: []mg.Lang{mg.JS}, // only fmt .js files
71+
Langs: web.PrettierDefaultLangs,
72+
},
73+
74+
You might also need to `import "margo.sh/web"`.
75+
76+
You will need to install prettier separately.
77+
78+
- Add new Lang constants: mg.HTML, mg.SVG and mg.XML
79+
80+
- Add mgutil.SplitWriter a writer that writes to an underlying writer in split chunks e.g. lines somewhat similar to bufio.scanner
81+
82+
- `go.play` and `go.replay` (cord `ctrl/cmd+.`,`ctrl/cmd+r`) now works in in unsaved `_test.go` files.
83+
84+
- `go.replay` now runs the Benchmark\* func surrounding the cursor.
85+
86+
Compared to `ctrl/cmd+shift+left-click`, it also runs tests.
87+
88+
Known bugs:
89+
90+
- It currently ignores the TestArgs and BenchmarkArgs options of the golang.TestCmds reducer.
91+
92+
- mg.CmdCtx supports a new option `Verbose`,
93+
94+
When `cx.Verbose = true`the commands that are run are printed to the output prefixed with `#`.
95+
96+
e.g. output:
97+
98+
[ `replay` | done ]
99+
# go test -test.run=. -test.bench=^BenchmarkPoke$
100+
goos: linux
101+
[...]
102+
103+
It's enabled for `go.play` and `go.replay` (cord `ctrl/cmd+.`,`ctrl/cmd+r`).
104+
105+
- Issues without a valid tag are now defaulted to `mg.Error` instead of being ignored.
106+
107+
This fixes some cases where the error palette shows errors, but the status and HUD doesn't.
108+
109+
- Fix some cases where issues are reported in the wrong file or incorrectly anchored to the current file.
110+
111+
- goutil.IsPkgDir() and other functions now use the VFS, so should touch the disk less.
112+
13113
## 20.03.09
14114

15115
This release fixes a couple bugs:

gosubl/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22
import sublime
33

4-
TAG = '20.03.09-1'
4+
TAG = '20.06.14-1'
55
ANN = 'a'+TAG
66
VERSION = 'r'+TAG
77
VERSION_PAT = re.compile(r'\d{2}[.]\d{2}[.]\d{2}-\d+', re.IGNORECASE)

gosubl/gs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,10 @@ def active_view(win=None, view=None):
503503

504504
return win.active_view()
505505

506+
def active_wd(win=None, view=None):
507+
v = active_view(win=win, view=view)
508+
return basedir_or_cwd(v.file_name() if v else '')
509+
506510
def win_view(vfn=None, win=None):
507511
wins = [win]
508512
if win is None:

gosubl/margo_state.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def __init__(self, v={}):
232232
self.desc = v.get('Desc') or ''
233233
self.name = v.get('Name') or ''
234234
self.args = v.get('Args') or []
235+
self.dir = v.get('Dir') or ''
235236
self.prompts = v.get('Prompts') or []
236237

237238
class HUD(object):
@@ -248,11 +249,11 @@ def __init__(self, v={}):
248249
# if we attempt to copy large files because it has to convert into utf*
249250
# which could use up to x4 to convert into the string it gives us
250251
# and then we have to re-encode that into bytes to send it
251-
def make_props(view=None):
252+
def make_props(view=None, wd=''):
252253
props = {
253254
'Editor': _editor_props(view),
254255
'Env': sh.env(),
255-
'View': _view_props(view),
256+
'View': _view_props(view, wd=wd),
256257
}
257258

258259
return props
@@ -275,7 +276,7 @@ def _editor_props(view):
275276
def view_is_9o(view):
276277
return view is not None and view.settings().get('9o')
277278

278-
def _view_props(view):
279+
def _view_props(view, wd=''):
279280
was_9o = view_is_9o(view)
280281
if was_9o:
281282
view = gs.active_view()
@@ -287,7 +288,7 @@ def _view_props(view):
287288

288289
pos = gs.sel(view).begin()
289290
scope, lang, fn, props = _view_header(view, pos)
290-
wd = gs.getwd() or gs.basedir_or_cwd(fn)
291+
wd = wd or gs.getwd() or gs.basedir_or_cwd(fn)
291292
src = _view_src(view, lang)
292293

293294
props.update({

gosubl/margo_sublime.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def _on_done_call(self, *, win, cmd, prompts):
7070
'run': [cmd.name] + cmd.args,
7171
'action_data': {
7272
'Prompts': prompts,
73+
'Dir': cmd.dir,
7374
},
7475
'save_hist': False,
7576
'focus_view': False,
@@ -84,7 +85,14 @@ def _cb(self, *, rs, action):
8485
cmds = rs.state.user_cmds
8586

8687
for c in cmds:
87-
desc = c.desc or '`%s`' % ' '.join([c.name] + c.args)
88+
desc = c.desc
89+
if not desc:
90+
desc = '`%s`' % ' '.join([c.name] + c.args)
91+
if c.dir:
92+
sim = gs.simple_fn(c.dir)
93+
rel = os.path.relpath(c.dir, gs.active_wd(win=win))
94+
if rel != '.':
95+
desc += ' [ %s ]' % (rel if len(rel) < len(sim) else sim)
8896
items.append([c.title, desc])
8997

9098
def on_done(i):

gs9o.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,10 @@ def run(self, edit, save_hist=False, env={}, action_data={}):
471471

472472
f = builtins().get(nm)
473473
if f:
474-
f(view, edit, args, wd, rkey)
474+
try:
475+
f(view, edit, args, wd, rkey, action_data=action_data)
476+
except TypeError:
477+
f(view, edit, args, wd, rkey)
475478
return
476479
else:
477480
_rcmd(
@@ -622,6 +625,7 @@ def cb(rs):
622625
if rs.error:
623626
push_output(view, rkey, rs.error)
624627

628+
wd = action_data.get('Dir') or wd
625629
act = actions.RunCmd.copy()
626630
act['Data'] = {
627631
'Fd': _rcmd_fd(wd=wd, rkey=rkey),
@@ -693,7 +697,7 @@ def cmd_reset(view, edit, args, wd, rkey):
693697
def cmd_clear(view, edit, args, wd, rkey):
694698
cmd_reset(view, edit, args, wd, rkey)
695699

696-
def cmd_go(view, edit, args, wd, rkey):
700+
def cmd_go(view, edit, args, wd, rkey, action_data={}):
697701
_save_all(view.window(), wd)
698702
sublime.set_timeout_async(lambda: _rcmd(
699703
view=view,
@@ -702,6 +706,7 @@ def cmd_go(view, edit, args, wd, rkey):
702706
args=args,
703707
wd=wd,
704708
rkey=rkey,
709+
action_data=action_data,
705710
))
706711

707712
def cmd_cancel_replay(view, edit, args, wd, rkey):
@@ -720,12 +725,12 @@ def cmd_cancel_replay(view, edit, args, wd, rkey):
720725
mg9.acall('kill', {'cid': cid}, None)
721726
push_output(view, rkey, '')
722727

723-
def cmd_sh(view, edit, args, wd, rkey):
728+
def cmd_sh(view, edit, args, wd, rkey, action_data={}):
724729
cid, cb = _9_begin_call('sh', view, edit, args, wd, rkey, '')
725730
a = {
726731
'cid': cid,
727732
'env': sh.env(),
728-
'cwd': wd,
733+
'cwd': action_data.get('Dir') or wd,
729734
'cmd': {
730735
'name': args[0],
731736
'args': args[1:],

src/margo.sh/Gopkg.lock

Lines changed: 53 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)