Skip to content

Commit

Permalink
Merge pull request #972 from DisposaBoy/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
DisposaBoy authored Jun 14, 2020
2 parents bd0163d + d7d7880 commit 890149f
Show file tree
Hide file tree
Showing 241 changed files with 20,316 additions and 91,668 deletions.
100 changes: 100 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,106 @@ https://margo.sh/b/motd - Get notified when GoSublime has a new release.

## Changes

## 20.06.14

This release contains a number of features and bug fixes that have been worked on over the last few months.

_You will need to restart Sublime Text for all changes to take effect_

- 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).

- large numbers are split up using commas
- 123456 ns/op is converted to µs/op, etc.
- 123456 B/op is converted to KiB/op, etc.

To enabled it, use:

&golang.GoCmd{
Humanize: true,
}

e.g. output:

goos: linux
goarch: amd64
pkg: margo.sh/vfs
BenchmarkPoke/Miss-8 388,868 2.952 µs/op
BenchmarkPoke/Hit-8 1,739,704 684 ns/op
PASS

Known bugs:

- The output fields are not aligned

- Add new reducer golang.GoGenerate

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).

It can be enabled with:

&golang.GoGenerate{
Args: []string{"-v", "-x"},
},

- Auto-completion now works when the line ends with a dot (.)

- Add new reducer golang.AsmFmt

It does code fmt'ing for `.s` files using https://github.com/klauspost/asmfmt

It formats `.s` files when they are saved, or the fmt cord `ctrl+.`,`ctrl.f` is pressed.

- Add new reducer &web.Prettier{}

It does code fmt'ing using https://github.com/prettier/prettier
By default It fmt's CSS, HTML, JS, JSON, JSX, SVG, TS, TSX and XML files.

To specify the list of langs to fmt set the `Langs` field:

&web.Prettier{
// Langs: []mg.Lang{mg.JS}, // only fmt .js files
Langs: web.PrettierDefaultLangs,
},

You might also need to `import "margo.sh/web"`.

You will need to install prettier separately.

- Add new Lang constants: mg.HTML, mg.SVG and mg.XML

- Add mgutil.SplitWriter a writer that writes to an underlying writer in split chunks e.g. lines somewhat similar to bufio.scanner

- `go.play` and `go.replay` (cord `ctrl/cmd+.`,`ctrl/cmd+r`) now works in in unsaved `_test.go` files.

- `go.replay` now runs the Benchmark\* func surrounding the cursor.

Compared to `ctrl/cmd+shift+left-click`, it also runs tests.

Known bugs:

- It currently ignores the TestArgs and BenchmarkArgs options of the golang.TestCmds reducer.

- mg.CmdCtx supports a new option `Verbose`,

When `cx.Verbose = true`the commands that are run are printed to the output prefixed with `#`.

e.g. output:

[ `replay` | done ]
# go test -test.run=. -test.bench=^BenchmarkPoke$
goos: linux
[...]

It's enabled for `go.play` and `go.replay` (cord `ctrl/cmd+.`,`ctrl/cmd+r`).

- Issues without a valid tag are now defaulted to `mg.Error` instead of being ignored.

This fixes some cases where the error palette shows errors, but the status and HUD doesn't.

- Fix some cases where issues are reported in the wrong file or incorrectly anchored to the current file.

- goutil.IsPkgDir() and other functions now use the VFS, so should touch the disk less.

## 20.03.09

This release fixes a couple bugs:
Expand Down
2 changes: 1 addition & 1 deletion gosubl/about.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import sublime

TAG = '20.03.09-1'
TAG = '20.06.14-1'
ANN = 'a'+TAG
VERSION = 'r'+TAG
VERSION_PAT = re.compile(r'\d{2}[.]\d{2}[.]\d{2}-\d+', re.IGNORECASE)
Expand Down
4 changes: 4 additions & 0 deletions gosubl/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ def active_view(win=None, view=None):

