diff --git a/Cargo.lock b/Cargo.lock index e262f0813e7c..ba8a308c32d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "0.7.18" @@ -23,18 +38,79 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e906254e445520903e7fc9da4f709886c84ae4bc4ddaf0e093188d66df4dc820" +[[package]] +name = "async-trait" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "bstr" version = "0.2.16" @@ -50,6 +126,72 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +[[package]] +name = "cap-fs-ext" +version = "0.13.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff3a1e32332db9ad29d6da34693ce9a7ac26a9edf96abb5c1788d193410031ab" +dependencies = [ + "cap-primitives", + "cap-std", + "rustc_version 0.3.3", + "unsafe-io", + "winapi", +] + +[[package]] +name = "cap-primitives" +version = "0.13.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d253b74de50b097594462618e7dd17b93b3e3bef19f32d2e512996f9095661f" +dependencies = [ + "errno", + "fs-set-times", + "ipnet", + "libc", + "maybe-owned", + "once_cell", + "posish", + "rustc_version 0.3.3", + "unsafe-io", + "winapi", + "winapi-util", + "winx", +] + +[[package]] +name = "cap-rand" +version = "0.13.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "458e98ed00e4276d0ac60da888d80957a177dfa7efa8dbb3be59f1e2b0e02ae5" +dependencies = [ + "rand", +] + +[[package]] +name = "cap-std" +version = "0.13.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7019d48ea53c5f378e0fdab0fe5f627fc00e76d65e75dffd6fb1cbc0c9b382ee" +dependencies = [ + "cap-primitives", + "posish", + "rustc_version 0.3.3", + "unsafe-io", +] + +[[package]] +name = "cap-time-ext" +version = "0.13.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90585adeada7f804e6dcf71b8ff74217ad8742188fc870b9da5deab4722baa04" +dependencies = [ + "cap-primitives", + "once_cell", + "posish", + "winx", +] + [[package]] name = "cassowary" version = "0.3.0" @@ -61,6 +203,9 @@ name = "cc" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +dependencies = [ + "jobserver", +] [[package]] name = "cfg-if" @@ -108,6 +253,161 @@ dependencies = [ "winapi", ] +[[package]] +name = "cpp_demangle" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea47428dc9d2237f3c6bc134472edfd63ebba0af932e783506dcfd66f10d18a" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-bforest" +version = "0.75.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3f8dd4f920a422c96c53fb6a91cc7932b865fdb60066ae9df7c329342d303f" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.75.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe85f9a8dbf3c9dfa47ecb89828a7dc17c0b62015b84b5505fd4beba61c542c" +dependencies = [ + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli", + "log", + "regalloc", + "serde", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.75.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12bc4be68da214a56bf9beea4212eb3b9eac16ca9f0b47762f907c4cd4684073" +dependencies = [ + "cranelift-codegen-shared", + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.75.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c87b69923825cfbc3efde17d929a68cd5b50a4016b2bd0eb8c3933cc5bd8cd" +dependencies = [ + "serde", +] + +[[package]] +name = "cranelift-entity" +version = "0.75.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe683e7ec6e627facf44b2eab4b263507be4e7ef7ea06eb8cee5283d9b45370e" +dependencies = [ + "serde", +] + +[[package]] +name = "cranelift-frontend" +version = "0.75.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da80025ca214f0118273f8b94c4790add3b776f0dc97afba6b711757497743b" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-native" +version = "0.75.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1c0e8c56f9a63f352a64aaa9c9eef7c205008b03593af7b128a3fbc46eae7e9" +dependencies = [ + "cranelift-codegen", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.75.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d10ddafc5f1230d2190eb55018fcdecfcce728c9c2b975f2690ef13691d18eb5" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "serde", + "smallvec", + "thiserror", + "wasmparser", +] + +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + [[package]] name = "crossbeam-utils" version = "0.8.5" @@ -144,6 +444,25 @@ dependencies = [ "winapi", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + [[package]] name = "dirs-next" version = "2.0.0" @@ -180,6 +499,40 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +dependencies = [ + "gcc", + "libc", +] + [[package]] name = "error-code" version = "2.3.0" @@ -201,6 +554,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "fern" version = "0.6.0" @@ -210,6 +569,16 @@ dependencies = [ "log", ] +[[package]] +name = "file-per-thread-logger" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fdbe0d94371f9ce939b555dd342d0686cc4c0cadbcd4b61d70af5ff97eb4126" +dependencies = [ + "env_logger", + "log", +] + [[package]] name = "fnv" version = "1.0.7" @@ -226,6 +595,17 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs-set-times" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28f1ca01f517bba5770c067dc6c466d290b962e08214c8f2598db98d66087e55" +dependencies = [ + "posish", + "unsafe-io", + "winapi", +] + [[package]] name = "futf" version = "0.1.4" @@ -282,6 +662,22 @@ dependencies = [ "thread_local", ] +[[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.3" @@ -293,6 +689,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "globset" version = "0.4.8" @@ -306,6 +713,21 @@ dependencies = [ "regex", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "helix-core" version = "0.3.0" @@ -348,14 +770,26 @@ dependencies = [ ] [[package]] -name = "helix-syntax" -version = "0.3.0" +name = "helix-plugin" +version = "0.1.0" dependencies = [ "anyhow", - "cc", - "libloading", - "threadpool", - "tree-sitter", + "futures-util", + "tokio", + "tokio-macros", + "wasmtime", + "wasmtime-wasi", +] + +[[package]] +name = "helix-syntax" +version = "0.3.0" +dependencies = [ + "anyhow", + "cc", + "libloading", + "threadpool", + "tree-sitter", ] [[package]] @@ -429,6 +863,15 @@ dependencies = [ "libc", ] +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + [[package]] name = "idna" version = "0.2.3" @@ -458,6 +901,17 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", + "serde", +] + [[package]] name = "instant" version = "0.1.9" @@ -467,12 +921,47 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "io-lifetimes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "609c23089c52d7edcf39d6cfd2cf581dcea7e059f80f1d91130887dceac77c1f" +dependencies = [ + "libc", + "rustc_version 0.4.0", + "winapi", +] + +[[package]] +name = "ipnet" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" + +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +[[package]] +name = "jobserver" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" +dependencies = [ + "libc", +] + [[package]] name = "jsonrpc-core" version = "17.1.0" @@ -492,6 +981,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" + [[package]] name = "libc" version = "0.2.97" @@ -545,18 +1040,52 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "matches" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +[[package]] +name = "maybe-owned" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" + [[package]] name = "memchr" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "mio" version = "0.7.13" @@ -579,6 +1108,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "more-asserts" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" + [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -623,12 +1158,29 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7" +dependencies = [ + "crc32fast", + "indexmap", + "memchr", +] + [[package]] name = "once_cell" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "parking_lot" version = "0.11.1" @@ -654,12 +1206,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + [[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "pin-project-lite" version = "0.2.6" @@ -672,6 +1239,26 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "posish" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89cfd94d463bd7f94d4dc43af1117881afdc654d389a1917b41fc0326e3b0806" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "errno", + "itoa", + "libc", + "unsafe-io", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + [[package]] name = "proc-macro2" version = "1.0.27" @@ -681,6 +1268,15 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "psm" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21ff0279b4a85e576b97e4a21d13e437ebcd56612706cde5d3f0d5c9399490c0" +dependencies = [ + "cc", +] + [[package]] name = "pulldown-cmark" version = "0.8.0" @@ -692,6 +1288,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quickcheck" version = "1.0.3" @@ -716,6 +1318,19 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" dependencies = [ + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", "rand_core", ] @@ -728,6 +1343,40 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + [[package]] name = "redox_syscall" version = "0.2.9" @@ -747,6 +1396,18 @@ dependencies = [ "redox_syscall", ] +[[package]] +name = "regalloc" +version = "0.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" +dependencies = [ + "log", + "rustc-hash", + "serde", + "smallvec", +] + [[package]] name = "regex" version = "1.5.4" @@ -764,6 +1425,18 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +[[package]] +name = "region" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +dependencies = [ + "bitflags", + "libc", + "mach", + "winapi", +] + [[package]] name = "ropey" version = "1.3.1" @@ -806,6 +1479,36 @@ dependencies = [ "walkdir", ] +[[package]] +name = "rustc-demangle" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.3", +] + [[package]] name = "ryu" version = "1.0.5" @@ -827,6 +1530,50 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scroll" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f3aac57ee7f3272d8395c6e4f502f434f0e289fcd62876f70daa008c20dcabe" + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" version = "1.0.126" @@ -869,6 +1616,28 @@ dependencies = [ "syn", ] +[[package]] +name = "sha2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +dependencies = [ + "block-buffer", + "cfg-if 1.0.0", + "cpufeatures", + "digest", + "opaque-debug", +] + +[[package]] +name = "shellexpand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83bdb7831b2d85ddf4a7b148aa19d0587eddbe8671a436b7bd1182eaad0f2829" +dependencies = [ + "dirs-next", +] + [[package]] name = "signal-hook" version = "0.3.9" @@ -926,6 +1695,12 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "str-buf" version = "1.0.5" @@ -943,6 +1718,29 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-interface" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef194146527a71113b76650b19c509b6537aa20b91f6702f1933e7b96b347736" +dependencies = [ + "atty", + "bitflags", + "cap-fs-ext", + "cap-std", + "posish", + "rustc_version 0.4.0", + "unsafe-io", + "winapi", + "winx", +] + +[[package]] +name = "target-lexicon" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834" + [[package]] name = "tendril" version = "0.4.2" @@ -954,6 +1752,15 @@ dependencies = [ "utf-8", ] +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.26" @@ -1029,9 +1836,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" +checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110" dependencies = [ "proc-macro2", "quote", @@ -1058,6 +1865,39 @@ dependencies = [ "serde", ] +[[package]] +name = "tracing" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +dependencies = [ + "cfg-if 1.0.0", + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +dependencies = [ + "lazy_static", +] + [[package]] name = "tree-sitter" version = "0.19.5" @@ -1068,6 +1908,18 @@ dependencies = [ "regex", ] +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicase" version = "2.6.0" @@ -1119,6 +1971,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +[[package]] +name = "unsafe-io" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1598c579f79cdd11e677b3942b7bed5cb3369464cfd240f4c4a308ffaed6f5e4" +dependencies = [ + "io-lifetimes", + "rustc_version 0.3.3", + "winapi", +] + [[package]] name = "url" version = "2.2.2" @@ -1161,6 +2024,324 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasi-cap-std-sync" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ed414ed6ff3b95653ea07b237cf03c513015d94169aac159755e05a2eaa80f" +dependencies = [ + "anyhow", + "async-trait", + "bitflags", + "cap-fs-ext", + "cap-rand", + "cap-std", + "cap-time-ext", + "fs-set-times", + "lazy_static", + "libc", + "system-interface", + "tracing", + "unsafe-io", + "wasi-common", + "winapi", +] + +[[package]] +name = "wasi-common" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c67b1e49ae6d9bcab37a6f13594aed98d8ab8f5c2117b3bed543d8019688733" +dependencies = [ + "anyhow", + "bitflags", + "cap-rand", + "cap-std", + "libc", + "thiserror", + "tracing", + "wiggle", + "winapi", +] + +[[package]] +name = "wasi-tokio" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dfdfbdc16c6a9fd99655f0990b5a2c1d14fca20b3f6018c2d81d4bdde25a1ba" +dependencies = [ + "anyhow", + "bitflags", + "cap-fs-ext", + "cap-std", + "cap-time-ext", + "fs-set-times", + "lazy_static", + "libc", + "posish", + "system-interface", + "tokio", + "tracing", + "unsafe-io", + "wasi-cap-std-sync", + "wasi-common", + "wiggle", + "winapi", +] + +[[package]] +name = "wasmparser" +version = "0.78.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" + +[[package]] +name = "wasmtime" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56828b11cd743a0e9b4207d1c7a8c1a66cb32d14601df10422072802a6aee86c" +dependencies = [ + "anyhow", + "backtrace", + "bincode", + "cfg-if 1.0.0", + "cpp_demangle", + "indexmap", + "lazy_static", + "libc", + "log", + "paste", + "psm", + "region", + "rustc-demangle", + "serde", + "smallvec", + "target-lexicon", + "wasmparser", + "wasmtime-cache", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit", + "wasmtime-profiling", + "wasmtime-runtime", + "wat", + "winapi", +] + +[[package]] +name = "wasmtime-cache" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99aca6335ad194d795342137a92afaec9338a2bfcf4caa4c667b5ece16c2bfa9" +dependencies = [ + "anyhow", + "base64", + "bincode", + "directories-next", + "errno", + "file-per-thread-logger", + "libc", + "log", + "serde", + "sha2", + "toml", + "winapi", + "zstd", +] + +[[package]] +name = "wasmtime-cranelift" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "519fa80abe29dc46fc43177cbe391e38c8613c59229c8d1d90d7f226c3c7cede" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-wasm", + "target-lexicon", + "wasmparser", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-debug" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ddf6e9bca2f3bc1dd499db2a93d35c735176cff0de7daacdc18c3794f7082e0" +dependencies = [ + "anyhow", + "gimli", + "more-asserts", + "object", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-environ" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a991635b1cf1d1336fbea7a5f2c0e1dafaa54cb21c632d8414885278fa5d1b1" +dependencies = [ + "cfg-if 1.0.0", + "cranelift-codegen", + "cranelift-entity", + "cranelift-wasm", + "gimli", + "indexmap", + "log", + "more-asserts", + "serde", + "thiserror", + "wasmparser", +] + +[[package]] +name = "wasmtime-fiber" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab6bb95303636d1eba6f7fd2b67c1cd583f73303c73b1a3259b46bb1c2eb299" +dependencies = [ + "cc", + "libc", + "winapi", +] + +[[package]] +name = "wasmtime-jit" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33a0ae79b7c8d050156b22e10fdc49dfb09cc482c251d12bf10e8a833498fb" +dependencies = [ + "addr2line", + "anyhow", + "cfg-if 1.0.0", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "more-asserts", + "object", + "rayon", + "region", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-cranelift", + "wasmtime-debug", + "wasmtime-environ", + "wasmtime-obj", + "wasmtime-profiling", + "wasmtime-runtime", + "winapi", +] + +[[package]] +name = "wasmtime-obj" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a879f03d416615f322dcb3aa5cb4cbc47b64b12be6aa235a64ab63a4281d50a" +dependencies = [ + "anyhow", + "more-asserts", + "object", + "target-lexicon", + "wasmtime-debug", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-profiling" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171ae3107e8502667b16d336a1dd03e370aa6630a1ce26559aba572ade1031d1" +dependencies = [ + "anyhow", + "cfg-if 1.0.0", + "gimli", + "lazy_static", + "libc", + "object", + "scroll", + "serde", + "target-lexicon", + "wasmtime-environ", + "wasmtime-runtime", +] + +[[package]] +name = "wasmtime-runtime" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0404e10f8b07f940be42aa4b8785b4ab42e96d7167ccc92e35d36eee040309c2" +dependencies = [ + "anyhow", + "backtrace", + "cc", + "cfg-if 1.0.0", + "indexmap", + "lazy_static", + "libc", + "log", + "mach", + "memoffset", + "more-asserts", + "rand", + "region", + "thiserror", + "wasmtime-environ", + "wasmtime-fiber", + "winapi", +] + +[[package]] +name = "wasmtime-wasi" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39d75f21122ec134c8bfc8840a8742c0d406a65560fb9716b23800bd7cfd6ae5" +dependencies = [ + "anyhow", + "wasi-cap-std-sync", + "wasi-common", + "wasi-tokio", + "wasmtime", + "wiggle", +] + +[[package]] +name = "wast" +version = "35.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" +dependencies = [ + "leb128", +] + +[[package]] +name = "wast" +version = "36.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b5d7ba374a364571da1cb0a379a3dc302582a2d9937a183bfe35b68ad5bb9c4" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16383df7f0e3901484c2dda6294ed6895caa3627ce4f6584141dcf30a33a23e6" +dependencies = [ + "wast 36.0.0", +] + [[package]] name = "which" version = "4.1.0" @@ -1171,6 +2352,50 @@ dependencies = [ "libc", ] +[[package]] +name = "wiggle" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79ca01f1388a549eb3eaa221a072c3cfd3e383618ec6b423e82f2734ee28dd40" +dependencies = [ + "anyhow", + "async-trait", + "bitflags", + "thiserror", + "tracing", + "wasmtime", + "wiggle-macro", + "witx", +] + +[[package]] +name = "wiggle-generate" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "544fd41029c33b179656ab1674cd813db7cd473f38f1976ae6e08effb46dd269" +dependencies = [ + "anyhow", + "heck", + "proc-macro2", + "quote", + "shellexpand", + "syn", + "witx", +] + +[[package]] +name = "wiggle-macro" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e31ae77a274c9800e6f1342fa4a6dde5e2d72eb9d9b2e0418781be6efc35b58" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wiggle-generate", + "witx", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1201,3 +2426,54 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winx" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bdb79e12a5ac98f09e863b99c38c72f942a41f643ae0bb05d4d6d2633481341" +dependencies = [ + "bitflags", + "winapi", +] + +[[package]] +name = "witx" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" +dependencies = [ + "anyhow", + "log", + "thiserror", + "wast 35.0.2", +] + +[[package]] +name = "zstd" +version = "0.6.1+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de55e77f798f205d8561b8fe2ef57abfb6e0ff2abe7fd3c089e119cdb5631a3" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "3.0.1+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1387cabcd938127b30ce78c4bf00b30387dddf704e3f0881dbc4ff62b5566f8c" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "1.4.20+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd5b733d7cf2d9447e2c3e76a5589b4f5e5ae065c22a2bc0b023cbc331b6c8e" +dependencies = [ + "cc", + "libc", +] diff --git a/Cargo.toml b/Cargo.toml index 22d292600486..c522127e212e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "helix-tui", "helix-syntax", "helix-lsp", + "helix-plugin", ] # Build helix-syntax in release mode to make the code path faster in development. diff --git a/helix-plugin/Cargo.toml b/helix-plugin/Cargo.toml new file mode 100644 index 000000000000..cd20839095a4 --- /dev/null +++ b/helix-plugin/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "helix-plugin" +version = "0.1.0" +edition = "2018" + +[dependencies] +wasmtime = "0.28" +wasmtime-wasi = { version = "0.28", features = ["tokio"] } +anyhow = "1" +futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false } + +[dev-dependencies] +tokio-macros = "1.3" +tokio = "1.8" diff --git a/helix-plugin/README.md b/helix-plugin/README.md new file mode 100644 index 000000000000..31cb3775b875 --- /dev/null +++ b/helix-plugin/README.md @@ -0,0 +1,16 @@ +# Helix plugins system MVP + +This is still an early alpha, you should expect frequent breaking changes. +The intend is to take inspiration from [CodeMirror 6](https://codemirror.net/6/docs/ref/). + +Plugins for Helix are written in any language that can be compiled to WASM (Web Assembly). +This implies: +- No language language lock-in, user can use what they're most comfortable with to extend and customize their experience. +- Sandboxing, a plugin can do only what it has been allowed to. +- Portability, .wasm and .wat files are platform agnostic and can be packaged as is for any platform. + +API is described by .witx files and bindings for some languages can be generated by [`witx-bindgen`](https://github.com/bytecodealliance/witx-bindgen). +As of now, `witx-bindgen` is still in prototype stage. + +Host side code is generated with [BLABLA TODO] + diff --git a/helix-plugin/src/lib.rs b/helix-plugin/src/lib.rs new file mode 100644 index 000000000000..614cdcb924f1 --- /dev/null +++ b/helix-plugin/src/lib.rs @@ -0,0 +1,253 @@ +use anyhow::{Context, Result}; +use std::collections::HashMap; +use std::fmt; +use std::path::PathBuf; +use wasmtime_wasi::tokio::WasiCtxBuilder; + +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct PluginName(String); + +impl From<&str> for PluginName { + fn from(name: &str) -> Self { + Self(name.to_owned()) + } +} + +impl From for PluginName { + fn from(name: String) -> Self { + Self(name) + } +} + +impl fmt::Display for PluginName { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) + } +} + +/// Describes a path accessible from sandbox +#[derive(Debug)] +pub enum DirDef { + Mirrored { + path: PathBuf, + }, + Mapped { + host_path: PathBuf, + guest_path: PathBuf, + }, +} + +impl DirDef { + /// Preopens the directory definition for the given WASI context + pub fn preopen(&self, wasi_builder: WasiCtxBuilder) -> Result { + use std::fs::File; + use wasmtime_wasi::Dir; + + let (host_path, guest_path) = match self { + DirDef::Mirrored { path } => (path.as_path(), path.as_path()), + DirDef::Mapped { + host_path, + guest_path, + } => (host_path.as_path(), guest_path.as_path()), + }; + + let host_dir = unsafe { + // SAFETY: user is deciding for himself folders that should be accessibles + Dir::from_std_file(File::open(host_path)?) + }; + + wasi_builder.preopened_dir(host_dir, guest_path) + } +} + +pub struct HelixCtx { + wasi: wasmtime_wasi::WasiCtx, +} + +pub type HelixStore = wasmtime::Store; + +pub struct PluginDef { + pub name: PluginName, + pub path: PathBuf, + pub dependencies: Vec, +} + +pub struct Plugin { + instance: wasmtime::Instance, +} + +impl Plugin { + pub fn get_typed_func( + &self, + store: &mut HelixStore, + name: &str, + ) -> Result> + where + Params: wasmtime::WasmParams, + Results: wasmtime::WasmResults, + { + let func = self + .instance + .get_typed_func::(store, name)?; + Ok(func) + } + + pub fn get_func(&self, store: &mut HelixStore, name: &str) -> Option { + self.instance.get_func(store, name) + } +} + +pub struct PluginsSystem { + pub store: HelixStore, + pub plugins: HashMap, +} + +impl PluginsSystem { + pub fn builder() -> PluginsSystemBuilder { + PluginsSystemBuilder::default() + } +} + +pub struct PluginsSystemBuilder { + debug_info: bool, + definitions: Vec, + preopened_dirs: Vec, + linker_fn: Box) -> Result<()>>, +} + +impl Default for PluginsSystemBuilder { + fn default() -> Self { + Self { + debug_info: false, + definitions: vec![], + preopened_dirs: vec![], + linker_fn: Box::new(|_| Ok(())), + } + } +} + +impl PluginsSystemBuilder { + pub fn plugin(&mut self, def: PluginDef) -> &mut Self { + self.definitions.push(def); + self + } + + pub fn plugins(&mut self, mut defs: Vec) -> &mut Self { + self.definitions.append(&mut defs); + self + } + + pub fn dir(&mut self, dir: DirDef) -> &mut Self { + self.preopened_dirs.push(dir); + self + } + + pub fn dirs(&mut self, mut dirs: Vec) -> &mut Self { + self.preopened_dirs.append(&mut dirs); + self + } + + pub fn debug_info(&mut self, debug: bool) -> &mut Self { + self.debug_info = debug; + self + } + + pub fn linker(&mut self, linker_fn: F) -> &mut Self + where + F: Fn(&mut wasmtime::Linker) -> Result<()> + 'static, + { + self.linker_fn = Box::new(linker_fn); + self + } + + /// Instanciate the plugins system, compiling and linking WASM modules as appropriate. + pub async fn build(&self) -> Result { + use wasmtime::{Config, Engine, Linker, Module, Store}; + + let mut config = Config::new(); + config.debug_info(self.debug_info); + config.async_support(true); + + let engine = Engine::new(&config)?; + + // Compile plugins + let modules: HashMap = self + .definitions + .iter() + .map(|def| { + println!("Compile {}", def.name); + Module::from_file(&engine, &def.path) + .with_context(|| format!("module creation failed for `{}`", def.name)) + .map(|module| (def.name.clone(), module)) + }) + .collect::>>()?; + + // Dumb link order resolution: a good one would detect cycles to give a better error, in + // our case a link error will arise at link time + let mut link_order = Vec::new(); + for def in &self.definitions { + let insert_pos = if let Some(pos) = link_order.iter().position(|name| name == &def.name) + { + pos + } else { + link_order.push(def.name.clone()); + link_order.len() - 1 + }; + + for dep in &def.dependencies { + if let Some(pos) = link_order.iter().position(|name| name == dep) { + if pos > insert_pos { + link_order.remove(pos); + link_order.insert(insert_pos, dep.clone()); + } + } else { + link_order.insert(insert_pos, dep.clone()); + }; + } + } + + // Link and create instances + let mut wasi_builder = WasiCtxBuilder::new(); + for dir in &self.preopened_dirs { + wasi_builder = dir + .preopen(wasi_builder) + .with_context(|| format!("couldn't preopen directory `{:?}`", dir))?; + } + let wasi = wasi_builder.build(); + + let ctx = HelixCtx { wasi }; + + let mut store = Store::new(&engine, ctx); + + let mut linker = Linker::new(&engine); + wasmtime_wasi::add_to_linker(&mut linker, |s: &mut HelixCtx| &mut s.wasi)?; + + (self.linker_fn)(&mut linker).context("couldn't add host-provided modules to linker")?; + + let mut plugins: HashMap = HashMap::new(); + + for name in link_order { + let module = modules.get(&name).expect("this module was compiled above"); + + let instance = linker + .instantiate_async(&mut store, module) + .await + .with_context(|| format!("couldn't instanciate `{}`", name))?; + + // Register the instance with the linker for the next linking + linker.instance(&mut store, &name.0, instance)?; + + plugins.insert(name, Plugin { instance }); + } + + // Call `init` function on all loaded plugins + for plugin in plugins.values_mut() { + // Call this plugin's `init` function if one is defined + if let Ok(func) = plugin.get_typed_func::<(), ()>(&mut store, "init") { + func.call_async(&mut store, ()).await?; + } + } + + Ok(PluginsSystem { store, plugins }) + } +} diff --git a/helix-plugin/tests/call_host.wat b/helix-plugin/tests/call_host.wat new file mode 100644 index 000000000000..b7af9dec6c66 --- /dev/null +++ b/helix-plugin/tests/call_host.wat @@ -0,0 +1,7 @@ +(module + (import "host" "callback" (func $callback)) + + (func (export "init") + call $callback + ) +) diff --git a/helix-plugin/tests/linking.rs b/helix-plugin/tests/linking.rs new file mode 100644 index 000000000000..fc7125dc9ebd --- /dev/null +++ b/helix-plugin/tests/linking.rs @@ -0,0 +1,88 @@ +use helix_plugin::{DirDef, PluginDef, PluginName, PluginsSystem}; +use std::path::PathBuf; + +/// Based on https://docs.wasmtime.dev/examples-rust-linking.html +#[tokio_macros::test] +async fn two_plugins() { + let linking1 = PluginName::from("linking1"); + let linking2 = PluginName::from("linking2"); + + let mut system = PluginsSystem::builder() + .plugin(PluginDef { + name: linking1.clone(), + path: PathBuf::from("tests/linking1.wat"), + dependencies: vec![linking2.clone()], + }) + .plugin(PluginDef { + name: linking2.clone(), + path: PathBuf::from("tests/linking2.wat"), + dependencies: vec![], + }) + .build() + .await + .unwrap(); + + let run = system + .plugins + .get(&linking1) + .unwrap() + .get_typed_func::<(), ()>(&mut system.store, "run") + .unwrap(); + run.call_async(&mut system.store, ()).await.unwrap(); + + let double = system + .plugins + .get(&linking2) + .unwrap() + .get_typed_func::(&mut system.store, "double") + .unwrap(); + assert_eq!(double.call_async(&mut system.store, 5).await.unwrap(), 10); +} + +#[tokio_macros::test(flavor = "multi_thread")] +async fn wasi_preopen_dir() { + let name = PluginName::from("read_file"); + + // read_file.wasm is a program reading `./Cargo.toml` file and does nothing with it + + PluginsSystem::builder() + .dir(DirDef::Mirrored { + path: PathBuf::from("./"), + }) + .plugin(PluginDef { + name: name.clone(), + path: PathBuf::from("tests/read_file.wasm"), + dependencies: vec![], + }) + .build() + .await + .unwrap(); +} + +#[tokio_macros::test] +async fn callback_to_host() { + use std::sync::atomic::{AtomicBool, Ordering}; + + static CANARY: AtomicBool = AtomicBool::new(false); + + PluginsSystem::builder() + .plugin(PluginDef { + name: PluginName::from("call_host"), + path: PathBuf::from("tests/call_host.wat"), + dependencies: vec![], + }) + .linker(|l| { + l.func_wrap("host", "callback", || CANARY.store(true, Ordering::Relaxed))?; + Ok(()) + }) + .build() + .await + .unwrap(); + + assert_eq!(CANARY.load(Ordering::Relaxed), true); +} + +#[tokio_macros::test] +async fn callback_to_content() { + todo!() +} diff --git a/helix-plugin/tests/linking1.wat b/helix-plugin/tests/linking1.wat new file mode 100644 index 000000000000..0c2732de6a63 --- /dev/null +++ b/helix-plugin/tests/linking1.wat @@ -0,0 +1,24 @@ +;; from https://docs.wasmtime.dev/examples-rust-linking.html + +(module + (import "linking2" "double" (func $double (param i32) (result i32))) + (import "linking2" "log" (func $log (param i32 i32))) + (import "linking2" "memory" (memory 1)) + (import "linking2" "memory_offset" (global $offset i32)) + + (func (export "run") + ;; Call into the other module to double our number, and we could print it + ;; here but for now we just drop it + i32.const 2 + call $double + drop + + ;; Our `data` segment initialized our imported memory, so let's print the + ;; string there now. + global.get $offset + i32.const 14 + call $log + ) + + (data (global.get $offset) "Hello, world!\n") +) diff --git a/helix-plugin/tests/linking2.wat b/helix-plugin/tests/linking2.wat new file mode 100644 index 000000000000..3799aed950bf --- /dev/null +++ b/helix-plugin/tests/linking2.wat @@ -0,0 +1,36 @@ +;; from https://docs.wasmtime.dev/examples-rust-linking.html + +(module + (type $fd_write_ty (func (param i32 i32 i32 i32) (result i32))) + (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (type $fd_write_ty))) + + (func (export "double") (param i32) (result i32) + local.get 0 + i32.const 2 + i32.mul + ) + + (func (export "log") (param i32 i32) + ;; store the pointer in the first iovec field + i32.const 4 + local.get 0 + i32.store + + ;; store the length in the first iovec field + i32.const 4 + local.get 1 + i32.store offset=4 + + ;; call the `fd_write` import + i32.const 1 ;; stdout fd + i32.const 4 ;; iovs start + i32.const 1 ;; number of iovs + i32.const 0 ;; where to write nwritten bytes + call $fd_write + drop + ) + + (memory (export "memory") 2) + (global (export "memory_offset") i32 (i32.const 65536)) +) + diff --git a/helix-plugin/tests/read_file.wasm b/helix-plugin/tests/read_file.wasm new file mode 100644 index 000000000000..9d0915585e52 Binary files /dev/null and b/helix-plugin/tests/read_file.wasm differ