Skip to content

Commit

Permalink
Next (#948)
Browse files Browse the repository at this point in the history
* 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 aeeff9a
Show file tree
Hide file tree
Showing 449 changed files with 92,167 additions and 64,100 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Expand Up @@ -3,10 +3,8 @@ sudo: false
language: go language: go


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


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


## Changes ## 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 ## 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 ## 18.11.28


Expand All @@ -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`. It's bound to the keys `ctrl+.`,`ctrl+0`.


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

```json ```json
{ {
"keys": ["ctrl+0"], "keys": ["ctrl+0"],
Expand All @@ -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. - Several new snippets have been added and old ones improved.


- AppendSnippet: `name = |` suggests: - AppendSnippet: `name = |` suggests:

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


- DeferSnippet: - DeferSnippet:

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


- ReturnSnippet: - ReturnSnippet:

- `return` - `return`


- MutexSnippet: `mu.|` suggests: - MutexSnippet: `mu.|` suggests:

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


- PackageNameSnippet: - PackageNameSnippet:

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


- DocSnippet: suggest function names, field names, etc. inside the corresponding _documentation_ comment - DocSnippet: suggest function names, field names, etc. inside the corresponding _documentation_ comment
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -74,4 +74,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l


<br> <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>
11 changes: 9 additions & 2 deletions SUPPORT.md
Expand Up @@ -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. - 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. - 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 ## 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. - Windows and macOS should work without issue, but no testing is done on them.


## Tools ## Tools


Please note: 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. - By default `fmt` is achieved through direct use of the packages in the stdlib and not the binaries on your system.


## Sponsors & Backers ## Sponsors & Backers
Expand Down
2 changes: 1 addition & 1 deletion gosubl/about.py
@@ -1,7 +1,7 @@
import re import re
import sublime import sublime


TAG = '19.06.16-1' TAG = '19.10.22-1'
ANN = 'a'+TAG ANN = 'a'+TAG
VERSION = 'r'+TAG VERSION = 'r'+TAG
VERSION_PAT = re.compile(r'\d{2}[.]\d{2}[.]\d{2}-\d+', re.IGNORECASE) VERSION_PAT = re.compile(r'\d{2}[.]\d{2}[.]\d{2}-\d+', re.IGNORECASE)
Expand Down
12 changes: 7 additions & 5 deletions gosubl/margo.py
@@ -1,7 +1,7 @@
from . import _dbg from . import _dbg
from . import gs, gsq, sh from . import gs, gsq, sh
from .margo_agent import MargoAgent 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_render import render
from .margo_state import State, actions, client_actions, Config, _view_scope_lang, view_is_9o, MgView from .margo_state import State, actions, client_actions, Config, _view_scope_lang, view_is_9o, MgView
from base64 import b64decode from base64 import b64decode
Expand All @@ -10,7 +10,6 @@
import os import os
import shlex import shlex
import sublime import sublime
import threading
import time import time
import webbrowser import webbrowser


Expand All @@ -34,11 +33,11 @@ def __init__(self):
} }
self.file_ids = [] self.file_ids = []
self._hud_state = {} 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_name = 'GoSublime/HUD'
self.hud_id = self.hud_name.replace('/','-').lower() self.hud_id = self.hud_name.replace('/','-').lower()
self._views = {} self._views = {}
self._view_lock = threading.Lock() self._view_lock = Mutex(name='margo.MargoSingleton._view_lock')
self._gopath = '' self._gopath = ''


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


if view.is_loading():
return False

if not self.enabled(view): if not self.enabled(view):
return False return False


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


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


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


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


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


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


Expand Down
19 changes: 18 additions & 1 deletion gosubl/margo_common.py
Expand Up @@ -5,6 +5,23 @@
import sublime import sublime
import time 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): class OutputLogger(object):
def __init__(self, domain, parent=None): def __init__(self, domain, parent=None):
self.domain = domain self.domain = domain
Expand Down Expand Up @@ -39,7 +56,7 @@ def next(self):


class Chan(object): class Chan(object):
def __init__(self, *, zero=None, discard=None): def __init__(self, *, zero=None, discard=None):
self.lock = threading.Lock() self.lock = Mutex(name='margo.Chan')
self.ev = threading.Event() self.ev = threading.Event()
self.dq = deque([], maxlen=discard) self.dq = deque([], maxlen=discard)
self.closed = False self.closed = False
Expand Down
6 changes: 3 additions & 3 deletions gosubl/margo_render.py
Expand Up @@ -7,9 +7,9 @@




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


def render(*, mg, view, state, status): def render(*, mg, view, state, status):
def cb(): def cb():
Expand Down
12 changes: 11 additions & 1 deletion gosubl/margo_state.py
Expand Up @@ -240,7 +240,7 @@ def __init__(self, v={}):


# in testing, we should be able to push 50MiB+ files constantly without noticing a performance problem # 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 # 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: only send the content when it actually changes
# TODO: do chunked copying i.e. copy e.g. 1MiB at a time # TODO: do chunked copying i.e. copy e.g. 1MiB at a time
Expand Down Expand Up @@ -352,6 +352,11 @@ def _view_hash(view):


return 'id=%s,change=%d' % (_view_id(view), view.change_count()) 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.]+)') _scope_lang_pat = re.compile(r'(?:source\.\w+|source|text)[.]([^\s.]+)')
def _view_scope_lang(view, pos): def _view_scope_lang(view, pos):
if view is None: if view is None:
Expand All @@ -363,6 +368,11 @@ def _view_scope_lang(view, pos):
if view_is_9o(view): if view_is_9o(view):
return (scope, 'cmd-prompt') 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) l = _scope_lang_pat.findall(scope)
if not l: if not l:
return (scope, '') return (scope, '')
Expand Down
2 changes: 1 addition & 1 deletion src/margo.sh/.travis.yml
Expand Up @@ -3,8 +3,8 @@ sudo: false
language: go language: go


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


matrix: matrix:
Expand Down

0 comments on commit aeeff9a

Please sign in to comment.