work in progress adding of steel

pull/8675/merge^2
mattwparas 2 years ago
parent f2ccc03332
commit ddca44e02b

593
Cargo.lock generated

@ -70,12 +70,44 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6"
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
"winapi",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.1.0" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "beef"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1"
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.3.2"
@ -88,6 +120,15 @@ version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24a6904aef64d73cf10ab17ebace7befb918b82164785cb89907993be7f83813" checksum = "24a6904aef64d73cf10ab17ebace7befb918b82164785cb89907993be7f83813"
[[package]]
name = "bitmaps"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2"
dependencies = [
"typenum",
]
[[package]] [[package]]
name = "bstr" name = "bstr"
version = "1.4.0" version = "1.4.0"
@ -121,6 +162,12 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c"
[[package]]
name = "byteorder"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.4.0" version = "1.4.0"
@ -163,8 +210,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
dependencies = [ dependencies = [
"iana-time-zone", "iana-time-zone",
"js-sys",
"num-integer", "num-integer",
"num-traits", "num-traits",
"time 0.1.45",
"wasm-bindgen",
"winapi", "winapi",
] ]
@ -185,6 +235,15 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8191fa7302e03607ff0e237d4246cc043ff5b3cb9409d995172ba3bea16b807" checksum = "b8191fa7302e03607ff0e237d4246cc043ff5b3cb9409d995172ba3bea16b807"
[[package]]
name = "codegen"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff61280aed771c3070e7dcc9e050c66f1eb1e3b96431ba66f9f74641d02fc41d"
dependencies = [
"indexmap",
]
[[package]] [[package]]
name = "codespan-reporting" name = "codespan-reporting"
version = "0.11.1" version = "0.11.1"
@ -195,6 +254,17 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "colored"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
dependencies = [
"atty",
"lazy_static",
"winapi",
]
[[package]] [[package]]
name = "content_inspector" name = "content_inspector"
version = "0.2.4" version = "0.2.4"
@ -204,6 +274,15 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "coolor"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af4d7a805ca0d92f8c61a31c809d4323fdaa939b0b440e544d21db7797c5aaad"
dependencies = [
"crossterm 0.23.2",
]
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.4" version = "0.8.4"
@ -219,6 +298,89 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crossbeam"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c"
dependencies = [
"cfg-if",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b"
dependencies = [
"cfg-if",
]
[[package]]
name = "crossterm"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17"
dependencies = [
"bitflags 1.3.2",
"crossterm_winapi",
"libc",
"mio",
"parking_lot",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]] [[package]]
name = "crossterm" name = "crossterm"
version = "0.26.1" version = "0.26.1"
@ -266,8 +428,8 @@ dependencies = [
"cc", "cc",
"codespan-reporting", "codespan-reporting",
"once_cell", "once_cell",
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"scratch", "scratch",
"syn 2.0.15", "syn 2.0.15",
] ]
@ -284,11 +446,21 @@ version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"syn 2.0.15", "syn 2.0.15",
] ]
[[package]]
name = "dashmap"
version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c"
dependencies = [
"cfg-if",
"num_cpus",
]
[[package]] [[package]]
name = "dirs-next" name = "dirs-next"
version = "2.0.0" version = "2.0.0"
@ -310,6 +482,29 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "dlopen"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e80ad39f814a9abe68583cd50a2d45c8a67561c3361ab8da240587dda80937"
dependencies = [
"dlopen_derive",
"lazy_static",
"libc",
"winapi",
]
[[package]]
name = "dlopen_derive"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f236d9e1b1fbd81cea0f9cbdc8dcc7e8ebcd80e6659cd7cb2ad5f6c05946c581"
dependencies = [
"libc",
"quote 0.6.13",
"syn 0.15.44",
]
[[package]] [[package]]
name = "dunce" name = "dunce"
version = "1.0.4" version = "1.0.4"
@ -436,6 +631,31 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "futures"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.28" version = "0.3.28"
@ -453,6 +673,29 @@ dependencies = [
"futures-util", "futures-util",
] ]
[[package]]
name = "futures-io"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
[[package]]
name = "futures-macro"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 2.0.15",
]
[[package]]
name = "futures-sink"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.28" version = "0.3.28"
@ -465,8 +708,13 @@ version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
dependencies = [ dependencies = [
"futures-channel",
"futures-core", "futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task", "futures-task",
"memchr",
"pin-project-lite", "pin-project-lite",
"pin-utils", "pin-utils",
"slab", "slab",
@ -481,6 +729,15 @@ dependencies = [
"thread_local", "thread_local",
] ]
[[package]]
name = "fxhash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
dependencies = [
"byteorder",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.9" version = "0.2.9"
@ -489,7 +746,7 @@ checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
] ]
[[package]] [[package]]
@ -655,7 +912,7 @@ dependencies = [
"bstr", "bstr",
"itoa", "itoa",
"thiserror", "thiserror",
"time", "time 0.3.20",
] ]
[[package]] [[package]]
@ -1087,6 +1344,16 @@ dependencies = [
"memmap2", "memmap2",
] ]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash 0.7.6",
"serde",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.12.3" version = "0.12.3"
@ -1203,7 +1470,7 @@ dependencies = [
"arc-swap", "arc-swap",
"chrono", "chrono",
"content_inspector", "content_inspector",
"crossterm", "crossterm 0.26.1",
"fern", "fern",
"futures-util", "futures-util",
"fuzzy-matcher", "fuzzy-matcher",
@ -1227,6 +1494,7 @@ dependencies = [
"signal-hook", "signal-hook",
"signal-hook-tokio", "signal-hook-tokio",
"smallvec", "smallvec",
"steel-core",
"tempfile", "tempfile",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
@ -1240,7 +1508,7 @@ version = "0.6.0"
dependencies = [ dependencies = [
"bitflags 2.2.1", "bitflags 2.2.1",
"cassowary", "cassowary",
"crossterm", "crossterm 0.26.1",
"helix-core", "helix-core",
"helix-view", "helix-view",
"log", "log",
@ -1274,7 +1542,7 @@ dependencies = [
"bitflags 2.2.1", "bitflags 2.2.1",
"chardetng", "chardetng",
"clipboard-win", "clipboard-win",
"crossterm", "crossterm 0.26.1",
"futures-util", "futures-util",
"helix-core", "helix-core",
"helix-dap", "helix-dap",
@ -1296,6 +1564,15 @@ dependencies = [
"which", "which",
] ]
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.2.6" version = "0.2.6"
@ -1377,6 +1654,26 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "im-lists"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f93ebe9d5265409edc0b5c2ebd96bf7dcd4125c1626bff0ece34b9300e490a"
[[package]]
name = "im-rc"
version = "15.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1955a75fa080c677d3972822ec4bad316169ab1cfc6c257a942c2265dbe5fe"
dependencies = [
"bitmaps",
"rand_core",
"rand_xoshiro",
"sized-chunks",
"typenum",
"version_check",
]
[[package]] [[package]]
name = "imara-diff" name = "imara-diff"
version = "0.1.5" version = "0.1.5"
@ -1433,6 +1730,15 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.6" version = "1.0.6"
@ -1457,6 +1763,17 @@ dependencies = [
"static_assertions", "static_assertions",
] ]
[[package]]
name = "lasso"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeb7b21a526375c5ca55f1a6dfd4e1fad9fa4edd750f530252a718a44b2608f0"
dependencies = [
"dashmap",
"hashbrown 0.11.2",
"serde",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -1513,6 +1830,29 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "logos"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1"
dependencies = [
"logos-derive",
]
[[package]]
name = "logos-derive"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c"
dependencies = [
"beef",
"fnv",
"proc-macro2 1.0.56",
"quote 1.0.26",
"regex-syntax 0.6.29",
"syn 1.0.109",
]
[[package]] [[package]]
name = "lsp-types" name = "lsp-types"
version = "0.94.0" version = "0.94.0"
@ -1541,6 +1881,24 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "memoffset"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1"
dependencies = [
"autocfg",
]
[[package]]
name = "minimad"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed1b13e2000bd8e238d97a97de6fc30224f89a08b0aa5aaa09ed1bd68ba2fa1"
dependencies = [
"once_cell",
]
[[package]] [[package]]
name = "minimal-lexical" name = "minimal-lexical"
version = "0.2.1" version = "0.2.1"
@ -1564,7 +1922,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
@ -1663,6 +2021,27 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pretty"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83f3aa1e3ca87d3b124db7461265ac176b40c277f37e503eaa29c9c75c037846"
dependencies = [
"arrayvec",
"log",
"typed-arena",
"unicode-segmentation",
]
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.56" version = "1.0.56"
@ -1698,13 +2077,32 @@ dependencies = [
"rand", "rand",
] ]
[[package]]
name = "quickscope"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d47bcfc3e13850589cf9338a02b6dfb5aebb3748a0f93a392e8df91d6193b6b"
dependencies = [
"indexmap",
"smallvec",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2 0.4.30",
]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.26" version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
] ]
[[package]] [[package]]
@ -1725,6 +2123,15 @@ dependencies = [
"getrandom", "getrandom",
] ]
[[package]]
name = "rand_xoshiro"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
dependencies = [
"rand_core",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.2.16" version = "0.2.16"
@ -1849,8 +2256,8 @@ version = "1.0.160"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"syn 2.0.15", "syn 2.0.15",
] ]
@ -1871,8 +2278,8 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"syn 2.0.15", "syn 2.0.15",
] ]
@ -1933,6 +2340,16 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "sized-chunks"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e"
dependencies = [
"bitmaps",
"typenum",
]
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.8" version = "0.4.8"
@ -1990,6 +2407,60 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "steel-core"
version = "0.2.0"
dependencies = [
"anyhow",
"bincode",
"chrono",
"codespan-reporting",
"colored",
"dlopen",
"dlopen_derive",
"futures",
"fxhash",
"im-lists",
"im-rc",
"itertools",
"lasso",
"lazy_static",
"log",
"logos",
"once_cell",
"pretty",
"quickscope",
"serde",
"serde_derive",
"serde_json",
"slotmap",
"smallvec",
"steel-gen",
"steel-parser",
"termimad",
"thiserror",
"weak-table",
]
[[package]]
name = "steel-gen"
version = "0.2.0"
dependencies = [
"codegen",
"itertools",
"serde",
"serde_derive",
]
[[package]]
name = "steel-parser"
version = "0.2.0"
dependencies = [
"logos",
"serde",
"serde_derive",
]
[[package]] [[package]]
name = "str-buf" name = "str-buf"
version = "1.0.6" version = "1.0.6"
@ -2002,14 +2473,25 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f026164926842ec52deb1938fae44f83dfdb82d0a5b0270c5bd5935ab74d6dd" checksum = "5f026164926842ec52deb1938fae44f83dfdb82d0a5b0270c5bd5935ab74d6dd"
[[package]]
name = "syn"
version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"unicode-xid",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"unicode-ident", "unicode-ident",
] ]
@ -2019,8 +2501,8 @@ version = "2.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"unicode-ident", "unicode-ident",
] ]
@ -2046,6 +2528,20 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "termimad"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8743d628f9b0eb33087c1e1c4915d91efca23ae69f7c81981489128a0e17d300"
dependencies = [
"coolor",
"crossbeam",
"crossterm 0.23.2",
"minimad",
"thiserror",
"unicode-width",
]
[[package]] [[package]]
name = "termini" name = "termini"
version = "0.1.4" version = "0.1.4"
@ -2081,8 +2577,8 @@ version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"syn 2.0.15", "syn 2.0.15",
] ]
@ -2105,6 +2601,17 @@ dependencies = [
"num_cpus", "num_cpus",
] ]
[[package]]
name = "time"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
dependencies = [
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
"winapi",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.20" version = "0.3.20"
@ -2174,8 +2681,8 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"syn 2.0.15", "syn 2.0.15",
] ]
@ -2234,6 +2741,18 @@ dependencies = [
"regex", "regex",
] ]
[[package]]
name = "typed-arena"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "typenum"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]] [[package]]
name = "unicase" name = "unicase"
version = "2.6.0" version = "2.6.0"
@ -2298,6 +2817,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]] [[package]]
name = "url" name = "url"
version = "2.3.1" version = "2.3.1"
@ -2326,6 +2851,12 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"
@ -2351,8 +2882,8 @@ dependencies = [
"bumpalo", "bumpalo",
"log", "log",
"once_cell", "once_cell",
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"syn 1.0.109", "syn 1.0.109",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -2363,7 +2894,7 @@ version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
dependencies = [ dependencies = [
"quote", "quote 1.0.26",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
] ]
@ -2373,8 +2904,8 @@ version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.56",
"quote", "quote 1.0.26",
"syn 1.0.109", "syn 1.0.109",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
@ -2386,6 +2917,12 @@ version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
[[package]]
name = "weak-table"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "323f4da9523e9a669e1eaf9c6e763892769b1d38c623913647bfdc1532fe4549"
[[package]] [[package]]
name = "which" name = "which"
version = "4.4.0" version = "4.4.0"

@ -128,6 +128,10 @@ pub fn config_file() -> PathBuf {
.unwrap_or_else(|| config_dir().join("config.toml")) .unwrap_or_else(|| config_dir().join("config.toml"))
} }
pub fn helix_module_file() -> PathBuf {
config_dir().join("helix.scm")
}
pub fn workspace_config_file() -> PathBuf { pub fn workspace_config_file() -> PathBuf {
find_workspace().0.join(".helix").join("config.toml") find_workspace().0.join(".helix").join("config.toml")
} }

