2024-09-07 22:12:32 +02:00
[![codemp ](https://code.mp/static/banner.png )](https://code.mp)
2024-09-16 04:52:24 +02:00
[![GitHub last commit ](https://img.shields.io/github/last-commit/hexedtech/codemp-nvim )](https://github.com/hexedtech/codemp-nvim)
[![LuaRocks ](https://img.shields.io/luarocks/v/alemi/codemp )](https://luarocks.org/modules/alemi/codemp)
[![Gitter ](https://img.shields.io/gitter/room/hexedtech/codemp )](https://gitter.im/hexedtech/codemp)
2024-08-17 17:04:00 +02:00
2024-09-05 04:37:36 +02:00
> `codemp` is a **collaborative** text editing solution to work remotely.
2022-09-14 12:13:48 +02:00
2024-08-17 16:57:38 +02:00
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.
2024-09-05 04:37:36 +02:00
# codemp-nvim
2024-08-17 16:57:38 +02:00
2024-09-05 04:37:36 +02:00
This is the reference codemp [neovim ](https://neovim.io ) plugin maintained by [hexedtech ](https://hexed.technology )
2024-08-17 16:57:38 +02:00
2024-09-25 22:37:43 +02:00
> compare development status with our [feature comparison matrix](https://github.com/orgs/hexedtech/projects/3)
2024-09-05 06:11:30 +02:00
# installation
2024-09-17 20:04:28 +02:00
Just add `hexedtech/codemp-nvim` to your plugin spec.
2024-09-05 06:11:30 +02:00
2024-09-17 20:04:28 +02:00
If you're using [`lazy.nvim` ](https://github.com/folke/lazy.nvim ), everything will be configured automatically!
If you're using something else to load `codemp-nvim` , you need to also do the following:
* run `build.lua` during installation and every update
* invoke `require('codemp-nvim').setup({ ... })` after loading, pass your config
2024-09-05 06:11:30 +02:00
Note that the native codemp lua library will be downloaded automatically on each update.
## neo-tree integration
`codemp-nvim` integrates with [neo-tree ](https://github.com/nvim-neo-tree/neo-tree.nvim ) to provide a rich and intuitive file tree.
2024-09-06 03:32:44 +02:00
To enable this integration, add `neo_tree = true` in plugin `opts` and add `codemp` as a neo-tree source:
2024-09-05 06:11:30 +02:00
```lua
2024-09-06 03:32:44 +02:00
{
"hexedtech/codemp-nvim",
opts = { neo_tree = true },
},
2024-09-05 06:11:30 +02:00
{
"nvim-neo-tree/neo-tree.nvim",
dependencies = { "hexedtech/codemp-nvim" },
config = function ()
require('neo-tree').setup({
sources = {
-- your other sources
"codemp.neo-tree",
},
})
end,
}
```
2024-08-17 17:11:20 +02:00
2024-09-05 06:11:30 +02:00
# usage
2024-09-05 05:09:21 +02:00
Interact with this plugin using the `:MP` command.
2024-08-17 17:11:20 +02:00
2024-09-05 05:09:21 +02:00
Most actions can be performed from the side tree: toggle it with `:MP toggle` .
2024-08-17 16:57:38 +02:00
2024-08-17 17:04:00 +02:00
| command | description |
| --- | --- |
| `:MP toggle` | toggles the codemp sidebar |
| `:MP connect [host] [username] [password]` | to connect to server, user and pwd will be prompted if not given |
2024-08-17 17:15:39 +02:00
once connected, more commands become available:
| command | description |
| --- | --- |
2024-08-17 17:04:00 +02:00
| `:MP disconnect` | disconnects from server |
| `:MP id` | shows current client id |
2024-08-22 03:41:46 +02:00
| `:MP start <workspace>` | will create a new workspace with given name |
| `:MP invite <user> [workspace]` | invite given user to workspace |
| `:MP available` | list all workspaces available to join |
2024-08-17 17:04:00 +02:00
| `:MP join <workspace>` | will join requested workspace; starts processing cursors, users and filetree |
2024-08-17 17:15:39 +02:00
after a workspace is joined, more commands become available:
| command | description |
| --- | --- |
2024-08-17 17:04:00 +02:00
| `:MP leave <workspace>` | disconnect from a joined workspace |
| `:MP attach <buffer>` | will attach to requested buffer if it exists (opens a new local buffer and uses current window) |
| `:MP detach <buffer>` | detach from a buffer and stop receiving changes |
| `:MP share` | shares current file: creates a new buffer with local file's content, and attach to it |
| `:MP sync` | forces resynchronization of current buffer |
| `:MP create <bufname>` | will create a new empty buffer in workspace |
| `:MP delete <bufname>` | will delete a buffer from workspace |
2024-08-17 16:57:38 +02:00
### quick start
* first connect to server with `:MP connect`
* then join a workspace with `:MP join <workspace>`
* either attach directly to a buffer with `:MP attach <buffer>` or browse available buffers with `:MP toggle`
MP command autocompletes available options for current state, so cycle < Tab > if you forget any name
2024-08-17 17:18:12 +02:00
## configuration
2024-09-06 03:32:44 +02:00
`codemp-nvim` gets most of its configuration from `setup()` options. If you're using `lazy.nvim` , just place these in the `opts` table in your spec, otherwise be sure to `require('codemp').setup({...})` .
```lua
opts = {
2024-09-06 03:35:39 +02:00
neo_tree = false, -- enable neo-tree integration
timer_interval = 100, -- poll for codemp callbacks every __ ms
2024-09-06 03:53:52 +02:00
debug = false, -- print text operations as they happen
2024-09-06 03:32:44 +02:00
}
```
2024-09-05 06:11:06 +02:00
`codemp-nvim` reads some global vim variables for configuration:
* `vim.g.codemp_username` will be used when connecting instead of prompting for username
* `vim.g.codemp_password` will be used when connecting instead of prompting for password
2024-08-17 16:57:38 +02:00
2024-08-17 17:18:12 +02:00
## building
2024-09-05 06:13:40 +02:00
this plugin relies on the native codemp lua bindings: just compile the main `codemp` project with `lua` feature enabled, rename the
output library into `native.so` (or `.dll` or `.dylib` ) and place it together with the plugin lua files while bundling
2022-09-14 12:13:48 +02:00
2024-08-17 17:18:12 +02:00
```
.config/
|-nvim/
: |-lua/
: : |-codemp/
2024-09-05 06:13:40 +02:00
: : : |- native.(so|dll|dylib)
2024-08-17 17:18:12 +02:00
: : : |- init.lua
: : : : ...
```