return win.active_view()

def active_wd(win=None, view=None):
v = active_view(win=win, view=view)
return basedir_or_cwd(v.file_name() if v else '')

def win_view(vfn=None, win=None):
wins = [win]
if win is None:
Expand Down
9 changes: 5 additions & 4 deletions gosubl/margo_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def __init__(self, v={}):
self.desc = v.get('Desc') or ''
self.name = v.get('Name') or ''
self.args = v.get('Args') or []
self.dir = v.get('Dir') or ''
self.prompts = v.get('Prompts') or []

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

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

def _view_props(view):
def _view_props(view, wd=''):
was_9o = view_is_9o(view)
if was_9o:
view = gs.active_view()
Expand All @@ -287,7 +288,7 @@ def _view_props(view):

pos = gs.sel(view).begin()
scope, lang, fn, props = _view_header(view, pos)
wd = gs.getwd() or gs.basedir_or_cwd(fn)
wd = wd or gs.getwd() or gs.basedir_or_cwd(fn)
src = _view_src(view, lang)

props.update({
Expand Down
10 changes: 9 additions & 1 deletion gosubl/margo_sublime.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def _on_done_call(self, *, win, cmd, prompts):
'run': [cmd.name] + cmd.args,
'action_data': {
'Prompts': prompts,
'Dir': cmd.dir,
},
'save_hist': False,
'focus_view': False,
Expand All @@ -84,7 +85,14 @@ def _cb(self, *, rs, action):
cmds = rs.state.user_cmds

for c in cmds:
desc = c.desc or '`%s`' % ' '.join([c.name] + c.args)
desc = c.desc
if not desc:
desc = '`%s`' % ' '.join([c.name] + c.args)
if c.dir:
sim = gs.simple_fn(c.dir)
rel = os.path.relpath(c.dir, gs.active_wd(win=win))
if rel != '.':
desc += ' [ %s ]' % (rel if len(rel) < len(sim) else sim)
items.append([c.title, desc])

def on_done(i):
Expand Down
13 changes: 9 additions & 4 deletions gs9o.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,10 @@ def run(self, edit, save_hist=False, env={}, action_data={}):

f = builtins().get(nm)
if f:
f(view, edit, args, wd, rkey)
try:
f(view, edit, args, wd, rkey, action_data=action_data)
except TypeError:
f(view, edit, args, wd, rkey)
return
else:
_rcmd(
Expand Down Expand Up @@ -622,6 +625,7 @@ def cb(rs):
if rs.error:
push_output(view, rkey, rs.error)

wd = action_data.get('Dir') or wd
act = actions.RunCmd.copy()
act['Data'] = {
'Fd': _rcmd_fd(wd=wd, rkey=rkey),
Expand Down Expand Up @@ -693,7 +697,7 @@ def cmd_reset(view, edit, args, wd, rkey):
def cmd_clear(view, edit, args, wd, rkey):
cmd_reset(view, edit, args, wd, rkey)

def cmd_go(view, edit, args, wd, rkey):
def cmd_go(view, edit, args, wd, rkey, action_data={}):
_save_all(view.window(), wd)
sublime.set_timeout_async(lambda: _rcmd(
view=view,
Expand All @@ -702,6 +706,7 @@ def cmd_go(view, edit, args, wd, rkey):
args=args,
wd=wd,
rkey=rkey,
action_data=action_data,
))

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

def cmd_sh(view, edit, args, wd, rkey):
def cmd_sh(view, edit, args, wd, rkey, action_data={}):
cid, cb = _9_begin_call('sh', view, edit, args, wd, rkey, '')
a = {
'cid': cid,
'env': sh.env(),
'cwd': wd,
'cwd': action_data.get('Dir') or wd,
'cmd': {
'name': args[0],
'args': args[1:],
Expand Down
71 changes: 53 additions & 18 deletions src/margo.sh/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 890149f

Please sign in to comment.