Skip to content

Commit

Permalink
include client names
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-jpq committed Jan 19, 2025
1 parent f518278 commit c64aec3
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 20 deletions.
3 changes: 3 additions & 0 deletions coq/clients/lsp/mul_bandit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

class MultiArmedBandit:
pass
8 changes: 4 additions & 4 deletions coq/clients/t9/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def _decode(
or not isinstance((old_prefix := reply.get("old_prefix")), str)
or not isinstance((results := reply.get("results")), Sequence)
):
log.warn("%s", reply)
log.warning("%s", reply)
else:
for result in results:
try:
resp = _DECODER(result)
except DecodeError as e:
log.warn("%s", e)
log.warning("%s", e)
else:
new_text = resp.new_prefix + resp.new_suffix
edit = ContextualEdit(
Expand Down Expand Up @@ -262,7 +262,7 @@ async def cont() -> Optional[str]:
await self._proc.stdin.drain()
out = await _readline(self._proc.stdout)
except (ConnectionError, IncompleteReadError) as e:
log.warn("%s", e)
log.warning("%s", e)
await self._clean()
return None
else:
Expand Down Expand Up @@ -296,7 +296,7 @@ async def _work(self, context: Context) -> AsyncIterator[Completion]:
try:
resp = loads(reply)
except JSONDecodeError as e:
log.warn("%s", e)
log.warning("%s", e)
else:
if isinstance(resp, Mapping):
self._t9_locked = resp.get("is_locked", False)
Expand Down
12 changes: 6 additions & 6 deletions coq/lsp/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def parse_item(
else:
go, parsed = _item_parser(item)
if not go:
log.warn("%s -> %s", client, parsed)
log.warning("%s -> %s", client, parsed)
return None
else:
assert isinstance(parsed, CompletionItem)
Expand Down Expand Up @@ -303,7 +303,7 @@ def parse_inline_item(
go, parsed = _inline_item_parser(item)
if not go:
if "kind" not in item:
log.warn("%s -> %s", client, parsed)
log.warning("%s -> %s", client, parsed)
return None
else:
assert isinstance(parsed, InlineCompletionItem)
Expand Down Expand Up @@ -359,7 +359,7 @@ def parse(
is_complete = _falsy(resp.get("isIncomplete"))

if not isinstance((items := resp.get("items")), Sequence):
log.warn("%s", f"Unknown LSP resp -- {type(items)}")
log.warning("%s", f"Unknown LSP resp -- {type(items)}")
return LSPcomp(client=client, local_cache=is_complete, items=iter(()))

else:
Expand Down Expand Up @@ -405,7 +405,7 @@ def parse(
return LSPcomp(client=client, local_cache=True, items=comps)

else:
log.warn("%s", f"Unknown LSP resp -- {type(resp)}")
log.warning("%s", f"Unknown LSP resp -- {type(resp)}")
return LSPcomp(client=client, local_cache=False, items=iter(()))


Expand All @@ -426,7 +426,7 @@ def parse_inline(

elif isinstance(resp, Mapping):
if not isinstance((items := resp.get("items")), Sequence):
log.warn("%s", f"Unknown LSP resp -- {type(items)}")
log.warning("%s", f"Unknown LSP resp -- {type(items)}")
else:
comps = (
co1
Expand Down Expand Up @@ -467,6 +467,6 @@ def parse_inline(
)
return LSPcomp(client=client, local_cache=False, items=comps)
else:
log.warn("%s", f"Unknown LSP resp -- {type(resp)}")
log.warning("%s", f"Unknown LSP resp -- {type(resp)}")

return LSPcomp(client=client, local_cache=local_cache, items=iter(()))
6 changes: 3 additions & 3 deletions coq/server/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ async def apply(buf: Buffer, instructions: Iterable[EditInstruction]) -> _MarkSh
ctx = []

msg = Template(dedent(tpl)).substitute(e=e, inst=inst, ctx=ctx)
log.warn("%s", msg)
log.warning("%s", msg)

return m_shift

Expand Down Expand Up @@ -518,15 +518,15 @@ async def _view(

for row in rows:
if row.start < 0 or row.stop > state.context.line_count:
log.warn("%s", pformat(("BAD ROW", row, comp)))
log.warning("%s", pformat(("BAD ROW", row, comp)))
return None
else:
atomic.buf_get_lines(buf, row.start, row.stop, True)

try:
lines = cast(Sequence[Sequence[str]], await atomic.commit(NoneType))
except NvimError as e:
log.warn("%s", e)
log.warning("%s", e)
return None
else:
return _lines(zip(rows, lines))
Expand Down
4 changes: 2 additions & 2 deletions coq/server/registrants/marks.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _safexform(xform: Optional[TextTransform], text: str) -> str:
try:
return "".join(chain.from_iterable(xform(text)))
except Exception as e:
log.warn("%s", e)
log.warning("%s", e)
return text


Expand Down Expand Up @@ -127,7 +127,7 @@ async def _single_mark(
{e}
"""
log.warn("%s", dedent(msg))
log.warning("%s", dedent(msg))
else:
await Nvim.exec("startinsert")
state(inserted_pos=(row, col))
Expand Down
2 changes: 1 addition & 1 deletion coq/server/registrants/omnifunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async def _comp_done(stack: Stack, event: Mapping[str, Any]) -> None:
commit_id=uuid4(),
)
else:
log.warn("%s", "delayed completion")
log.warning("%s", "delayed completion")


_ = (
Expand Down
2 changes: 1 addition & 1 deletion coq/server/registrants/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ async def _rolling_load(
Failed to load compiled snips
${e}
""".rstrip()
log.warn("%s", Template(dedent(tpl)).substitute(e=type(e)))
log.warning("%s", Template(dedent(tpl)).substitute(e=type(e)))
else:
await worker.populate(path, mtime=mtime, loaded=loaded)
if not silent:
Expand Down
2 changes: 1 addition & 1 deletion coq/server/registrants/user_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def eval_snips(
grammar = SnippetGrammar[maybe_grammar]
except KeyError:
grammar = SnippetGrammar.lsp
log.warn("%s", "bad snippet grammar -- reverting to LSP")
log.warning("%s", "bad snippet grammar -- reverting to LSP")

win = await Window.get_current()
buf = await win.get_buf()
Expand Down
2 changes: 1 addition & 1 deletion coq/snippets/loaders/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def load_direct(
)
except LoadError as e:
if ignore_error:
log.warn("%s", e)
log.warning("%s", e)
else:
raise
else:
Expand Down
2 changes: 1 addition & 1 deletion coq/snippets/parsers/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _consolidate(
for reg in chain.from_iterable(acc.values())
if _overlap(region, reg)
):
log.warn("%s", f"snippet region overlapped -- {overlapped}")
log.warning("%s", f"snippet region overlapped -- {overlapped}")
else:
a = acc.setdefault(idx, [])
a.append(region)
Expand Down
8 changes: 8 additions & 0 deletions lua/coq/lsp-request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@
)

local new_payload = function()
local client_names = {}
for _, client in pairs(client_map) do
local client_name = client.name
coq.validate {client_name = {client_name, "string", true}}
table.insert(client_names, client_name or vim.NIL)
end

return {
client = vim.NIL,
client_names = client_names,
done = true,
method = vim.NIL,
multipart = multipart,
Expand Down

0 comments on commit c64aec3

Please sign in to comment.