From 107c4673efee5ca5a72d49c81c8e1f78de991bce Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 21 Apr 2023 18:47:10 +0200 Subject: [PATCH] chore: separated modules in a cargo workspace --- Cargo.toml | 33 ++----------------- client/nvim/Cargo.toml | 18 ++++++++++ .../nvim => client/nvim/src}/codemp.lua | 0 {src/client/nvim => client/nvim/src}/main.rs | 2 +- server/Cargo.toml | 19 +++++++++++ {src/server => server/src}/buffer/actor.rs | 0 {src/server => server/src}/buffer/mod.rs | 0 {src/server => server/src}/buffer/service.rs | 0 {src/server => server/src}/main.rs | 0 src/{lib => }/client.rs | 0 src/{lib => }/cursor.rs | 0 src/{lib => }/lib.rs | 0 src/{lib => }/operation/controller.rs | 0 src/{lib => }/operation/factory.rs | 0 src/{lib => }/operation/mod.rs | 0 src/{lib => }/operation/processor.rs | 0 src/{lib => }/proto.rs | 0 17 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 client/nvim/Cargo.toml rename {src/client/nvim => client/nvim/src}/codemp.lua (100%) rename {src/client/nvim => client/nvim/src}/main.rs (99%) create mode 100644 server/Cargo.toml rename {src/server => server/src}/buffer/actor.rs (100%) rename {src/server => server/src}/buffer/mod.rs (100%) rename {src/server => server/src}/buffer/service.rs (100%) rename {src/server => server/src}/main.rs (100%) rename src/{lib => }/client.rs (100%) rename src/{lib => }/cursor.rs (100%) rename src/{lib => }/lib.rs (100%) rename src/{lib => }/operation/controller.rs (100%) rename src/{lib => }/operation/factory.rs (100%) rename src/{lib => }/operation/mod.rs (100%) rename src/{lib => }/operation/processor.rs (100%) rename src/{lib => }/proto.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index de0c0c1..ca5b0c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,25 +1,13 @@ +[workspace] +members = ["client/nvim", "server"] + [package] name = "codemp" version = "0.2.0" edition = "2021" -# [features] -# default = ["nvim"] -# nvim = [] - [lib] name = "codemp" -path = "src/lib/lib.rs" - -[[bin]] # Bin to run the CodeMP gRPC server -name = "server" -path = "src/server/main.rs" -required-features = ["server"] - -[[bin]] -name = "client-nvim" -path = "src/client/nvim/main.rs" -required-features = ["nvim"] [dependencies] # core @@ -29,27 +17,12 @@ prost = "0.11.8" md5 = "0.7.0" uuid = { version = "1.3.1", features = ["v4"] } operational-transform = { version = "0.6", features = ["serde"] } -# can these be optional? tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "sync", "full"], optional = false } tokio-stream = { version = "0.1", optional = false } serde = { version = "1", optional = false } serde_json = { version = "1", optional = false } -# runtime -# logs tracing-subscriber = { version = "0.3", optional = true } -# nvim -rmpv = { version = "1", optional = true } -clap = { version = "4.2.1", features = ["derive"], optional = true } -nvim-rs = { version = "0.5", features = ["use_tokio"], optional = true } similar = { version = "2.2", features = ["inline"] } [build-dependencies] tonic-build = "0.9" - -[features] -default = [] -logs = ["dep:tracing-subscriber"] -# runtime = ["dep:tokio", "dep:tokio-stream"] -# serde = ["dep:serde", "dep:serde_json"] -server = ["logs", "dep:clap"] -nvim = ["logs", "dep:nvim-rs", "dep:clap", "dep:rmpv"] diff --git a/client/nvim/Cargo.toml b/client/nvim/Cargo.toml new file mode 100644 index 0000000..ea71678 --- /dev/null +++ b/client/nvim/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "codemp-nvim" +version = "0.2.0" +edition = "2021" + +[dependencies] +codemp = { path = "../.." } +tracing = "0.1" +tracing-subscriber = "0.3" +uuid = { version = "1.3.1", features = ["v4"] } +operational-transform = { version = "0.6", features = ["serde"] } +tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "sync", "full"] } +serde = "1" +serde_json = "1" +rmpv = "1" +clap = { version = "4.2.1", features = ["derive"] } +nvim-rs = { version = "0.5", features = ["use_tokio"] } +async-trait = "0.1.68" diff --git a/src/client/nvim/codemp.lua b/client/nvim/src/codemp.lua similarity index 100% rename from src/client/nvim/codemp.lua rename to client/nvim/src/codemp.lua diff --git a/src/client/nvim/main.rs b/client/nvim/src/main.rs similarity index 99% rename from src/client/nvim/main.rs rename to client/nvim/src/main.rs index 58b5d12..e7976b4 100644 --- a/src/client/nvim/main.rs +++ b/client/nvim/src/main.rs @@ -41,7 +41,7 @@ impl NeovimHandler { } } -#[tonic::async_trait] +#[async_trait::async_trait] impl Handler for NeovimHandler { type Writer = Compat; diff --git a/server/Cargo.toml b/server/Cargo.toml new file mode 100644 index 0000000..5fa0755 --- /dev/null +++ b/server/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "codemp-server" +version = "0.2.0" +edition = "2021" + +[dependencies] +codemp = { path = ".." } +tracing = "0.1" +tracing-subscriber = "0.3" +tonic = { version = "0.9", features = ["tls", "tls-roots"] } +prost = "0.11.8" +md5 = "0.7.0" +uuid = { version = "1.3.1", features = ["v4"] } +operational-transform = { version = "0.6", features = ["serde"] } +tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "sync", "full"] } +tokio-stream = "0.1" +serde = "1" +serde_json = "1" +clap = { version = "4.2.1", features = ["derive"] } diff --git a/src/server/buffer/actor.rs b/server/src/buffer/actor.rs similarity index 100% rename from src/server/buffer/actor.rs rename to server/src/buffer/actor.rs diff --git a/src/server/buffer/mod.rs b/server/src/buffer/mod.rs similarity index 100% rename from src/server/buffer/mod.rs rename to server/src/buffer/mod.rs diff --git a/src/server/buffer/service.rs b/server/src/buffer/service.rs similarity index 100% rename from src/server/buffer/service.rs rename to server/src/buffer/service.rs diff --git a/src/server/main.rs b/server/src/main.rs similarity index 100% rename from src/server/main.rs rename to server/src/main.rs diff --git a/src/lib/client.rs b/src/client.rs similarity index 100% rename from src/lib/client.rs rename to src/client.rs diff --git a/src/lib/cursor.rs b/src/cursor.rs similarity index 100% rename from src/lib/cursor.rs rename to src/cursor.rs diff --git a/src/lib/lib.rs b/src/lib.rs similarity index 100% rename from src/lib/lib.rs rename to src/lib.rs diff --git a/src/lib/operation/controller.rs b/src/operation/controller.rs similarity index 100% rename from src/lib/operation/controller.rs rename to src/operation/controller.rs diff --git a/src/lib/operation/factory.rs b/src/operation/factory.rs similarity index 100% rename from src/lib/operation/factory.rs rename to src/operation/factory.rs diff --git a/src/lib/operation/mod.rs b/src/operation/mod.rs similarity index 100% rename from src/lib/operation/mod.rs rename to src/operation/mod.rs diff --git a/src/lib/operation/processor.rs b/src/operation/processor.rs similarity index 100% rename from src/lib/operation/processor.rs rename to src/operation/processor.rs diff --git a/src/lib/proto.rs b/src/proto.rs similarity index 100% rename from src/lib/proto.rs rename to src/proto.rs