@ -66,6 +66,9 @@ serde = { version = "1.0", features = ["derive"] }
grep-regex = "0.1.11" grep-regex = "0.1.11"
grep-searcher = "0.1.11" grep-searcher = "0.1.11"
# plugin support
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow"] }
[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100 [target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] } signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
libc = "0.2.142" libc = "0.2.142"

@ -249,6 +249,11 @@ impl Application {
last_render: Instant::now(), last_render: Instant::now(),
}; };
// // Initialize the engine before we boot up!
// crate::commands::ENGINE.with(|x| {
// let _ = x.borrow().globals();
// });
Ok(app) Ok(app)
} }
@ -416,6 +421,7 @@ impl Application {
Ok(()) Ok(())
} }
// TODO: @Matt - consider querying the engine for keybindings
fn refresh_config(&mut self) { fn refresh_config(&mut self) {
let mut refresh_config = || -> Result<(), Error> { let mut refresh_config = || -> Result<(), Error> {
let default_config = Config::load_default() let default_config = Config::load_default()

@ -1,10 +1,14 @@
pub(crate) mod dap; pub(crate) mod dap;
pub(crate) mod engine;
pub(crate) mod lsp; pub(crate) mod lsp;
pub(crate) mod typed; pub(crate) mod typed;
pub use dap::*; pub use dap::*;
use helix_vcs::Hunk; use helix_vcs::Hunk;
pub use lsp::*; pub use lsp::*;
pub use engine::initialize_engine;
use steel::rvals::IntoSteelVal;
use tokio::sync::oneshot; use tokio::sync::oneshot;
use tui::widgets::Row; use tui::widgets::Row;
pub use typed::*; pub use typed::*;
@ -184,6 +188,7 @@ macro_rules! static_commands {
impl MappableCommand { impl MappableCommand {
pub fn execute(&self, cx: &mut Context) { pub fn execute(&self, cx: &mut Context) {
match &self { match &self {
// TODO: @Matt - Add delegating to the engine to run scripts here
Self::Typable { name, args, doc: _ } => { Self::Typable { name, args, doc: _ } => {
let args: Vec<Cow<str>> = args.iter().map(Cow::from).collect(); let args: Vec<Cow<str>> = args.iter().map(Cow::from).collect();
if let Some(command) = typed::TYPABLE_COMMAND_MAP.get(name.as_str()) { if let Some(command) = typed::TYPABLE_COMMAND_MAP.get(name.as_str()) {
@ -195,6 +200,33 @@ impl MappableCommand {
if let Err(e) = (command.fun)(&mut cx, &args[..], PromptEvent::Validate) { if let Err(e) = (command.fun)(&mut cx, &args[..], PromptEvent::Validate) {
cx.editor.set_error(format!("{}", e)); cx.editor.set_error(format!("{}", e));
} }
} else if ENGINE.with(|x| x.borrow().global_exists(name)) {
let args = steel::List::from(
args.iter()
.map(|x| x.clone().into_steelval().unwrap())
.collect::<Vec<_>>(),
);
if let Err(e) = ENGINE.with(|x| {
let mut guard = x.borrow_mut();
{
guard
.register_value("_helix_args", steel::rvals::SteelVal::ListV(args));
let res = guard.run_with_reference::<Context, Context>(
cx,
"*context*",
&format!("(apply {} (cons *context* _helix_args))", name),
);
guard.register_value("_helix_args", steel::rvals::SteelVal::Void);
res
}
}) {
cx.editor.set_error(format!("{}", e));
}
} }
} }
Self::Static { fun, .. } => (fun)(cx), Self::Static { fun, .. } => (fun)(cx),
@ -514,7 +546,24 @@ impl std::str::FromStr for MappableCommand {
.map(|cmd| MappableCommand::Typable { .map(|cmd| MappableCommand::Typable {
name: cmd.name.to_owned(), name: cmd.name.to_owned(),
doc: format!(":{} {:?}", cmd.name, args), doc: format!(":{} {:?}", cmd.name, args),
args: args.clone(),
})
.or_else(|| {
if let Some(doc) = self::engine::ExportedIdentifiers::engine_get_doc(name) {
Some(MappableCommand::Typable {
name: name.to_owned(),
args,
doc,
})
} else if self::engine::ExportedIdentifiers::is_exported(name) {
Some(MappableCommand::Typable {
name: name.to_owned(),
args, args,
doc: "plugin function".to_string(),
})
} else {
None
}
}) })
.ok_or_else(|| anyhow!("No TypableCommand named '{}'", s)) .ok_or_else(|| anyhow!("No TypableCommand named '{}'", s))
} else { } else {
@ -593,6 +642,8 @@ fn move_impl(cx: &mut Context, move_fn: MoveFn, dir: Direction, behaviour: Movem
use helix_core::movement::{move_horizontally, move_vertically}; use helix_core::movement::{move_horizontally, move_vertically};
use self::engine::ENGINE;
fn move_char_left(cx: &mut Context) { fn move_char_left(cx: &mut Context) {
move_impl(cx, move_horizontally, Direction::Backward, Movement::Move) move_impl(cx, move_horizontally, Direction::Backward, Movement::Move)
} }
@ -3287,6 +3338,18 @@ pub mod insert {
} }
} }
pub fn insert_string(cx: &mut Context, string: String) {
let (view, doc) = current!(cx.editor);
let indent = Tendril::from(string);
let transaction = Transaction::insert(
doc.text(),
&doc.selection(view.id).clone().cursors(doc.text().slice(..)),
indent,
);
doc.apply(&transaction, view.id);
}
pub fn insert_tab(cx: &mut Context) { pub fn insert_tab(cx: &mut Context) {
let (view, doc) = current!(cx.editor); let (view, doc) = current!(cx.editor);
// TODO: round out to nearest indentation level (for example a line with 3 spaces should // TODO: round out to nearest indentation level (for example a line with 3 spaces should

@ -0,0 +1,327 @@
use fuzzy_matcher::FuzzyMatcher;
use helix_core::{graphemes, Tendril};
use helix_view::{document::Mode, Editor};
use once_cell::sync::Lazy;
use steel::{
gc::unsafe_erased_pointers::CustomReference,
rvals::{IntoSteelVal, SteelString},
steel_vm::register_fn::RegisterFn,
};
use std::{
borrow::Cow,
collections::{HashMap, VecDeque},
sync::Mutex,
};
use std::{
collections::HashSet,
sync::{Arc, RwLock},
};
use steel::{rvals::Custom, steel_vm::builtin::BuiltInModule};
use crate::{
compositor::{self, Compositor},
job::{self, Callback},
keymap::{merge_keys, Keymap},
ui::{self, Popup, PromptEvent},
};
use super::{
insert::{insert_char, insert_string},
Context, MappableCommand, TYPABLE_COMMAND_LIST,
};
thread_local! {
pub static ENGINE: std::rc::Rc<std::cell::RefCell<steel::steel_vm::engine::Engine>> = configure_engine();
}
pub fn initialize_engine() {
ENGINE.with(|x| x.borrow().globals().first().copied());
}
pub static KEYBINDING_QUEUE: Lazy<SharedKeyBindingsEventQueue> =
Lazy::new(|| SharedKeyBindingsEventQueue::new());
pub static EXPORTED_IDENTIFIERS: Lazy<ExportedIdentifiers> =
Lazy::new(|| ExportedIdentifiers::default());
/// In order to send events from the engine back to the configuration, we can created a shared
/// queue that the engine and the config push and pull from. Alternatively, we could use a channel
/// directly, however this was easy enough to set up.
pub struct SharedKeyBindingsEventQueue {
raw_bindings: Arc<Mutex<VecDeque<String>>>,
}
impl SharedKeyBindingsEventQueue {
pub fn new() -> Self {
Self {
raw_bindings: std::sync::Arc::new(std::sync::Mutex::new(VecDeque::new())),
}
}
pub fn merge(other_as_json: String) {
KEYBINDING_QUEUE
.raw_bindings
.lock()
.unwrap()
.push_back(other_as_json);
}
pub fn get() -> Option<HashMap<Mode, Keymap>> {
let mut guard = KEYBINDING_QUEUE.raw_bindings.lock().unwrap();
if let Some(initial) = guard.pop_front() {
let mut initial = serde_json::from_str(&initial).unwrap();
while let Some(remaining_event) = guard.pop_front() {
let bindings = serde_json::from_str(&remaining_event).unwrap();
merge_keys(&mut initial, bindings);
}
return Some(initial);
}
None
}
}
impl Custom for PromptEvent {}
impl<'a> CustomReference for Context<'a> {}
fn configure_engine() -> std::rc::Rc<std::cell::RefCell<steel::steel_vm::engine::Engine>> {
let mut engine = steel::steel_vm::engine::Engine::new();
let mut module = BuiltInModule::new("helix/core/keybindings".to_string());
module.register_fn("set-keybindings!", SharedKeyBindingsEventQueue::merge);
engine.register_module(module);
let mut module = BuiltInModule::new("helix/core/typable".to_string());
module.register_value(
"PromptEvent::Validate",
PromptEvent::Validate.into_steelval().unwrap(),
);
// Register everything in the typable command list. Now these are all available
for command in TYPABLE_COMMAND_LIST {
let func = |cx: &mut Context, args: &[Cow<str>], event: PromptEvent| {
let mut cx = compositor::Context {
editor: cx.editor,
scroll: None,
jobs: cx.jobs,
};
(command.fun)(&mut cx, args, event)
};
module.register_fn(command.name, func);
}
engine.register_module(module);
let mut module = BuiltInModule::new("helix/core/static".to_string());
// Register everything in the static command list as well
// These just accept the context, no arguments
for command in MappableCommand::STATIC_COMMAND_LIST {
if let MappableCommand::Static { name, fun, .. } = command {
module.register_fn(name, fun);
}
}
module.register_fn("insert_char", insert_char);
module.register_fn("insert_string", insert_string);
module.register_fn("current_selection", get_selection);
module.register_fn("current-highlighted-text!", get_highlighted_text);
module.register_fn("run-in-engine!", run_in_engine);
module.register_fn("get-helix-scm-path", get_helix_scm_path);
engine.register_module(module);
let helix_module_path = helix_loader::helix_module_file();
engine
.run(&format!(
r#"(require "{}")"#,
helix_module_path.to_str().unwrap()
))
.unwrap();
// __module-mangler/home/matt/Documents/steel/cogs/logging/log.scm
// TODO: Use the helix.scm file located in the configuration directory instead
// let mut working_directory = std::env::current_dir().unwrap();
// working_directory.push("helix.scm");
// working_directory = working_directory.canonicalize().unwrap();
let helix_path =
"__module-mangler".to_string() + helix_module_path.as_os_str().to_str().unwrap();
let module = engine.extract_value(&helix_path).unwrap();
if let steel::rvals::SteelVal::HashMapV(m) = module {
let exported = m
.iter()
.filter(|(_, v)| v.is_function())
.map(|(k, _)| {
if let steel::rvals::SteelVal::SymbolV(s) = k {
s.to_string()
} else {
panic!("Found a non symbol!")
}
})
.collect::<HashSet<_>>();
*EXPORTED_IDENTIFIERS.identifiers.write().unwrap() = exported;
let docs = m
.iter()
.filter_map(|(k, v)| {
if let steel::rvals::SteelVal::SymbolV(s) = k {
if s.ends_with("__doc__") {
if let steel::rvals::SteelVal::StringV(d) = v {
return Some((
s.strip_suffix("__doc__").unwrap().to_string(),
d.to_string(),
));
}
}
}
None
})
.collect::<HashMap<_, _>>();
*EXPORTED_IDENTIFIERS.docs.write().unwrap() = docs;
} else {
panic!("Unable to parse exported identifiers from helix module!")
}
std::rc::Rc::new(std::cell::RefCell::new(engine))
}
#[derive(Default, Debug)]
pub struct ExportedIdentifiers {
identifiers: Arc<RwLock<HashSet<String>>>,
docs: Arc<RwLock<HashMap<String, String>>>,
}
impl ExportedIdentifiers {
pub(crate) fn fuzzy_match<'a>(
fuzzy_matcher: &'a fuzzy_matcher::skim::SkimMatcherV2,
input: &'a str,
) -> Vec<(String, i64)> {
EXPORTED_IDENTIFIERS
.identifiers
.read()
.unwrap()
.iter()
.filter_map(|name| {
fuzzy_matcher
.fuzzy_match(name, input)
.map(|score| (name, score))
})
.map(|x| (x.0.to_string(), x.1))
.collect::<Vec<_>>()
}
pub(crate) fn is_exported(ident: &str) -> bool {
EXPORTED_IDENTIFIERS
.identifiers
.read()
.unwrap()
.contains(ident)
}
pub(crate) fn engine_get_doc(ident: &str) -> Option<String> {
EXPORTED_IDENTIFIERS.get_doc(ident)
}
fn get_doc(&self, ident: &str) -> Option<String> {
self.docs.read().unwrap().get(ident).cloned()
}
}
fn get_highlighted_text(cx: &mut Context) -> String {
let (view, doc) = current_ref!(cx.editor);
let text = doc.text().slice(..);
doc.selection(view.id).primary().slice(text).to_string()
}
fn get_selection(cx: &mut Context) -> String {
let (view, doc) = current_ref!(cx.editor);
let text = doc.text().slice(..);
let grapheme_start = doc.selection(view.id).primary().cursor(text);
let grapheme_end = graphemes::next_grapheme_boundary(text, grapheme_start);
if grapheme_start == grapheme_end {
return "".into();
}
let grapheme = text.slice(grapheme_start..grapheme_end).to_string();
let printable = grapheme.chars().fold(String::new(), |mut s, c| {
match c {
'\0' => s.push_str("\\0"),
'\t' => s.push_str("\\t"),
'\n' => s.push_str("\\n"),
'\r' => s.push_str("\\r"),
_ => s.push(c),
}
s
});
printable
}
fn run_in_engine(cx: &mut Context, arg: String) -> anyhow::Result<()> {
let callback = async move {
let output = ENGINE
.with(|x| x.borrow_mut().run(&arg))
.map(|x| format!("{:?}", x));
let (output, success) = match output {
Ok(v) => (Tendril::from(v), true),
Err(e) => (Tendril::from(e.to_string()), false),
};
let call: job::Callback = Callback::EditorCompositor(Box::new(
move |editor: &mut Editor, compositor: &mut Compositor| {
if !output.is_empty() {
let contents = ui::Markdown::new(
format!("```\n{}\n```", output),
editor.syn_loader.clone(),
);
let popup = Popup::new("engine", contents).position(Some(
helix_core::Position::new(editor.cursor().0.unwrap_or_default().row, 2),
));
compositor.replace_or_push("engine", popup);
}
if success {
editor.set_status("Command succeeded");
} else {
editor.set_error("Command failed");
}
},
));
Ok(call)
};
cx.jobs.callback(callback);
Ok(())
}
fn get_helix_scm_path() -> String {
helix_loader::helix_module_file()
.to_str()
.unwrap()
.to_string()
}

@ -1,4 +1,3 @@
use std::fmt::Write;
use std::ops::Deref; use std::ops::Deref;
use crate::job::Job; use crate::job::Job;
@ -11,6 +10,8 @@ use helix_view::editor::{Action, CloseError, ConfigEvent};
use serde_json::Value; use serde_json::Value;
use ui::completers::{self, Completer}; use ui::completers::{self, Completer};
use std::fmt::Write;
#[derive(Clone)] #[derive(Clone)]
pub struct TypableCommand { pub struct TypableCommand {
pub name: &'static str, pub name: &'static str,
@ -2785,14 +2786,23 @@ pub(super) fn command_mode(cx: &mut Context) {
let words = shellwords.words(); let words = shellwords.words();
if words.is_empty() || (words.len() == 1 && !shellwords.ends_with_whitespace()) { if words.is_empty() || (words.len() == 1 && !shellwords.ends_with_whitespace()) {
let globals = crate::commands::engine::ExportedIdentifiers::fuzzy_match(
&FUZZY_MATCHER,
input,
)
.into_iter()
.map(|x| (Cow::from(x.0), x.1))
.collect::<Vec<_>>();
// If the command has not been finished yet, complete commands. // If the command has not been finished yet, complete commands.
let mut matches: Vec<_> = typed::TYPABLE_COMMAND_LIST let mut matches: Vec<_> = typed::TYPABLE_COMMAND_LIST
.iter() .iter()
.filter_map(|command| { .filter_map(|command| {
FUZZY_MATCHER FUZZY_MATCHER
.fuzzy_match(command.name, input) .fuzzy_match(command.name, input)
.map(|score| (command.name, score)) .map(|score| (Cow::from(command.name), score))
}) })
.chain(globals)
.collect(); .collect();
matches.sort_unstable_by_key(|(_file, score)| std::cmp::Reverse(*score)); matches.sort_unstable_by_key(|(_file, score)| std::cmp::Reverse(*score));
@ -2848,14 +2858,60 @@ pub(super) fn command_mode(cx: &mut Context) {
return; return;
} }
// TODO: @Matt - Add completion for added scripting commands here
// Handle typable commands // Handle typable commands
if let Some(cmd) = typed::TYPABLE_COMMAND_MAP.get(parts[0]) { if let Some(cmd) = typed::TYPABLE_COMMAND_MAP.get(parts[0]) {
let shellwords = Shellwords::from(input); let shellwords = Shellwords::from(input);
let args = shellwords.words(); let args = shellwords.words();
log::warn!("calling builtin: {}...", parts[0]);
if let Err(e) = (cmd.fun)(cx, &args[1..], event) { if let Err(e) = (cmd.fun)(cx, &args[1..], event) {
cx.editor.set_error(format!("{}", e)); cx.editor.set_error(format!("{}", e));
} }
} else if ENGINE.with(|x| x.borrow().global_exists(parts[0])) {
let shellwords = Shellwords::from(input);
let args = shellwords.words();
// We're finalizing the event - we actually want to call the function
if event == PromptEvent::Validate {
if let Err(e) = ENGINE.with(|x| {
let args = steel::List::from(
args[1..]
.iter()
.map(|x| x.clone().into_steelval().unwrap())
.collect::<Vec<_>>(),
);
let mut guard = x.borrow_mut();
let mut cx = Context {
register: None,
count: std::num::NonZeroUsize::new(1),
editor: cx.editor,
callback: None,
on_next_key_callback: None,
jobs: cx.jobs,
};
{
guard
.register_value("_helix_args", steel::rvals::SteelVal::ListV(args));
let res = guard.run_with_reference::<Context, Context>(
&mut cx,
"*context*",
&format!("(apply {} (cons *context* _helix_args))", parts[0]),
);
guard.register_value("_helix_args", steel::rvals::SteelVal::Void);
res
}
}) {
cx.editor.set_error(format!("{}", e));
};
}
} else if event == PromptEvent::Validate { } else if event == PromptEvent::Validate {
cx.editor cx.editor
.set_error(format!("no such command: '{}'", parts[0])); .set_error(format!("no such command: '{}'", parts[0]));
@ -2872,6 +2928,18 @@ pub(super) fn command_mode(cx: &mut Context) {
return Some((*doc).into()); return Some((*doc).into());
} }
return Some(format!("{}\nAliases: {}", doc, aliases.join(", ")).into()); return Some(format!("{}\nAliases: {}", doc, aliases.join(", ")).into());
} else if ENGINE.with(|x| x.borrow().global_exists(part)) {
if let Some(v) = super::engine::ExportedIdentifiers::engine_get_doc(part) {
return Some(v.into());
}
// if let Ok(v) = ENGINE.with(|x| x.borrow().extract_value(&format!("{part}__doc__"))) {
// if let steel::rvals::SteelVal::StringV(s) = v {
// return Some(s.to_string().into());
// }
// }
return Some("Run this plugin command!".into());
} }
None None

@ -59,11 +59,13 @@ impl Config {
pub fn load( pub fn load(
global: Result<String, ConfigLoadError>, global: Result<String, ConfigLoadError>,
local: Result<String, ConfigLoadError>, local: Result<String, ConfigLoadError>,
engine_overlay: Option<HashMap<Mode, Keymap>>,
) -> Result<Config, ConfigLoadError> { ) -> Result<Config, ConfigLoadError> {
let global_config: Result<ConfigRaw, ConfigLoadError> = let global_config: Result<ConfigRaw, ConfigLoadError> =
global.and_then(|file| toml::from_str(&file).map_err(ConfigLoadError::BadConfig)); global.and_then(|file| toml::from_str(&file).map_err(ConfigLoadError::BadConfig));
let local_config: Result<ConfigRaw, ConfigLoadError> = let local_config: Result<ConfigRaw, ConfigLoadError> =
local.and_then(|file| toml::from_str(&file).map_err(ConfigLoadError::BadConfig)); local.and_then(|file| toml::from_str(&file).map_err(ConfigLoadError::BadConfig));
let res = match (global_config, local_config) { let res = match (global_config, local_config) {
(Ok(global), Ok(local)) => { (Ok(global), Ok(local)) => {
let mut keys = keymap::default(); let mut keys = keymap::default();
@ -74,6 +76,10 @@ impl Config {
merge_keys(&mut keys, local_keys) merge_keys(&mut keys, local_keys)
} }
if let Some(overlay) = engine_overlay {
merge_keys(&mut keys, overlay);
}
let editor = match (global.editor, local.editor) { let editor = match (global.editor, local.editor) {
(None, None) => helix_view::editor::Config::default(), (None, None) => helix_view::editor::Config::default(),
(None, Some(val)) | (Some(val), None) => { (None, Some(val)) | (Some(val), None) => {
@ -100,6 +106,11 @@ impl Config {
if let Some(keymap) = config.keys { if let Some(keymap) = config.keys {
merge_keys(&mut keys, keymap); merge_keys(&mut keys, keymap);
} }
if let Some(overlay) = engine_overlay {
merge_keys(&mut keys, overlay);
}
Config { Config {
theme: config.theme, theme: config.theme,
keys, keys,
@ -116,12 +127,27 @@ impl Config {
Ok(res) Ok(res)
} }
// TODO: @Matt -> Add key binding here by reading value from steel engine
pub fn load_default() -> Result<Config, ConfigLoadError> { pub fn load_default() -> Result<Config, ConfigLoadError> {
let global_config = let global_config =
fs::read_to_string(helix_loader::config_file()).map_err(ConfigLoadError::Error); fs::read_to_string(helix_loader::config_file()).map_err(ConfigLoadError::Error);
let local_config = fs::read_to_string(helix_loader::workspace_config_file()) let local_config = fs::read_to_string(helix_loader::workspace_config_file())
.map_err(ConfigLoadError::Error); .map_err(ConfigLoadError::Error);
Config::load(global_config, local_config)
// let binding = crate::commands::ENGINE.with(|x| {
// x.borrow_mut()
// .run("(value->jsexpr-string *KEYBINDINGS*)")
// .unwrap()
// });
// let keybindings_as_str = binding[0]
// .string_or_else(|| panic!("Should always be a string"))
// .unwrap();
// let bindings: HashMap<Mode, Keymap> = serde_json::from_str(&keybindings_as_str).unwrap();
let bindings = crate::commands::engine::SharedKeyBindingsEventQueue::get();
Config::load(global_config, local_config, bindings)
} }
} }
@ -131,7 +157,7 @@ mod tests {
impl Config { impl Config {
fn load_test(config: &str) -> Config { fn load_test(config: &str) -> Config {
Config::load(Ok(config.to_owned()), Err(ConfigLoadError::default())).unwrap() Config::load(Ok(config.to_owned()), Err(ConfigLoadError::default()), None).unwrap()
} }
} }

@ -143,6 +143,9 @@ impl DerefMut for KeyTrieNode {
} }
} }
// TODO: impl FromSteelVal and IntoSteelVal for this - or expose methods
// that allow Steel to integrate with the keybindings on the editor
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum KeyTrie { pub enum KeyTrie {
Leaf(MappableCommand), Leaf(MappableCommand),

@ -126,6 +126,9 @@ FLAGS:
helix_loader::initialize_config_file(args.config_file.clone()); helix_loader::initialize_config_file(args.config_file.clone());
// Initialize the engine before we boot up!
let _ = helix_term::commands::initialize_engine();
let config = match Config::load_default() { let config = match Config::load_default() {
Ok(config) => config, Ok(config) => config,
Err(ConfigLoadError::Error(err)) if err.kind() == std::io::ErrorKind::NotFound => { Err(ConfigLoadError::Error(err)) if err.kind() == std::io::ErrorKind::NotFound => {

@ -0,0 +1,178 @@
(require-builtin helix/core/typable as helix.)
(require-builtin helix/core/static as helix.static.)
(require-builtin helix/core/keybindings as helix.keybindings.)
(provide
set-theme-dracula
set-theme-dracula__doc__
set-theme-custom
set-theme-custom__doc__
theme-then-vsplit
theme-then-vsplit__doc__
custom-undo
custom-undo__doc__
lam
lam__doc__
delete-word-forward
insert-string-at-selection
highlight-to-matching-paren
highlight-to-matching-paren__doc__
delete-sexpr
delete-sexpr__doc__
run-expr
run-highlight
make-minor-mode!
git-status
reload-helix-scm
)
;;@doc
;; Sets the theme to be the dracula theme
(define (set-theme-dracula cx)
(helix.theme cx (list "dracula") helix.PromptEvent::Validate))
;;@doc
;; Sets the theme to be the theme passed in
(define (set-theme-custom cx entered-theme)
(helix.theme cx (list entered-theme) helix.PromptEvent::Validate))
;;@doc
;; Switch theme to the entered theme, then split the current file into
;; a vsplit
(define (theme-then-vsplit cx entered-theme)
(set-theme-custom cx entered-theme)
(helix.vsplit cx '() helix.PromptEvent::Validate))
;;@doc
;; Perform an undo
(define (custom-undo cx)
(helix.static.undo cx))
;;@doc
;; Insert a lambda
(define (lam cx)
(helix.static.insert_char cx #\λ)
(helix.static.insert_mode cx))
;;@doc
;; Insert the string at the selection and go back into insert mode
(define (insert-string-at-selection cx str)
(helix.static.insert_string cx str)
(helix.static.insert_mode cx))
;;@doc
;; Delete the word forward
(define (delete-word-forward cx)
(helix.static.delete_word_forward cx))
;;@doc
;; Registers a minor mode with the registered modifer and key map
;;
;; Examples:
;; ```scheme
;; (make-minor-mode! "+"
;; (hash "P" ":lam"))
;; ```
(define (make-minor-mode! modifier bindings)
(~> (hash "normal" (hash modifier bindings))
(value->jsexpr-string)
(helix.keybindings.set-keybindings!)))
(define-syntax minor-mode!
(syntax-rules (=>)
[(minor-mode! modifier (key => function))
(make-minor-mode! modifier (minor-mode-cruncher (key => function)))]
[(minor-mode! modifier (key => (function ...)))
(make-minor-mode! modifier (minor-mode-cruncher (key => (function ...))))]
[(minor-mode! modifier (key => function) remaining ...)
(make-minor-mode! modifier (minor-mode-cruncher (key => function) remaining ...))]
[(minor-mode! modifier (key => (function ...)) remaining ...)
(make-minor-mode! modifier (minor-mode-cruncher (key => function) ... remaining ...))]
))
(define-syntax minor-mode-cruncher
(syntax-rules (=>)
[(minor-mode-cruncher (key => (function ...)))
(hash key (map (lambda (x)
(string-append ":" (symbol->string x)))
(quote (function ...))))]
[(minor-mode-cruncher (key => function))
(hash key (string-append ":" (symbol->string (quote function))))]
[(minor-mode-cruncher (key => (function ...)) remaining ...)
(hash-insert
(minor-mode-cruncher remaining ...)
key (map (lambda (x)
(string-append ":" (symbol->string x)))
(quote (function ...))))]
[(minor-mode-cruncher (key => function) remaining ...)
(hash-insert
(minor-mode-cruncher remaining ...)
key
(string-append ":" (symbol->string (quote function))))]
))
;;@doc
;; Highlight to the matching paren
(define (highlight-to-matching-paren cx)
(helix.static.select_mode cx)
(helix.static.match_brackets cx))
(define (run-expr cx)
(define current-selection (helix.static.current_selection cx))
(when (or (equal? "(" current-selection)
(equal? ")" current-selection))
(highlight-to-matching-paren cx)
(helix.static.run-in-engine! cx (helix.static.current-highlighted-text! cx))
(helix.static.normal_mode cx)))
(define (run-highlight cx)
(helix.static.run-in-engine! cx (helix.static.current-highlighted-text! cx)))
;;@doc
;; Delete the s-expression matching this bracket
;; If the current selection is not on a bracket, this is a no-op
(define (delete-sexpr cx)
(define current-selection (helix.static.current_selection cx))
(when (or (equal? "(" current-selection)
(equal? ")" current-selection))
(highlight-to-matching-paren cx)
(helix.static.delete_selection cx)))
; (minor-mode! "+" ("l" => lam)
; ("q" => (set-theme-dracula lam)))
(minor-mode! "P" ("l" => lam)
("p" => highlight-to-matching-paren)
("d" => delete-sexpr)
("r" => run-expr))
(make-minor-mode! "+" (hash "l" ":lam"))
(define (git-status cx)
(helix.run-shell-command cx '("git" "status") helix.PromptEvent::Validate))
(minor-mode! "G" ("s" => git-status))
(define (reload-helix-scm cx)
(helix.static.run-in-engine! cx
(string-append "(require \"" (helix.static.get-helix.scm-path) "\")")))
Loading…
Cancel
Save