From 197c68f4b211a807390822a13804b8f163680aea Mon Sep 17 00:00:00 2001 From: keith Date: Tue, 15 Sep 2020 21:34:52 -0700 Subject: [PATCH] switch to synchronous neovim library --- Cargo.lock | 565 +++++++++++--------------------------- Cargo.toml | 6 +- src/bridge/mod.rs | 270 +++++++++--------- src/bridge/ui_commands.rs | 26 +- src/main.rs | 4 +- src/settings/mod.rs | 14 +- src/window.rs | 11 +- 7 files changed, 318 insertions(+), 578 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8fa39c0..d3e4f0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,12 +74,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "arc-swap" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" - [[package]] name = "arrayref" version = "0.3.6" @@ -101,17 +95,6 @@ dependencies = [ "libloading 0.6.3", ] -[[package]] -name = "async-trait" -version = "0.1.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1a4a2f97ce50c9d0282c1468816208588441492b40d813b2e0419c22c05e7f" -dependencies = [ - "proc-macro2 1.0.19", - "quote 1.0.7", - "syn 1.0.39", -] - [[package]] name = "atty" version = "0.2.14" @@ -137,9 +120,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "base64" -version = "0.11.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "bindgen" @@ -157,7 +140,7 @@ dependencies = [ "lazycell", "log", "peeking_take_while", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", "regex", "rustc-hash", @@ -194,22 +177,6 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - [[package]] name = "calloop" version = "0.4.4" @@ -352,80 +319,81 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "core-foundation" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" dependencies = [ - "core-foundation-sys 0.6.2", + "core-foundation-sys 0.7.0", "libc", ] [[package]] name = "core-foundation" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +checksum = "3b5ed8e7e76c45974e15e41bfa8d5b0483cd90191639e01d8f5f1e606299d3fb" dependencies = [ - "core-foundation-sys 0.7.0", + "core-foundation-sys 0.8.0", "libc", ] [[package]] name = "core-foundation-sys" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" [[package]] name = "core-foundation-sys" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" +checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6" [[package]] name = "core-graphics" -version = "0.17.3" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" +checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" dependencies = [ "bitflags", - "core-foundation 0.6.4", + "core-foundation 0.7.0", "foreign-types", "libc", ] [[package]] name = "core-graphics" -version = "0.19.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" +checksum = "f6082396a349fa49674ba1bda4077332a18bf150e8fa75745ece07085e29a113" dependencies = [ "bitflags", - "core-foundation 0.7.0", + "core-foundation 0.9.0", + "core-graphics-types", "foreign-types", "libc", ] [[package]] -name = "core-text" -version = "13.3.2" +name = "core-graphics-types" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db84654ad95211c082cf9795f6f83dc17d0ae6c985ac1b906369dc7384ed346d" +checksum = "e92f5d519093a4178296707dbaa3880eae85a5ef5386675f361a1cf25376e93c" dependencies = [ - "core-foundation 0.6.4", - "core-graphics 0.17.3", + "bitflags", + "core-foundation 0.9.0", "foreign-types", "libc", ] [[package]] name = "core-text" -version = "15.0.0" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131b3fd1f8bd5db9f2b398fa4fdb6008c64afc04d447c306ac2c7e98fba2a61d" +checksum = "04dfae50af11e72657fe7174cddb1ecddc5398037f7f6f39533ad69207c9a4e2" dependencies = [ - "core-foundation 0.7.0", - "core-graphics 0.19.2", + "core-foundation 0.9.0", + "core-graphics 0.22.0", "foreign-types", "libc", ] @@ -454,12 +422,12 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" dependencies = [ - "cfg-if", "crossbeam-utils", + "maybe-uninit", ] [[package]] @@ -545,9 +513,9 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.39", + "syn 1.0.40", ] [[package]] @@ -556,9 +524,9 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.39", + "syn 1.0.40", ] [[package]] @@ -617,9 +585,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dwrote" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcdf488e3a52a7aa30a05732a3e58420e22acb4b2b75635a561fc6ffbcab59ef" +checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" dependencies = [ "lazy_static", "libc", @@ -725,23 +693,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "font-kit" -version = "0.6.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f953474ebbe3460775ed2da52435477cc029493284d6ceb635598586a2c6298" +checksum = "1f9042cb45150fb2b2a012fc03d0f1d2071f18e90397b9d2a5ec8ade8464bf20" dependencies = [ "bitflags", "byteorder", - "core-foundation 0.7.0", - "core-graphics 0.19.2", - "core-text 15.0.0", + "core-foundation 0.9.0", + "core-graphics 0.22.0", + "core-text", "dirs", "dwrote", "float-ord", @@ -779,12 +741,23 @@ checksum = "69a039c3498dc930fe810151a34ba0c1c70b02b8625035592e74432f678591f2" [[package]] name = "freetype" -version = "0.4.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11926b2b410b469d0e9399eca4cbbe237a9ef02176c485803b29216307e8e028" +checksum = "bee38378a9e3db1cc693b4f88d166ae375338a0ff75cb8263e1c601d51f35dc6" dependencies = [ + "freetype-sys", "libc", - "servo-freetype-sys", +] + +[[package]] +name = "freetype-sys" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" +dependencies = [ + "cmake", + "libc", + "pkg-config", ] [[package]] @@ -803,118 +776,15 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" - -[[package]] -name = "futures" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" - -[[package]] -name = "futures-executor" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" - -[[package]] -name = "futures-macro" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" -dependencies = [ - "proc-macro-hack", - "proc-macro2 1.0.19", - "quote 1.0.7", - "syn 1.0.39", -] - -[[package]] -name = "futures-sink" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" - -[[package]] -name = "futures-task" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" -dependencies = [ - "once_cell", -] - -[[package]] -name = "futures-util" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" -dependencies = [ - "futures 0.1.29", - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", - "tokio-io", -] - [[package]] name = "getrandom" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] @@ -935,22 +805,22 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "harfbuzz" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f7426266a5ece3e49eae6f48e602c0f8c39917354a847eac9c06437dcde8da" +checksum = "776caa9519beb53f697d578b6777eebd1262265c84ae797620b7f8f9b3648d91" dependencies = [ "harfbuzz-sys", ] [[package]] name = "harfbuzz-sys" -version = "0.3.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d74cab8498b2d15700b694fb38f77562869d05e1f8b602dd05221a1ca2d63" +checksum = "bf8c27ca13930dc4ffe474880040fe9e0f03c2121600dc9c95423624cab3e467" dependencies = [ "cc", - "core-graphics 0.17.3", - "core-text 13.3.2", + "core-graphics 0.22.0", + "core-text", "foreign-types", "freetype", "pkg-config", @@ -1080,9 +950,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.76" +version = "0.2.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3" +checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" [[package]] name = "libloading" @@ -1106,9 +976,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af67924b8dd885cccea261866c8ce5b74d239d272e154053ff927dae839f5ae9" +checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" dependencies = [ "cc", "libc", @@ -1215,11 +1085,12 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722" +checksum = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9" dependencies = [ "adler", + "autocfg 1.0.1", ] [[package]] @@ -1235,7 +1106,7 @@ dependencies = [ "kernel32-sys", "libc", "log", - "miow 0.2.1", + "miow", "net2", "slab", "winapi 0.2.8", @@ -1253,29 +1124,6 @@ dependencies = [ "slab", ] -[[package]] -name = "mio-named-pipes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio", - "miow 0.3.5", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", -] - [[package]] name = "miow" version = "0.2.1" @@ -1288,16 +1136,6 @@ dependencies = [ "ws2_32-sys", ] -[[package]] -name = "miow" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" -dependencies = [ - "socket2", - "winapi 0.3.9", -] - [[package]] name = "mockall" version = "0.7.2" @@ -1320,9 +1158,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a673cb441f78cd9af4f5919c28576a3cc325fb6b54e42f7047dacce3c718c17b" dependencies = [ "cfg-if", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.39", + "syn 1.0.40", ] [[package]] @@ -1361,7 +1199,6 @@ name = "neovide" version = "0.6.0" dependencies = [ "anyhow", - "async-trait", "cargo-husky", "cfg-if", "derive-new", @@ -1374,7 +1211,7 @@ dependencies = [ "log", "lru", "mockall", - "nvim-rs", + "neovim-lib", "parking_lot", "rand", "rmpv", @@ -1383,18 +1220,27 @@ dependencies = [ "skia-safe", "skribo", "skulpin", - "tokio", "unicode-segmentation", "which 4.0.2", "winapi 0.3.9", "winres", ] +[[package]] +name = "neovim-lib" +version = "0.6.0" +source = "git+https://github.com/kethku/neovim-lib#3a89df15c788fd0a3b28e5e15c25da88e5cdda2d" +dependencies = [ + "log", + "rmpv", + "unix_socket", +] + [[package]] name = "net2" -version = "0.2.34" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" dependencies = [ "cfg-if", "libc", @@ -1509,23 +1355,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.39", -] - -[[package]] -name = "nvim-rs" -version = "0.1.1-alpha.0" -source = "git+https://github.com/kethku/nvim-rs#109feea9e345fcbb2674384b0d6914ba4b8fc61e" -dependencies = [ - "async-trait", - "futures 0.3.5", - "log", - "pin-project", - "rmp", - "rmpv", - "tokio", + "syn 1.0.40", ] [[package]] @@ -1547,12 +1379,6 @@ dependencies = [ "cc", ] -[[package]] -name = "once_cell" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" - [[package]] name = "openssl-probe" version = "0.1.2" @@ -1636,38 +1462,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -[[package]] -name = "pin-project" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca4433fff2ae79342e497d9f8ee990d174071408f28f726d6d83af93e58e48aa" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0e815c3ee9a031fdf5af21c10aa17c573c9c6a566328d99e3936c34e36461f" -dependencies = [ - "proc-macro2 1.0.19", - "quote 1.0.7", - "syn 1.0.39", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - [[package]] name = "pkg-config" version = "0.3.18" @@ -1736,12 +1530,6 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" -[[package]] -name = "proc-macro-nested" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" - [[package]] name = "proc-macro2" version = "0.4.30" @@ -1753,9 +1541,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.19" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c" dependencies = [ "unicode-xid 0.2.1", ] @@ -1781,7 +1569,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", ] [[package]] @@ -1867,9 +1655,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_users" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ "getrandom", "redox_syscall", @@ -1912,13 +1700,15 @@ checksum = "ee358f3c4be83ab373cd3e501dc04881034f1ae198e73b2d9edd617653ac4293" dependencies = [ "num-traits", "rmp", + "serde", + "serde_bytes", ] [[package]] name = "rust-argon2" -version = "0.7.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" dependencies = [ "base64", "blake2b_simd", @@ -1945,7 +1735,7 @@ checksum = "7903c2cf599db8f310b392332f38367ca4acc84420fa1aee3536299f433c10d5" dependencies = [ "quote 1.0.7", "rust-embed-utils", - "syn 1.0.39", + "syn 1.0.40", "walkdir", ] @@ -2044,9 +1834,9 @@ dependencies = [ [[package]] name = "sdl2-sys" -version = "0.34.2" +version = "0.34.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed17d6d46b62b7df12134513bcc4f071268963e8c9bc8bf7ad983fbfb2bc3cc" +checksum = "28d81feded049b9c14eceb4a4f6d596a98cebbd59abdba949c5552a015466d33" dependencies = [ "cfg-if", "cmake", @@ -2074,9 +1864,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5" +checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" + +[[package]] +name = "serde_bytes" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" +dependencies = [ + "serde", +] [[package]] name = "serde_json" @@ -2091,9 +1890,9 @@ dependencies = [ [[package]] name = "servo-fontconfig" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a088f8d775a5c5314aae09bd77340bc9c67d72b9a45258be34c83548b4814cd9" +checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c" dependencies = [ "libc", "servo-fontconfig-sys", @@ -2101,22 +1900,12 @@ dependencies = [ [[package]] name = "servo-fontconfig-sys" -version = "4.0.9" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b3e166450f523f4db06c14f02a2d39e76d49b5d8cbd224338d93e3595c156c" +checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" dependencies = [ "expat-sys", - "pkg-config", - "servo-freetype-sys", -] - -[[package]] -name = "servo-freetype-sys" -version = "4.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4ccb6d0d32d277d3ef7dea86203d8210945eb7a45fba89dd445b3595dd0dfc" -dependencies = [ - "cmake", + "freetype-sys", "pkg-config", ] @@ -2126,16 +1915,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" -[[package]] -name = "signal-hook-registry" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035" -dependencies = [ - "arc-swap", - "libc", -] - [[package]] name = "skia-bindings" version = "0.32.1" @@ -2167,7 +1946,7 @@ dependencies = [ [[package]] name = "skribo" version = "0.1.0" -source = "git+https://github.com/linebender/skribo#6a8d5b75c8cb6a2978974b32f1b2dcd29ce2d43a" +source = "git+https://github.com/linebender/skribo#a35c876b9297f23b854b082b71b6a275b26cc18d" dependencies = [ "font-kit", "harfbuzz", @@ -2179,8 +1958,8 @@ dependencies = [ [[package]] name = "skulpin" -version = "0.9.5" -source = "git+https://github.com/aclysma/skulpin#f9b56db5632f10679317c3ec4e04d6985d6a63a6" +version = "0.10.0" +source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" dependencies = [ "log", "skulpin-app-winit", @@ -2191,8 +1970,8 @@ dependencies = [ [[package]] name = "skulpin-app-winit" -version = "0.3.0" -source = "git+https://github.com/aclysma/skulpin#f9b56db5632f10679317c3ec4e04d6985d6a63a6" +version = "0.4.0" +source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" dependencies = [ "log", "skulpin-renderer", @@ -2201,8 +1980,8 @@ dependencies = [ [[package]] name = "skulpin-renderer" -version = "0.3.1" -source = "git+https://github.com/aclysma/skulpin#f9b56db5632f10679317c3ec4e04d6985d6a63a6" +version = "0.4.0" +source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" dependencies = [ "ash", "log", @@ -2212,8 +1991,8 @@ dependencies = [ [[package]] name = "skulpin-renderer-sdl2" -version = "0.3.3" -source = "git+https://github.com/aclysma/skulpin#f9b56db5632f10679317c3ec4e04d6985d6a63a6" +version = "0.4.0" +source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" dependencies = [ "log", "sdl2", @@ -2222,8 +2001,8 @@ dependencies = [ [[package]] name = "skulpin-renderer-winit" -version = "0.3.1" -source = "git+https://github.com/aclysma/skulpin#f9b56db5632f10679317c3ec4e04d6985d6a63a6" +version = "0.4.0" +source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" dependencies = [ "cocoa", "log", @@ -2265,9 +2044,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.3.12" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" dependencies = [ "cfg-if", "libc", @@ -2303,20 +2082,20 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891d8d6567fe7c7f8835a3a98af4208f3846fba258c1bc3c31d6e506239f11f9" +checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", "unicode-xid 0.2.1", ] [[package]] name = "tar" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8a4c1d0bee3230179544336c15eefb563cf0302955d962e456542323e8c2e8a" +checksum = "489997b7557e9a43e192c527face4feacc78bfbe6eed67fd55c4c9e381cba290" dependencies = [ "filetime", "libc", @@ -2357,9 +2136,9 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.39", + "syn 1.0.40", ] [[package]] @@ -2385,11 +2164,12 @@ dependencies = [ [[package]] name = "time" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", + "wasi 0.10.0+wasi-snapshot-preview1", "winapi 0.3.9", ] @@ -2399,51 +2179,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" -[[package]] -name = "tokio" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" -dependencies = [ - "bytes 0.5.6", - "fnv", - "iovec", - "lazy_static", - "libc", - "memchr", - "mio", - "mio-named-pipes", - "mio-uds", - "num_cpus", - "pin-project-lite", - "signal-hook-registry", - "slab", - "tokio-macros", - "winapi 0.3.9", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", -] - -[[package]] -name = "tokio-macros" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" -dependencies = [ - "proc-macro2 1.0.19", - "quote 1.0.7", - "syn 1.0.39", -] - [[package]] name = "toml" version = "0.5.6" @@ -2503,6 +2238,16 @@ dependencies = [ "regex", ] +[[package]] +name = "unix_socket" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aa2700417c405c38f5e6902d699345241c28c0b7ade4abaad71e35a87eb1564" +dependencies = [ + "cfg-if", + "libc", +] + [[package]] name = "vcpkg" version = "0.2.10" @@ -2550,6 +2295,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wayland-client" version = "0.23.6" diff --git a/Cargo.toml b/Cargo.toml index b1edef7..216d3ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ embed-fonts = [] [dependencies] euclid = "0.20.7" -font-kit = "0.6.0" +font-kit = "0.10.0" skribo = { git = "https://github.com/linebender/skribo" } lru = "0.4.3" skulpin = { git = "https://github.com/aclysma/skulpin", branch = "master", features = ["skulpin_sdl2"] } @@ -20,9 +20,7 @@ derive-new = "0.5" rmpv = "0.4.4" rust-embed = { version = "5.2.0", features = ["debug-embed"] } image = "0.22.3" -nvim-rs = { git = "https://github.com/kethku/nvim-rs", features = [ "use_tokio" ] } -tokio = { version = "0.2.9", features = [ "blocking", "process", "time" ] } -async-trait = "0.1.18" +neovim-lib = { git = "https://github.com/kethku/neovim-lib" } lazy_static = "1.4.0" unicode-segmentation = "1.6.0" log = "0.4.8" diff --git a/src/bridge/mod.rs b/src/bridge/mod.rs index 02a5f4f..3926f83 100644 --- a/src/bridge/mod.rs +++ b/src/bridge/mod.rs @@ -2,29 +2,27 @@ pub mod layouts; mod events; -mod handler; mod ui_commands; -use std::process::Stdio; +use std::process::{Stdio, Command}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use std::sync::mpsc::Sender; +use std::sync::mpsc::{Sender, Receiver}; use std::env; use std::path::Path; use std::thread; +#[cfg(windows)] +use std::os::windows::process::CommandExt; + use log::{error, info, warn}; -use nvim_rs::{create::tokio as create, UiAttachOptions}; +use neovim_lib::{Neovim, NeovimApi, Session, UiAttachOptions}; use rmpv::Value; -use tokio::runtime::Runtime; -use tokio::process::Command; -use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use crate::error_handling::ResultPanicExplanation; use crate::settings::*; use crate::window::window_geometry_or_default; pub use events::*; -use handler::NeovimHandler; pub use layouts::*; pub use ui_commands::UiCommand; @@ -110,147 +108,155 @@ pub fn create_nvim_command() -> Command { cmd } -async fn start_process(ui_command_sender: UnboundedSender, mut ui_command_receiver: UnboundedReceiver, redraw_event_sender: Sender, running: Arc) { - let (width, height) = window_geometry_or_default(); - let (mut nvim, io_handler, _) = - create::new_child_cmd(&mut create_nvim_command(), NeovimHandler::new(ui_command_sender, redraw_event_sender)) - .await - .unwrap_or_explained_panic("Could not locate or start the neovim process"); - - let close_watcher_running = running.clone(); - tokio::spawn(async move { - info!("Close watcher started"); - match io_handler.await { - Err(join_error) => error!("Error joining IO loop: '{}'", join_error), - Ok(Err(error)) => { - if !error.is_channel_closed() { - error!("Error: '{}'", error); - } - } - Ok(Ok(())) => {} - }; - close_watcher_running.store(false, Ordering::Relaxed); - }); +pub fn start_bridge(ui_command_sender: Sender, ui_command_receiver: Receiver, redraw_event_sender: Sender, running: Arc) { + thread::spawn(move || { + let (width, height) = window_geometry_or_default(); + let mut session = Session::new_child_cmd(&mut create_nvim_command()).unwrap_or_explained_panic("Could not locate or start neovim process"); + let notification_receiver = session.start_event_loop_channel(); + + let mut nvim = Neovim::new(session); - if let Ok(Value::Integer(correct_version)) = nvim.eval("has(\"nvim-0.4\")").await { - if correct_version.as_i64() != Some(1) { + if let Ok(Value::Integer(correct_version)) = nvim.eval("has(\"nvim-0.4\")") { + if correct_version.as_i64() != Some(1) { + error!("Neovide requires version 0.4 or higher"); + std::process::exit(0); + } + } else { error!("Neovide requires version 0.4 or higher"); std::process::exit(0); + }; + + nvim.set_var("neovide", Value::Boolean(true)).unwrap_or_explained_panic("Could not communicate with neovim process"); + if let Err(command_error) = nvim.command("runtime! ginit.vim") { + nvim.command(&format!( + "echomsg \"error encountered in ginit.vim {:?}\"", + command_error + )) + .ok(); } - } else { - error!("Neovide requires version 0.4 or higher"); - std::process::exit(0); - }; - nvim.set_var("neovide", Value::Boolean(true)) - .await - .unwrap_or_explained_panic("Could not communicate with neovim process"); - let mut options = UiAttachOptions::new(); - options.set_linegrid_external(true); - options.set_multigrid_external(true); - options.set_rgb(true); - if let Err(command_error) = nvim.command("runtime! ginit.vim").await { - nvim.command(&format!( - "echomsg \"error encountered in ginit.vim {:?}\"", - command_error - )) - .await + nvim.set_client_info( + "neovide", + vec![ + (Value::from("major"), Value::from(0u64)), + (Value::from("minor"), Value::from(6u64)), + ], + "ui", + vec![], + vec![], + ) .ok(); - } - nvim.set_client_info( - "neovide", - vec![ - (Value::from("major"), Value::from(0u64)), - (Value::from("minor"), Value::from(6u64)), - ], - "ui", - vec![], - vec![], - ) - .await - .ok(); - - let neovide_channel: u64 = nvim - .list_chans() - .await - .ok() - .and_then(|channel_values| parse_channel_list(channel_values).ok()) - .and_then(|channel_list| { - channel_list.iter().find_map(|channel| match channel { - ChannelInfo { - id, - client: Some(ClientInfo { name, .. }), - .. - } if name == "neovide" => Some(*id), - _ => None, + let neovide_channel: u64 = nvim + .list_chans() + .ok() + .and_then(|channel_values| parse_channel_list(channel_values).ok()) + .and_then(|channel_list| { + channel_list.iter().find_map(|channel| match channel { + ChannelInfo { + id, + client: Some(ClientInfo { name, .. }), + .. + } if name == "neovide" => Some(*id), + _ => None, + }) }) - }) - .unwrap_or(0); + .unwrap_or(0); - info!( - "Neovide registered to nvim with channel id {}", - neovide_channel - ); + info!( + "Neovide registered to nvim with channel id {}", + neovide_channel + ); - #[cfg(windows)] - nvim.command(&build_neovide_command( - neovide_channel, - 0, - "NeovideRegisterRightClick", - "register_right_click", - )) - .await - .ok(); + #[cfg(windows)] + nvim.command(&build_neovide_command( + neovide_channel, + 0, + "NeovideRegisterRightClick", + "register_right_click", + )) + .ok(); - #[cfg(windows)] - nvim.command(&build_neovide_command( - neovide_channel, - 0, - "NeovideUnregisterRightClick", - "unregister_right_click", - )) - .await - .ok(); - - nvim.ui_attach(width as i64, height as i64, &options) - .await - .unwrap_or_explained_panic("Could not attach ui to neovim process"); - info!("Neovim process attached"); - - let nvim = Arc::new(nvim); - let input_nvim = nvim.clone(); - - let ui_command_processor_running = running.clone(); - tokio::spawn(async move { - info!("UiCommand processor started"); - while let Some(ui_command) = ui_command_receiver.recv().await { - if !ui_command_processor_running.load(Ordering::Relaxed) { - return; - } + #[cfg(windows)] + nvim.command(&build_neovide_command( + neovide_channel, + 0, + "NeovideUnregisterRightClick", + "unregister_right_click", + )) + .ok(); - ui_command.execute(&input_nvim).await; - } - }); + NeovimApi::set_option(&mut nvim, "lazyredraw", Value::Boolean(false)).ok(); - SETTINGS.read_initial_values(&nvim).await; - SETTINGS.setup_changed_listeners(&nvim).await; + let mut options = UiAttachOptions::new(); + options.set_linegrid_external(true); + options.set_multigrid_external(true); + options.set_rgb(true); + nvim.ui_attach(width as i64, height as i64, &options) + .unwrap_or_explained_panic("Could not attach ui to neovim process"); + info!("Neovim process attached"); - nvim.set_option("lazyredraw", Value::Boolean(false)) - .await - .ok(); -} + SETTINGS.read_initial_values(&mut nvim); + SETTINGS.setup_changed_listeners(&mut nvim); -pub fn start_bridge(ui_command_sender: UnboundedSender, ui_command_receiver: UnboundedReceiver, redraw_event_sender: Sender, running: Arc) { - thread::spawn(move || { - let runtime = Runtime::new().unwrap(); + let notification_running = running.clone(); + thread::spawn(move || { + loop { + if !notification_running.load(Ordering::Relaxed) { + break; + } - let running_clone = running.clone(); - runtime.spawn(async move { - start_process(ui_command_sender, ui_command_receiver, redraw_event_sender, running_clone).await; + match notification_receiver.recv() { + Ok((event_name, arguments)) => + match event_name.as_ref() { + "redraw" => { + for events in arguments { + let parsed_events = parse_redraw_event(events) + .unwrap_or_explained_panic("Could not parse event from neovim"); + + for parsed_event in parsed_events { + redraw_event_sender.send(parsed_event).ok(); + } + } + } + "setting_changed" => { + SETTINGS.handle_changed_notification(arguments); + } + #[cfg(windows)] + "neovide.register_right_click" => { + ui_command_sender.send(UiCommand::RegisterRightClick).ok(); + } + #[cfg(windows)] + "neovide.unregister_right_click" => { + ui_command_sender.send(UiCommand::UnregisterRightClick).ok(); + } + _ => {} + }, + Err(error) => { + notification_running.store(false, Ordering::Relaxed); + break; + } + } + } }); - while running.load(Ordering::Relaxed) { - } + let ui_command_running = running.clone(); + thread::spawn(move || { + loop { + if !ui_command_running.load(Ordering::Relaxed) { + break; + } + + match ui_command_receiver.recv() { + Ok(ui_command) => { + ui_command.execute(&mut nvim); + }, + Err(error) => { + ui_command_running.store(false, Ordering::Relaxed); + break; + } + } + } + }); }); } diff --git a/src/bridge/ui_commands.rs b/src/bridge/ui_commands.rs index 539a8b5..3564e00 100644 --- a/src/bridge/ui_commands.rs +++ b/src/bridge/ui_commands.rs @@ -1,7 +1,5 @@ use log::{error, trace}; -use nvim_rs::compat::tokio::Compat; -use nvim_rs::Neovim; -use tokio::process::ChildStdin; +use neovim_lib::{Neovim, NeovimApi}; #[cfg(windows)] use crate::settings::windows_registry::{ @@ -40,15 +38,14 @@ pub enum UiCommand { } impl UiCommand { - pub async fn execute(self, nvim: &Neovim>) { + pub fn execute(self, nvim: &mut Neovim) { match self { UiCommand::Resize { width, height } => nvim .ui_try_resize(width.max(10) as i64, height.max(3) as i64) - .await .expect("Resize failed"), UiCommand::Keyboard(input_command) => { trace!("Keyboard Input Sent: {}", input_command); - nvim.input(&input_command).await.expect("Input failed"); + nvim.input(&input_command).expect("Input failed"); } UiCommand::MouseButton { action, @@ -56,7 +53,6 @@ impl UiCommand { position: (grid_x, grid_y), } => { nvim.input_mouse("left", &action, "", grid_id as i64, grid_y as i64, grid_x as i64) - .await .expect("Mouse Input Failed"); } UiCommand::Scroll { @@ -65,7 +61,6 @@ impl UiCommand { position: (grid_x, grid_y), } => { nvim.input_mouse("wheel", &direction, "", grid_id as i64, grid_y as i64, grid_x as i64) - .await .expect("Mouse Scroll Failed"); } UiCommand::Drag { @@ -73,38 +68,35 @@ impl UiCommand { position: (grid_x, grid_y) } => { nvim.input_mouse("left", "drag", "", grid_id as i64, grid_y as i64, grid_x as i64) - .await .expect("Mouse Drag Failed"); } UiCommand::FocusLost => nvim .command("if exists('#FocusLost') | doautocmd FocusLost | endif") - .await .expect("Focus Lost Failed"), UiCommand::FocusGained => nvim .command("if exists('#FocusGained') | doautocmd FocusGained | endif") - .await .expect("Focus Gained Failed"), UiCommand::Quit => { - nvim.command("qa!").await.ok(); // Ignoring result as it won't succeed since the app closed. + nvim.command("qa!").ok(); // Ignoring result as it won't succeed since the app closed. } UiCommand::FileDrop(path) => { - nvim.command(format!("e {}", path).as_str()).await.ok(); + nvim.command(format!("e {}", path).as_str()).ok(); } #[cfg(windows)] UiCommand::RegisterRightClick => { if unregister_rightclick() { let msg = "Could not unregister previous menu item. Possibly already registered or not running as Admin?"; - nvim.err_writeln(msg).await.ok(); + nvim.err_writeln(msg).ok(); error!("{}", msg); } if !register_rightclick_directory() { let msg = "Could not register directory context menu item. Possibly already registered or not running as Admin?"; - nvim.err_writeln(msg).await.ok(); + nvim.err_writeln(msg).ok(); error!("{}", msg); } if !register_rightclick_file() { let msg = "Could not register file context menu item. Possibly already registered or not running as Admin?"; - nvim.err_writeln(msg).await.ok(); + nvim.err_writeln(msg).ok(); error!("{}", msg); } } @@ -112,7 +104,7 @@ impl UiCommand { UiCommand::UnregisterRightClick => { if !unregister_rightclick() { let msg = "Could not remove context menu items. Possibly already removed or not running as Admin?"; - nvim.err_writeln(msg).await.ok(); + nvim.err_writeln(msg).ok(); error!("{}", msg); } } diff --git a/src/main.rs b/src/main.rs index e96bca7..136eb86 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,8 +23,6 @@ use std::sync::atomic::AtomicBool; use std::sync::mpsc::channel; use std::process; -use tokio::sync::mpsc::unbounded_channel; - use window::window_geometry; use bridge::start_bridge; @@ -135,7 +133,7 @@ fn main() { let (redraw_event_sender, redraw_event_receiver) = channel(); let (draw_command_sender, draw_command_receiver) = channel(); - let (ui_command_sender, ui_command_receiver) = unbounded_channel(); + let (ui_command_sender, ui_command_receiver) = channel(); start_bridge(ui_command_sender.clone(), ui_command_receiver, redraw_event_sender, running.clone()); start_editor(redraw_event_receiver, draw_command_sender); diff --git a/src/settings/mod.rs b/src/settings/mod.rs index c1bf928..3ab09c2 100644 --- a/src/settings/mod.rs +++ b/src/settings/mod.rs @@ -5,16 +5,13 @@ use std::convert::TryInto; #[cfg(not(test))] use flexi_logger::{Cleanup, Criterion, Duplicate, Logger, Naming}; use log::warn; -use nvim_rs::compat::tokio::Compat; -use nvim_rs::Neovim; +use neovim_lib::{Neovim, NeovimApi}; use parking_lot::RwLock; pub use rmpv::Value; mod from_value; pub use from_value::FromValue; pub mod windows_registry; -use tokio::process::ChildStdin; - use crate::error_handling::ResultPanicExplanation; lazy_static! { @@ -141,25 +138,25 @@ impl Settings { (*value).clone() } - pub async fn read_initial_values(&self, nvim: &Neovim>) { + pub fn read_initial_values(&self, nvim: &mut Neovim) { let keys: Vec = self.listeners.read().keys().cloned().collect(); for name in keys { let variable_name = format!("neovide_{}", name.to_string()); - match nvim.get_var(&variable_name).await { + match nvim.get_var(&variable_name) { Ok(value) => { self.listeners.read().get(&name).unwrap()(value); } Err(error) => { warn!("Initial value load failed for {}: {}", name, error); let setting = self.readers.read().get(&name).unwrap()(); - nvim.set_var(&variable_name, setting).await.ok(); + nvim.set_var(&variable_name, setting).ok(); } } } } - pub async fn setup_changed_listeners(&self, nvim: &Neovim>) { + pub fn setup_changed_listeners(&self, nvim: &mut Neovim) { let keys: Vec = self.listeners.read().keys().cloned().collect(); for name in keys { @@ -174,7 +171,6 @@ impl Settings { name ); nvim.command(&vimscript) - .await .unwrap_or_explained_panic(&format!( "Could not setup setting notifier for {}", name diff --git a/src/window.rs b/src/window.rs index 6e932d1..5b7c565 100644 --- a/src/window.rs +++ b/src/window.rs @@ -2,7 +2,7 @@ use std::thread::sleep; use std::time::{Duration, Instant}; use std::sync::Arc; use std::sync::atomic::{Ordering, AtomicBool}; -use std::sync::mpsc::Receiver; +use std::sync::mpsc::{Sender, Receiver}; use log::{debug, error, info, trace}; use skulpin::sdl2; @@ -15,7 +15,6 @@ use skulpin::{ CoordinateSystem, LogicalSize, PhysicalSize, PresentMode, Renderer as SkulpinRenderer, RendererBuilder, Sdl2Window, Window, }; -use tokio::sync::mpsc::UnboundedSender; use crate::editor::DrawCommand; use crate::bridge::{produce_neovim_keybinding_string, UiCommand}; @@ -38,7 +37,7 @@ fn windows_fix_dpi() { } } -fn handle_new_grid_size(new_size: LogicalSize, renderer: &Renderer, ui_command_sender: &UnboundedSender) { +fn handle_new_grid_size(new_size: LogicalSize, renderer: &Renderer, ui_command_sender: &Sender) { if new_size.width > 0 && new_size.height > 0 { let new_width = ((new_size.width + 1) as f32 / renderer.font_width) as u32; let new_height = ((new_size.height + 1) as f32 / renderer.font_height) as u32; @@ -65,7 +64,7 @@ struct WindowWrapper { fullscreen: bool, cached_size: (u32, u32), cached_position: (i32, i32), - ui_command_sender: UnboundedSender, + ui_command_sender: Sender, running: Arc } @@ -112,7 +111,7 @@ pub fn window_geometry_or_default() -> (u64, u64) { } impl WindowWrapper { - pub fn new(ui_command_sender: UnboundedSender, running: Arc) -> WindowWrapper { + pub fn new(ui_command_sender: Sender, running: Arc) -> WindowWrapper { let context = sdl2::init().expect("Failed to initialize sdl2"); let video_subsystem = context .video() @@ -436,7 +435,7 @@ pub fn initialize_settings() { register_nvim_setting!("fullscreen", WindowSettings::fullscreen); } -pub fn start_window(draw_command_receiver: Receiver, ui_command_sender: UnboundedSender, running: Arc) { +pub fn start_window(draw_command_receiver: Receiver, ui_command_sender: Sender, running: Arc) { let mut window = WindowWrapper::new(ui_command_sender.clone(), running.clone()); info!("Starting window event loop");