Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next #948

Merged
merged 23 commits into from
Oct 22, 2019
Merged

Next #948

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3f79d0f
sync margo
DisposaBoy Nov 29, 2018
479c279
sync margo
DisposaBoy Dec 7, 2018
9bddf10
don't crash the ipc when decoding invalid utf-8
DisposaBoy Dec 7, 2018
367fb98
update .travis.yml to list the versions that are actually supported
DisposaBoy Jun 26, 2019
1fa209d
sync margo
DisposaBoy Jun 26, 2019
e715195
tweak for better readability
DisposaBoy Jun 26, 2019
1227ae2
recognise go.mod and go.sum files and increase MAX_VIEW_SIZE to 8MiB
DisposaBoy Jun 26, 2019
8011586
use custom Mutex for locking to make it easier to debug
DisposaBoy Jun 26, 2019
96d6e2c
don't trigger an action while the view is loading
DisposaBoy Jun 26, 2019
7c65941
prep CHANGELOG for next release
DisposaBoy Jun 26, 2019
a3913e8
sync margo
DisposaBoy Jul 8, 2019
466c0f8
reduce the spacing between status items now that they have a prefix
DisposaBoy Jul 8, 2019
36ce43c
set MARGO_AGENT_GOBIN when building margo.exe to avoid side-effects o…
DisposaBoy Jul 8, 2019
ef8ef81
update SUPPORT docs
DisposaBoy Jul 8, 2019
2453428
update CHANGELOG for next realease
DisposaBoy Jul 8, 2019
05819e7
sync margo
DisposaBoy Jul 9, 2019
4775407
update next CHANGELOG
DisposaBoy Jul 9, 2019
28f0ff7
sync margo
DisposaBoy Jul 22, 2019
e26e125
improve 9o filename regexp to reduce cases of highlighting things tha…
DisposaBoy Jul 22, 2019
975d5cc
Update CHANGELOG.md
DisposaBoy Oct 22, 2019
481880a
Update about.py
DisposaBoy Oct 22, 2019
7b71bf0
Update README.md
DisposaBoy Oct 22, 2019
b38ad9c
Update README.md
DisposaBoy Oct 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions Ariana.sublime-color-scheme
Original file line number Diff line number Diff line change
Expand Up @@ -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%)",
Expand All @@ -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":
{
Expand Down
50 changes: 48 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

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

```json
{
"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.

- 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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
11 changes: 9 additions & 2 deletions SUPPORT.md
Original file line number Diff line number Diff line change
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.
- 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
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 = '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)
Expand Down
12 changes: 7 additions & 5 deletions gosubl/margo.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,7 +10,6 @@
import os
import shlex
import sublime
import threading
import time
import webbrowser

Expand All @@ -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):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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')
Expand Down
13 changes: 7 additions & 6 deletions gosubl/margo_agent.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand All @@ -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 = {}
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
19 changes: 18 additions & 1 deletion gosubl/margo_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions gosubl/margo_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
12 changes: 11 additions & 1 deletion gosubl/margo_state.py
Original file line number Diff line number Diff line change
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
# 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
Expand Down Expand Up @@ -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:
Expand All @@ -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, '')
Expand Down
2 changes: 1 addition & 1 deletion src/margo.sh/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ sudo: false
language: go

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

matrix:
Expand Down
Loading