chore: make readme, clean up some leftover old stuff

Former-commit-id: 2542b39c99e620c7fab17b532d30bfd0381373a2
This commit is contained in:
cschen 2024-09-07 15:59:00 +02:00
parent 6c54a15560
commit 925b0e8eca
4 changed files with 102 additions and 17 deletions

View file

@ -19,13 +19,6 @@
"file": "${packages}/CodempClient/README.md" "file": "${packages}/CodempClient/README.md"
} }
}, },
{
"caption": "Codemp: Dump Internals",
"command": "codemp_client_dump",
"args": {
// "server_host": "http://[::1]:50051"
}
},
{ {
// # on_window_command, does not trigger when called from the command palette // # on_window_command, does not trigger when called from the command palette
// # See: https://github.com/sublimehq/sublime_text/issues/2234 // # See: https://github.com/sublimehq/sublime_text/issues/2234

83
README_sublime.md Normal file
View file

@ -0,0 +1,83 @@
[![codemp](https://codemp.dev/static/banner.png)](https://codemp.dev)
> `codemp` is a **collaborative** text editing solution to work remotely.
It seamlessly integrates in your editor providing remote cursors and instant text synchronization,
as well as a remote virtual workspace for you and your team.
# Codemp-Sublime
This is the reference [sublime](https://sublimetext.com) plugin for `codemp` maintained by [hexedtech](https://hexed.technology)
# Installation
## Package Control
The fastest and easiest way to install Codemp is via Package Control, the de-facto package manager for Sublime Text.
Package Control not only installs your packages for you, it also ensures that they are kept up to date
to make sure that you always have the benefit of the latest bug fixes and features for all of your installed packages.
If you are new to Sublime Text and don't have Package Control installed yet, you'll have to do that first.
More recent builds of Sublime Text have an option in the `Tools` menu named `Install Package Control...` that will install Package Control for you.
(won't show if package control is already installed!)
Currently this package is not on the sublime package repository.
But it can still be installed by package control.
* Open the command palette in Sublime (`Shift+Ctrl+P` on Windows/Linux or `Shift+⌘+P` on MacOS)
* select the `Package Control: Add Repository` command and paste `https://github.com/hexedtech/codemp-sublime.git` into the quick panel
* open the command palette again and select `Package Control: Satisfy Packages` or restart Sublime to force the installation.
## Manual
Alternatively you can simply `git clone` this repository into your `Packages` folder:
You can access it via sublime through `Settings -> Browse Packages...`.
You will need to keep the package up to date yourself.
# Usage
## Overview
* All sublime windows share a single client session with a server.
* The workspaces are window specific, similarly to a `sublime-project`. So you can open `workspace-1` in one window and `workspace-2` in another, so long as both are in the same server and you have access to them.
* Joining a workspace will materialize a virtual file system mimicking the remote one as if it were a project folder.
## quick start
* first connect to server with `Codemp: Connect`
* then join a workspace with `Codemp: Join Workspace`
* attach directly to a buffer with `Codemp: Join Buffer` and start typing away!
all commands will provide a list of available ids to chose from
## Commands
Interact with this plugin using the command palette.
In future versions side bar interaction will be attempted.
If an argument is shown between square brakets `[arg]` then the user will be prompted
if not present (either as simple text input or selecting from a list).
| command label | arguments | description |
| --- | --- | --- |
| `Codemp: Connect` | `[host]` `[user]` `[password]` | to connect to a `codemp` server specified by `host` (defaults to the reference `http://codemp.dev` hexedtech server).
Once connected the following commands will become available:
| command label | arguments | description |
| --- | --- | --- |
|`Codemp: Disconnect Client` | `None` | disconnects the client from the server.
|`Codemp: Create Workspace` | `[workspace_id]` | create a workspace with the provided name.
|`Codemp: Delete Workspace` | `[workspace_id]` | delete an owned workspace from the server.
|`Codemp: Invite To Workspace` | `[workspace_id]` `[user_name]` | invite another registered codemp user to the specified workspace to begin collaborating.
|`Codemp: Join Workspace` | `[workspace_id]` | join a workspace in the server, it can either be yours or one you were invited to. You can join multiple workspaces.
After joining a workspace the following commands will become available:
| command label | arguments | description |
| --- | --- | --- |
|`Codemp: Leave Workspace` | `[workspace_id]` | leave the specified workspace, it will close all associated buffers.
| `Codemp: Create Buffer` | `[workspace_id]` `[buffer_id]` | creates the buffer `buffer_id` in the previously joined workspace `workspace_id`.
| `Codemp: Delete Buffer` | `[workspace_id]` `[buffer_id]` | deletes the buffer `buffer_id` in the previously joined workspace `workspace_id` that you own.
| `Codemp: Join Buffer` | `[workspace_id]` `[buffer_id]` | joins the specified buffer in the workspace and loads a file with its contents for you to interact with.
After Joining a buffer the following commands will become available:
| command label | arguments | description |
| --- | --- | --- |
|`Codemp: Leave Buffer` | `[workspace_id]` `[buffer_id]` | detach from the specified buffer and closes the corresponding view (all changes will remain in the server).
##

View file

@ -172,14 +172,6 @@ class CodempClientTextChangeListener(sublime_plugin.TextChangeListener):
# replace_text: swaps the content of a view with the given text. # replace_text: swaps the content of a view with the given text.
class CodempClientDumpCommand(sublime_plugin.WindowCommand):
def is_enabled(self) -> bool:
return super().is_enabled()
def run(self):
client.dump()
# Client Commands # Client Commands
############################################################################# #############################################################################
# Connect Command # Connect Command
@ -210,6 +202,18 @@ class CodempConnectCommand(sublime_plugin.WindowCommand):
return SimpleTextInput( return SimpleTextInput(
("server_host", "http://codemp.dev:50053"), ("server_host", "http://codemp.dev:50053"),
("user_name", f"user-{random.random()}"), ("user_name", f"user-{random.random()}"),
("password", "password?"),
)
if "user_name" not in args:
return SimpleTextInput(
("user_name", f"user-{random.random()}"),
("password", "password?"),
)
if "password" not in args:
return SimpleTextInput(
("password", "password?"),
) )
@ -316,7 +320,7 @@ class CodempCreateWorkspaceCommand(sublime_plugin.WindowCommand):
class CodempDeleteWorkspaceCommand(sublime_plugin.WindowCommand): class CodempDeleteWorkspaceCommand(sublime_plugin.WindowCommand):
def is_enabled(self): def is_enabled(self):
return client.codemp is not None and len(client.all_workspaces(self.window)) > 0 return client.codemp is not None
def run(self, workspace_id: str): def run(self, workspace_id: str):
assert client.codemp is not None assert client.codemp is not None
@ -337,6 +341,11 @@ class CodempDeleteWorkspaceCommand(sublime_plugin.WindowCommand):
client.codemp.delete_workspace(workspace_id) client.codemp.delete_workspace(workspace_id)
def input(self, args):
workspaces = client.codemp.list_workspaces(True, False) # noqa: F841
if "workspace_id" not in args:
return SimpleListInput(("workspace_id", workspaces.wait()))
# WORKSPACE COMMANDS # WORKSPACE COMMANDS
############################################################################# #############################################################################

View file

@ -25,7 +25,7 @@ def make_cursor_callback(workspace: VirtualWorkspace):
vbuff = workspace.buff_by_id(event.buffer) vbuff = workspace.buff_by_id(event.buffer)
if vbuff is None: if vbuff is None:
logger.warning( logger.warning(
"received a cursor event for a buffer that wasn't saved internally." f"{workspace.id} received a cursor event for a buffer that wasn't saved internally."
) )
continue continue