-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute_command.py
More file actions
25 lines (22 loc) · 1.01 KB
/
Copy pathexecute_command.py
File metadata and controls
25 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from __future__ import annotations
import sublime_aio
from Mir.types.lsp import ExecuteCommandParams
from Mir import mir, server_for_view
from typing import Any
class mir_execute_command_command(sublime_aio.ViewCommand):
async def run(self, server_name: str, command: str | None = None, arguments: list[Any] | None = None) -> None:
if not command:
return
sublime_commands = mir.commands.to_sublime_commands(command)
if sublime_commands:
for sublime_command in sublime_commands:
self.view.run_command(sublime_command, {'arguments': arguments})
# after handling the commands on the client side, don't send the command to the server
return
server = server_for_view(server_name, self.view)
if server:
params: ExecuteCommandParams = {"command": command}
if arguments:
params["arguments"] = arguments
req = server.send.execute_command(params)
_ = await req.result