Skip to content
Permalink
Browse files

Next (#948)

* sync margo

* sync margo

* don't crash the ipc when decoding invalid utf-8

* update .travis.yml to list the versions that are actually supported

* sync margo

* tweak for better readability

* recognise go.mod and go.sum files and increase MAX_VIEW_SIZE to 8MiB

* use custom Mutex for locking to make it easier to debug

* don't trigger an action while the view is loading

* prep CHANGELOG for next release

* sync margo

* reduce the spacing between status items now that they have a prefix

* set MARGO_AGENT_GOBIN when building margo.exe to avoid side-effects of a global GOBIN

* update SUPPORT docs

* update CHANGELOG for next realease

* sync margo

* update next CHANGELOG

* sync margo

* improve 9o filename regexp to reduce cases of highlighting things that we can't open
  • Loading branch information...
DisposaBoy committed Oct 22, 2019
1 parent dd04012 commit aeeff9a03297ceb1b037ed339769261bb22a4f03
Showing 449 changed files with 92,167 additions and 64,100 deletions.
@@ -3,10 +3,8 @@ sudo: false
language: go

go:
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- tip

matrix:
@@ -5,8 +5,8 @@
{
"black": "hsl(0, 0%, 0%)",
"blue": "hsl(210, 50%, 60%)",
"blue2": "hsl(209, 13%, 35%)",
"blue3": "hsl(210, 36%, 21%)",
"blue2": "hsl(215, 33%, 29%)",
"blue3": "hsl(215, 40%, 21%)",
"blue4": "hsl(210, 13%, 45%)",
"blue5": "hsl(180, 36%, 54%)",
"blue6": "hsl(221, 12%, 69%)",
@@ -20,7 +20,7 @@
"red2": "hsl(13, 93%, 66%)",
"white": "hsl(0, 0%, 100%)",
"white2": "hsl(0, 0%, 97%)",
"white3": "hsl(219, 28%, 88%)"
"white3": "hsl(219, 28%, 93%)"
},
"globals":
{
@@ -10,9 +10,49 @@ https://margo.sh/b/motd - Get notified when GoSublime has a new release.

## Changes

## 19.10.22

- API BREAKAGE:
ParseWithMode and ParseWithMode now takes a `*mg.Ctx` instead of a `mg.KVStore`.

- Add experimental support for auto-completion and type-checking in go modules.

- Add experimental reducer `&golang.TypeCheck{}`.
It's a linter that does a full type-check as you type (even in unsaved files).
It can be thought of as a replacement for the `gotype` binary of old.

NOTE: This is purely an experiment used primarily for testing the package importer
and type-checking and will probably break randomly, if it works at all.

With that said, the plan is to clean it up and develop it further in the future.

- The Ariana color scheme has been tweaked to improve readability.

- Add a `‣` prefix to status items and reduce the space between them.

- Add langs `mg.GoMod` and `mg.GoSum` for `go.mod` and `go.sum` files, respectively.
For convenience, `goutil.Langs` now holds the list of all Go-related langs
and Go linters are now available in `go.mod` and `go.sum`.

- The tasks count styled has been changed to `Tasks ➊➋➌`.
The status animates between `Tasks ➊➋➌` and `Tasks ➀➁➂` while there are tasks less than 16s old.

- The issue count styled has been changed to `Error ➊ꞏ🄋`.

NOTE: The meanings of the numbers have been reverted.

Previously, given `1/2 Errors`, there was 1 issue with tag `Error` in this view, and there was a total 2 errors in all views.
The new meanings `Error ➊ꞏ🄋` is: ➊ is the number issues in the current view and 🄋 is the number issues in other views.

Only first number is highlighted if there are issues in the current view.
Likewise, when there are issues, but none in the current view, only the second number is highlighted.

- Don't show the `func` prefix in the calltip status. The parens already make it obviously a function.

## 19.06.16
* Fix a deadlock/freeze (seen on Mac OS) when starting up with multiple windows open.
* Fix an issue where the active window loses focus when starting up.

- Fix a deadlock/freeze (seen on Mac OS) when starting up with multiple windows open.
- Fix an issue where the active window loses focus when starting up.

## 18.11.28

@@ -29,6 +69,7 @@ This release introduces the HUD and comes with many improvements to snippets and
It's bound to the keys `ctrl+.`,`ctrl+0`.

You can manually bind it to another key. e.g. via `Preferences > Key Bindings`:

```json
{
"keys": ["ctrl+0"],
@@ -39,21 +80,26 @@ This release introduces the HUD and comes with many improvements to snippets and
- Several new snippets have been added and old ones improved.

- AppendSnippet: `name = |` suggests:

- `name = append(name, ...)`
- `slice = append(slice[:len(slice):len(slice)], ...)`

- DeferSnippet:

- `defer func() {}()`
- `defer f()`

- ReturnSnippet:

- `return`

- MutexSnippet: `mu.|` suggests:

- `mu.Lock(); defer mu.Unlock(); |`
- `mu.Lock(); |; mu.Unlock()`

- PackageNameSnippet:

- `package main; func main() { | }`

- DocSnippet: suggest function names, field names, etc. inside the corresponding _documentation_ comment
@@ -74,4 +74,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
<br>
<a href="https://margo.sh/sponsors/0" target="_blank"><img src="https://margo.sh/sponsors/0.svg"></a>
<a href="https://margo.sh/sponsors/0" target="_blank"><img src="https://margo.sh/sponsors/0.svg?2"></a>
@@ -27,16 +27,23 @@ GoSublime is backed by https://margo.sh/ to which the following points apply:
- Only the main `gc` tool-chain distributed by https://golang.org/ is supported.
- margo should not require a cgo-enabled Go installation, but non-cgo builds i.e. `CGO_ENABLED=0` are not tested.

## Go Modules

At this time, Go modules are only partially supported.
Auto-completion and other features built directly into margo should work in most cases,
but features backed by external tools e.g. `goto definition` might work.

We plan to implement most of these features internally as our (type-check) importer matures.

## Operating Systems

- Testing is only done on Linux.
- Testing is only done on Arch Linux.
- Windows and macOS should work without issue, but no testing is done on them.

## Tools

Please note:

- GoSublime uses its own fork of `gocode` so any installation on your system is ignored.
- By default `fmt` is achieved through direct use of the packages in the stdlib and not the binaries on your system.

## Sponsors & Backers
@@ -1,7 +1,7 @@
import re
import sublime

TAG = '19.06.16-1'
TAG = '19.10.22-1'
ANN = 'a'+TAG
VERSION = 'r'+TAG
VERSION_PAT = re.compile(r'\d{2}[.]\d{2}[.]\d{2}-\d+', re.IGNORECASE)
@@ -1,7 +1,7 @@
from . import _dbg
from . import gs, gsq, sh
from .margo_agent import MargoAgent
from .margo_common import OutputLogger, TokenCounter
from .margo_common import OutputLogger, TokenCounter, Mutex
from .margo_render import render
from .margo_state import State, actions, client_actions, Config, _view_scope_lang, view_is_9o, MgView
from base64 import b64decode
@@ -10,7 +10,6 @@
import os
import shlex
import sublime
import threading
import time
import webbrowser

@@ -34,11 +33,11 @@ def __init__(self):
}
self.file_ids = []
self._hud_state = {}
self._hud_state_lock = threading.Lock()
self._hud_state_lock = Mutex(name='margo.MargoSingleton._hud_state_lock')
self.hud_name = 'GoSublime/HUD'
self.hud_id = self.hud_name.replace('/','-').lower()
self._views = {}
self._view_lock = threading.Lock()
self._view_lock = Mutex(name='margo.MargoSingleton._view_lock')
self._gopath = ''

def _sync_settings(self):
@@ -155,6 +154,9 @@ def can_trigger_event(self, view, allow_9o=False):
if view is None:
return False

if view.is_loading():
return False

if not self.enabled(view):
return False

@@ -512,7 +514,7 @@ def on_post_save(self, view):
self.queue(view=view, actions=[actions.ViewSaved])

def on_load(self, view):
self.queue(view=view, actions=[actions.ViewLoaded])
self.on_activated(view)

def example_extension_file(self):
return gs.dist_path('src/margo.sh/extension-example/extension-example.go')
@@ -1,6 +1,6 @@
from . import _dbg
from . import sh, gs, gsq
from .margo_common import TokenCounter, OutputLogger, Chan
from .margo_common import TokenCounter, OutputLogger, Chan, Mutex
from .margo_state import State, make_props, actions
from datetime import datetime
import os
@@ -18,7 +18,7 @@
if ipc_codec == 'msgpack':
from .vendor import umsgpack
ipc_loads = umsgpack.loads
ipc_dec = umsgpack.load
ipc_dec = lambda fp: umsgpack.load(fp, allow_invalid_utf8=True)
ipc_enc = umsgpack.dump
ipc_silent_exceptions += (
umsgpack.InsufficientDataException,
@@ -40,7 +40,7 @@ def __init__(self, mg):
_, self.domain = mg.agent_tokens.next()
self.cookies = TokenCounter('%s,request' % self.domain)
self.proc = None
self.lock = threading.Lock()
self.lock = Mutex(name='margo.MargoAgent.lock')
self.out = OutputLogger(self.domain, parent=mg.out)
self.global_handlers = {}
self.req_handlers = {}
@@ -64,7 +64,7 @@ def __init__(self, mg):
}
gs.mkdirp(self.data_dir)

self._acts_lock = threading.Lock()
self._acts_lock = Mutex(name='margo.MargoAgent._acts_lock')
self._acts = []

def __del__(self):
@@ -109,12 +109,13 @@ def _start_proc(self):

gs_gobin = gs.dist_path('bin')
mg_exe = 'margo.sh'
install_cmd = ['go', 'install', '-v', mg_exe]
install_cmd = ['go', 'install', '-v','-x', mg_exe]
cmd = sh.Command(install_cmd)
cmd.env = self._env({
'GOPATH': self._default_env['MARGO_AGENT_GOPATH'],
'GO111MODULE': self._default_env['MARGO_AGENT_GO111MODULE'],
'GOBIN': gs_gobin,
'MARGO_AGENT_GOBIN': gs_gobin,
})
cr = cmd.run()
for v in (cr.out, cr.err, cr.exc):
@@ -341,7 +342,7 @@ def __init__(self, agent, actions, cb=None, view=None):
self.cb = cb
self.props = make_props(view=view)
self.rs = DEFAULT_RESPONSE
self.lock = threading.Lock()
self.lock = Mutex(name='margo.AgentReq.lock')
self.ev = threading.Event()
self.view = view

@@ -5,6 +5,23 @@
import sublime
import time

class Mutex(object):
def __init__(self, *, name=''):
self.name = name
self.lck = threading.Lock()

def __enter__(self):
self.lock()

def __exit__(self, type, value, traceback):
self.unlock()

def lock(self):
self.lck.acquire(True)

def unlock(self):
self.lck.release()

class OutputLogger(object):
def __init__(self, domain, parent=None):
self.domain = domain
@@ -39,7 +56,7 @@ def next(self):

class Chan(object):
def __init__(self, *, zero=None, discard=None):
self.lock = threading.Lock()
self.lock = Mutex(name='margo.Chan')
self.ev = threading.Event()
self.dq = deque([], maxlen=discard)
self.closed = False
@@ -7,9 +7,9 @@


STATUS_KEY = '#mg.Status'
STATUS_PFX = ' '
STATUS_SFX = ' '
STATUS_SEP = ' '
STATUS_PFX = ' '
STATUS_SFX = ' '
STATUS_SEP = ' '

def render(*, mg, view, state, status):
def cb():
@@ -240,7 +240,7 @@ def __init__(self, v={}):

# in testing, we should be able to push 50MiB+ files constantly without noticing a performance problem
# but keep this number low (realistic source files sizes) at least until we optimize things
MAX_VIEW_SIZE = 512 << 10
MAX_VIEW_SIZE = 8 << 20

# TODO: only send the content when it actually changes
# TODO: do chunked copying i.e. copy e.g. 1MiB at a time
@@ -352,6 +352,11 @@ def _view_hash(view):

return 'id=%s,change=%d' % (_view_id(view), view.change_count())


_lang_by_basename = {
'go.mod': 'go.mod',
'go.sum': 'go.sum',
}
_scope_lang_pat = re.compile(r'(?:source\.\w+|source|text)[.]([^\s.]+)')
def _view_scope_lang(view, pos):
if view is None:
@@ -363,6 +368,11 @@ def _view_scope_lang(view, pos):
if view_is_9o(view):
return (scope, 'cmd-prompt')

nm = basename(view_path(view))
lb = _lang_by_basename.get(nm)
if lb:
return (scope, lb)

l = _scope_lang_pat.findall(scope)
if not l:
return (scope, '')
@@ -3,8 +3,8 @@ sudo: false
language: go

go:
- 1.10.x
- 1.11.x
- 1.12.x
- tip

matrix:

0 comments on commit aeeff9a

Please sign in to comment.
You can’t perform that action at this time.