diff --git a/Cargo.lock b/Cargo.lock index f7b8523a..270d9dd3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,7 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "regex", ] @@ -81,7 +81,7 @@ dependencies = [ "mio-extras", "miow 0.3.7", "nix 0.22.2", - "parking_lot 0.11.2", + "parking_lot", "regex-automata", "serde 1.0.130", "serde_yaml", @@ -108,7 +108,7 @@ dependencies = [ "mio-extras", "miow 0.3.7", "nix 0.22.2", - "parking_lot 0.11.2", + "parking_lot", "regex-automata", "serde 1.0.130", "serde_yaml", @@ -119,15 +119,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -143,15 +134,6 @@ version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf" -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - [[package]] name = "arrayvec" version = "0.5.2" @@ -173,17 +155,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi 0.3.9", -] - [[package]] name = "autocfg" version = "0.1.7" @@ -280,7 +251,7 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "memchr", "regex-automata", ] @@ -400,33 +371,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "clap" -version = "2.33.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" -dependencies = [ - "ansi_term 0.11.0", - "atty", - "bitflags", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - -[[package]] -name = "clicolors-control" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f84dec9bc083ce2503908cd305af98bd363da6f54bf8d4bf0ac14ee749ad5d1" -dependencies = [ - "kernel32-sys", - "lazy_static 0.2.11", - "libc", - "winapi 0.3.9", -] - [[package]] name = "clipboard-win" version = "3.1.1" @@ -502,7 +446,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b1b9d958c2b1368a663f05538fc1b5975adce1e19f435acceae987aceeeb369" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "nom 5.1.2", "rust-ini", "serde 1.0.130", @@ -512,23 +456,6 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "console" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd48adf136733979b49e15bc3b4c43cc0d3c85ece7bd08e6daa414c6fcb13e6" -dependencies = [ - "atty", - "clicolors-control", - "lazy_static 1.4.0", - "libc", - "parking_lot 0.11.2", - "regex", - "termios", - "unicode-width", - "winapi 0.3.9", -] - [[package]] name = "console_error_panic_hook" version = "0.1.6" @@ -690,7 +617,7 @@ dependencies = [ "gimli", "log", "regalloc", - "smallvec 1.6.1", + "smallvec", "target-lexicon", ] @@ -724,7 +651,7 @@ checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" dependencies = [ "cranelift-codegen", "log", - "smallvec 1.6.1", + "smallvec", "target-lexicon", ] @@ -737,31 +664,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "crossbeam" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7408247b1b87f480890f28b670c5f8d9a8a4274833433fe74dc0dfd46d33650" -dependencies = [ - "crossbeam-channel 0.2.6", - "crossbeam-deque 0.5.2", - "crossbeam-epoch 0.5.2", - "crossbeam-utils 0.5.0", -] - -[[package]] -name = "crossbeam-channel" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b85741761b7f160bc5e7e0c14986ef685b7f8bf9b7ad081c60c604bb4649827" -dependencies = [ - "crossbeam-epoch 0.6.1", - "crossbeam-utils 0.5.0", - "parking_lot 0.6.4", - "rand 0.5.6", - "smallvec 0.6.14", -] - [[package]] name = "crossbeam-channel" version = "0.5.1" @@ -769,17 +671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.5", -] - -[[package]] -name = "crossbeam-deque" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7792c4a9b5a4222f654e3728a3dd945aacc24d2c3a1a096ed265d80e4929cb9a" -dependencies = [ - "crossbeam-epoch 0.5.2", - "crossbeam-utils 0.5.0", + "crossbeam-utils", ] [[package]] @@ -789,36 +681,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch 0.9.5", - "crossbeam-utils 0.8.5", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30fecfcac6abfef8771151f8be4abc9e4edc112c2bcb233314cafde2680536e9" -dependencies = [ - "arrayvec 0.4.12", - "cfg-if 0.1.10", - "crossbeam-utils 0.5.0", - "lazy_static 1.4.0", - "memoffset 0.2.1", - "scopeguard 0.3.3", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2449aaa4ec7ef96e5fb24db16024b935df718e9ae1cec0a1e68feeca2efca7b8" -dependencies = [ - "arrayvec 0.4.12", - "cfg-if 0.1.10", - "crossbeam-utils 0.6.6", - "lazy_static 1.4.0", - "memoffset 0.2.1", - "scopeguard 0.3.3", + "crossbeam-epoch", + "crossbeam-utils", ] [[package]] @@ -828,26 +692,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.5", - "lazy_static 1.4.0", - "memoffset 0.6.4", - "scopeguard 1.1.0", -] - -[[package]] -name = "crossbeam-utils" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" - -[[package]] -name = "crossbeam-utils" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -dependencies = [ - "cfg-if 0.1.10", - "lazy_static 1.4.0", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", ] [[package]] @@ -857,7 +705,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ "cfg-if 1.0.0", - "lazy_static 1.4.0", + "lazy_static", ] [[package]] @@ -897,7 +745,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn", ] @@ -1070,7 +918,7 @@ dependencies = [ "js-sys", "keyboard-types", "kurbo", - "lazy_static 1.4.0", + "lazy_static", "piet-wgpu", "raw-window-handle", "time 0.2.27", @@ -1092,7 +940,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "libc", "winapi 0.3.9", "wio", @@ -1255,7 +1103,7 @@ dependencies = [ "intl_pluralrules", "ouroboros", "rustc-hash", - "smallvec 1.6.1", + "smallvec", "unic-langid", ] @@ -1298,7 +1146,7 @@ dependencies = [ "dwrote", "float-ord", "freetype", - "lazy_static 1.4.0", + "lazy_static", "libc", "log", "pathfinder_geometry", @@ -1537,20 +1385,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "fzyr" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0d1c9db3ddaa88a020ad2685aa5352dbdb5f6630a9957e5abc9232cf826712" -dependencies = [ - "bit-vec 0.5.1", - "clap", - "console", - "crossbeam", - "itertools 0.7.11", - "ndarray", -] - [[package]] name = "generational-arena" version = "0.2.8" @@ -1899,9 +1733,9 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" dependencies = [ - "crossbeam-utils 0.8.5", + "crossbeam-utils", "globset", - "lazy_static 1.4.0", + "lazy_static", "log", "memchr", "regex", @@ -2045,15 +1879,6 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" -[[package]] -name = "itertools" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.10.3" @@ -2175,7 +2000,7 @@ dependencies = [ name = "lapce-core" version = "0.0.10" dependencies = [ - "itertools 0.10.3", + "itertools", "serde 1.0.130", "serde_json", "thiserror", @@ -2199,30 +2024,29 @@ dependencies = [ "cc", "chrono", "config", - "crossbeam-channel 0.5.1", - "crossbeam-utils 0.8.5", + "crossbeam-channel", + "crossbeam-utils", "diff", "directories", "druid", "fern", "flate2", "fuzzy-matcher", - "fzyr", "hashbrown 0.11.2", "im", "include_dir", "indexmap", - "itertools 0.10.3", + "itertools", "jsonrpc-lite", "lapce-core", "lapce-proxy", "lapce-rpc", - "lazy_static 1.4.0", + "lazy_static", "libloading", "log", "lsp-types", "notify 5.0.0-pre.13", - "parking_lot 0.11.2", + "parking_lot", "rayon", "regex", "reqwest", @@ -2235,11 +2059,6 @@ dependencies = [ "threadpool", "tinyfiledialogs", "toml", - "tree-sitter", - "tree-sitter-go", - "tree-sitter-highlight", - "tree-sitter-javascript", - "tree-sitter-rust", "unicode-segmentation", "unicode-width", "usvg", @@ -2255,7 +2074,7 @@ dependencies = [ "alacritty_terminal 0.16.0-rc2", "anyhow", "base64", - "crossbeam-channel 0.5.1", + "crossbeam-channel", "directories", "git2", "grep-matcher", @@ -2271,7 +2090,7 @@ dependencies = [ "lsp-types", "mio 0.6.23", "notify 5.0.0-pre.13", - "parking_lot 0.11.2", + "parking_lot", "regex", "reqwest", "serde 1.0.130", @@ -2287,9 +2106,9 @@ name = "lapce-rpc" version = "0.0.1" dependencies = [ "anyhow", - "crossbeam-channel 0.5.1", + "crossbeam-channel", "jsonrpc-lite", - "parking_lot 0.11.2", + "parking_lot", "serde 1.0.130", "serde_json", ] @@ -2306,30 +2125,29 @@ dependencies = [ "cc", "chrono", "config", - "crossbeam-channel 0.5.1", - "crossbeam-utils 0.8.5", + "crossbeam-channel", + "crossbeam-utils", "diff", "directories", "druid", "fern", "flate2", "fuzzy-matcher", - "fzyr", "hashbrown 0.11.2", "im", "include_dir", "indexmap", - "itertools 0.10.3", + "itertools", "jsonrpc-lite", "lapce-data", "lapce-proxy", "lapce-rpc", - "lazy_static 1.4.0", + "lazy_static", "libloading", "log", "lsp-types", "notify 5.0.0-pre.13", - "parking_lot 0.11.2", + "parking_lot", "rayon", "regex", "reqwest", @@ -2342,11 +2160,6 @@ dependencies = [ "threadpool", "tinyfiledialogs", "toml", - "tree-sitter", - "tree-sitter-go", - "tree-sitter-highlight", - "tree-sitter-javascript", - "tree-sitter-rust", "unicode-segmentation", "unicode-width", "usvg", @@ -2361,12 +2174,6 @@ version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10257499f089cd156ad82d0a9cd57d9501fa2c989068992a97eb3c27836f206b" -[[package]] -name = "lazy_static" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" - [[package]] name = "lazy_static" version = "1.4.0" @@ -2466,30 +2273,20 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "objc", "objc-foundation", "regex", "winapi 0.3.9", ] -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -dependencies = [ - "owning_ref", - "scopeguard 0.3.3", -] - [[package]] name = "lock_api" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" dependencies = [ - "scopeguard 1.1.0", + "scopeguard", ] [[package]] @@ -2611,15 +2408,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" -[[package]] -name = "matrixmultiply" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcad67dcec2d58ff56f6292582377e6921afdf3bfbd533e26fb8900ae575e002" -dependencies = [ - "rawpointer", -] - [[package]] name = "maybe-uninit" version = "2.0.0" @@ -2659,12 +2447,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" - [[package]] name = "memoffset" version = "0.6.4" @@ -2763,7 +2545,7 @@ checksum = "6bc513025fe5005a3aa561b50fdb2cda5a150b84800ae02acd8aa9ed62ca1a6b" dependencies = [ "mio 0.6.23", "miow 0.3.7", - "parking_lot 0.11.2", + "parking_lot", "spsc-buffer", "winapi 0.3.9", ] @@ -2849,7 +2631,7 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "libc", "log", "openssl", @@ -2861,18 +2643,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "ndarray" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e3d24c5ba54015d7d5203ca6f00d4cc16c71042bf7f7be26f091236f390a16a" -dependencies = [ - "itertools 0.7.11", - "matrixmultiply", - "num-complex", - "num-traits 0.1.43", -] - [[package]] name = "ndk" version = "0.6.0" @@ -2898,7 +2668,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ffb7443daba48349d545028777ca98853b018b4c16624aa01223bc29e078da" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "libc", "log", "ndk", @@ -2962,15 +2732,9 @@ dependencies = [ "cc", "cfg-if 1.0.0", "libc", - "memoffset 0.6.4", + "memoffset", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - [[package]] name = "nom" version = "5.1.2" @@ -3018,7 +2782,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245d358380e2352c2d020e8ee62baac09b3420f1f6c012a31326cfced4ad487d" dependencies = [ "bitflags", - "crossbeam-channel 0.5.1", + "crossbeam-channel", "filetime", "fsevent-sys 4.1.0", "inotify 0.9.6", @@ -3038,15 +2802,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "num-complex" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b288631d7878aaf59442cffd36910ea604ecd7745c36054328595114001c9656" -dependencies = [ - "num-traits 0.2.14", -] - [[package]] name = "num-integer" version = "0.1.44" @@ -3244,25 +2999,6 @@ dependencies = [ "syn", ] -[[package]] -name = "owning_ref" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] - -[[package]] -name = "parking_lot" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.3.1", -] - [[package]] name = "parking_lot" version = "0.11.2" @@ -3270,21 +3006,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", - "lock_api 0.4.5", - "parking_lot_core 0.8.5", -] - -[[package]] -name = "parking_lot_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" -dependencies = [ - "libc", - "rand 0.5.6", - "rustc_version 0.2.3", - "smallvec 0.6.14", - "winapi 0.3.9", + "lock_api", + "parking_lot_core", ] [[package]] @@ -3299,7 +3022,7 @@ dependencies = [ "libc", "petgraph 0.5.1", "redox_syscall", - "smallvec 1.6.1", + "smallvec", "thread-id", "winapi 0.3.9", ] @@ -3505,19 +3228,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.6.5" @@ -3654,12 +3364,6 @@ dependencies = [ "cty", ] -[[package]] -name = "rawpointer" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebac11a9d2e11f2af219b8b8d833b76b1ea0e054aa0e8d8e9e4cbde353bdf019" - [[package]] name = "rayon" version = "1.5.1" @@ -3667,7 +3371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ "autocfg 1.0.1", - "crossbeam-deque 0.8.1", + "crossbeam-deque", "either", "rayon-core", ] @@ -3678,10 +3382,10 @@ version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ - "crossbeam-channel 0.5.1", - "crossbeam-deque 0.8.1", - "crossbeam-utils 0.8.5", - "lazy_static 1.4.0", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", "num_cpus", ] @@ -3727,7 +3431,7 @@ checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", - "smallvec 1.6.1", + "smallvec", ] [[package]] @@ -3809,7 +3513,7 @@ dependencies = [ "hyper-tls", "ipnet", "js-sys", - "lazy_static 1.4.0", + "lazy_static", "log", "mime", "native-tls", @@ -3911,7 +3615,7 @@ checksum = "0ab463a295d00f3692e0974a0bfd83c7a9bcd119e27e07c2beecdb1b44a09d10" dependencies = [ "bitflags", "bytemuck", - "smallvec 1.6.1", + "smallvec", "ttf-parser 0.9.0", "unicode-bidi-mirroring", "unicode-ccc", @@ -3940,7 +3644,7 @@ version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "winapi 0.3.9", ] @@ -3950,12 +3654,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" - [[package]] name = "scopeguard" version = "1.1.0" @@ -4045,7 +3743,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "num-traits 0.1.43", "regex", "serde 0.8.23", @@ -4163,7 +3861,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "740223c51853f3145fe7c90360d2d4232f2b62e3449489c207eccde818979982" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", ] [[package]] @@ -4255,13 +3953,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f96b4737c2ce5987354855aed3797279def4ebf734436c6aa4552cf8e169935" dependencies = [ "crc32fast", - "crossbeam-epoch 0.9.5", - "crossbeam-utils 0.8.5", + "crossbeam-epoch", + "crossbeam-utils", "fs2", "fxhash", "libc", "log", - "parking_lot 0.11.2", + "parking_lot", ] [[package]] @@ -4273,15 +3971,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - [[package]] name = "smallvec" version = "1.6.1" @@ -4296,7 +3985,7 @@ checksum = "ec783683499a2cfc85b6df3d04f83b1907b5cbd98a1aed44667dbdf1eac4e64c" dependencies = [ "bitflags", "dlib", - "lazy_static 1.4.0", + "lazy_static", "log", "memmap2 0.2.3", "nix 0.20.0", @@ -4314,7 +4003,7 @@ dependencies = [ "bitflags", "calloop", "dlib", - "lazy_static 1.4.0", + "lazy_static", "log", "memmap2 0.3.1", "nix 0.22.2", @@ -4430,12 +4119,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" @@ -4521,24 +4204,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "termios" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" -dependencies = [ - "libc", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.28" @@ -4753,7 +4418,7 @@ version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ca517f43f0fb96e0c3072ed5c275fe5eece87e8cb52f4a77b69226d3b1c9df8" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", ] [[package]] @@ -4762,7 +4427,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9cbe87a2fa7e35900ce5de20220a582a9483a7063811defce79d7cbd59d4cfe" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", "sharded-slab", "thread_local", "tracing-core", @@ -5053,7 +4718,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" dependencies = [ - "rand 0.6.5", + "rand", ] [[package]] @@ -5062,12 +4727,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.3" @@ -5138,7 +4797,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe8dc78e2326ba5f845f4b5bf548401604fa20b1dd1d365fb73b6c1d6364041" dependencies = [ "bumpalo", - "lazy_static 1.4.0", + "lazy_static", "log", "proc-macro2", "quote", @@ -5224,7 +4883,7 @@ dependencies = [ "rkyv", "serde 1.0.130", "serde_bytes", - "smallvec 1.6.1", + "smallvec", "target-lexicon", "thiserror", "wasmer-types", @@ -5245,7 +4904,7 @@ dependencies = [ "loupe", "more-asserts", "rayon", - "smallvec 1.6.1", + "smallvec", "target-lexicon", "tracing", "wasmer-compiler", @@ -5273,7 +4932,7 @@ checksum = "ab20311c354fe2c12bc766417e0a1a45f399c1cd8ff262127d1dc86d0588971a" dependencies = [ "backtrace", "enumset", - "lazy_static 1.4.0", + "lazy_static", "loupe", "memmap2 0.5.0", "more-asserts", @@ -5377,7 +5036,7 @@ dependencies = [ "indexmap", "libc", "loupe", - "memoffset 0.6.4", + "memoffset", "more-asserts", "region", "rkyv", @@ -5481,7 +5140,7 @@ checksum = "a21817947c7011bbd0a27e11b17b337bfd022e8544b071a2641232047966fbda" dependencies = [ "nix 0.20.0", "once_cell", - "smallvec 1.6.1", + "smallvec", "wayland-sys 0.28.6", ] @@ -5493,7 +5152,7 @@ checksum = "94f6e5e340d7c13490eca867898c4cec5af56c27a5ffe5c80c6fc4708e22d33e" dependencies = [ "nix 0.22.2", "once_cell", - "smallvec 1.6.1", + "smallvec", "wayland-sys 0.29.4", ] @@ -5572,7 +5231,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d841fca9aed7febf9bed2e9796c49bf58d4152ceda8ac949ebe00868d8f0feb8" dependencies = [ "dlib", - "lazy_static 1.4.0", + "lazy_static", "pkg-config", ] @@ -5583,7 +5242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4" dependencies = [ "dlib", - "lazy_static 1.4.0", + "lazy_static", "pkg-config", ] @@ -5607,9 +5266,9 @@ dependencies = [ "js-sys", "log", "naga", - "parking_lot 0.11.2", + "parking_lot", "raw-window-handle", - "smallvec 1.6.1", + "smallvec", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -5632,10 +5291,10 @@ dependencies = [ "fxhash", "log", "naga", - "parking_lot 0.11.2", + "parking_lot", "profiling", "raw-window-handle", - "smallvec 1.6.1", + "smallvec", "thiserror", "wgpu-hal", "wgpu-types", @@ -5667,7 +5326,7 @@ dependencies = [ "metal", "naga", "objc", - "parking_lot 0.11.2", + "parking_lot", "profiling", "range-alloc", "raw-window-handle", @@ -5695,7 +5354,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" dependencies = [ "either", - "lazy_static 1.4.0", + "lazy_static", "libc", ] @@ -5754,7 +5413,7 @@ dependencies = [ "core-video-sys", "dispatch", "instant", - "lazy_static 1.4.0", + "lazy_static", "libc", "log", "memmap2 0.2.3", @@ -5764,7 +5423,7 @@ dependencies = [ "ndk-glue", "ndk-sys", "objc", - "parking_lot 0.11.2", + "parking_lot", "percent-encoding", "raw-window-handle", "smithay-client-toolkit 0.15.3", @@ -5821,7 +5480,7 @@ version = "2.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", "libc", "maybe-uninit", "pkg-config", @@ -5871,7 +5530,7 @@ source = "git+https://github.com/maroider/xkbcommon-dl?rev=900832888ad6f11011d13 dependencies = [ "bitflags", "dlib", - "lazy_static 1.4.0", + "lazy_static", "log", "x11-dl", ] diff --git a/lapce-core/src/language.rs b/lapce-core/src/language.rs index 78584727..883ce561 100644 --- a/lapce-core/src/language.rs +++ b/lapce-core/src/language.rs @@ -1,8 +1,8 @@ use std::{collections::HashSet, path::Path}; -use tree_sitter::{Parser, Query, TreeCursor}; +use tree_sitter::{Parser, TreeCursor}; -use crate::style::{HighlightConfiguration, SCOPES}; +use crate::style::HighlightConfiguration; const RUST_CODE_LENS_LIST: &[&str] = &["source_file", "impl_item", "trait_item", "declaration_list"]; @@ -59,9 +59,8 @@ pub(crate) fn new_highlight_config(&self) -> HighlightConfiguration { LapceLanguage::Rust => tree_sitter_rust::HIGHLIGHT_QUERY, LapceLanguage::Go => tree_sitter_go::HIGHLIGHT_QUERY, }; - let mut config = - HighlightConfiguration::new(language, query, "", "").unwrap(); - config + + HighlightConfiguration::new(language, query, "", "").unwrap() } pub(crate) fn walk_tree( diff --git a/lapce-core/src/lens.rs b/lapce-core/src/lens.rs index cb92e19f..82433114 100644 --- a/lapce-core/src/lens.rs +++ b/lapce-core/src/lens.rs @@ -32,7 +32,6 @@ pub struct LensLeaf { pub struct LensIter<'a> { cursor: Cursor<'a, LensInfo>, - ix: usize, end: usize, } @@ -64,7 +63,6 @@ pub fn height_of_line(&self, line: usize) -> usize { pub fn iter(&self) -> LensIter { LensIter { cursor: Cursor::new(&self.0, 0), - ix: 0, end: self.len(), } } @@ -74,7 +72,6 @@ pub fn iter_chunks(&self, range: I) -> LensIter { LensIter { cursor: Cursor::new(&self.0, start), - ix: 0, end, } } @@ -199,11 +196,11 @@ fn from_base_units(l: &LensLeaf, in_base_units: usize) -> usize { accum } - fn is_boundary(l: &LensLeaf, offset: usize) -> bool { + fn is_boundary(_l: &LensLeaf, _offset: usize) -> bool { true } - fn prev(l: &LensLeaf, offset: usize) -> Option { + fn prev(_l: &LensLeaf, offset: usize) -> Option { if offset == 0 { None } else { diff --git a/lapce-core/src/style.rs b/lapce-core/src/style.rs index d2c091c1..a6bb2b33 100644 --- a/lapce-core/src/style.rs +++ b/lapce-core/src/style.rs @@ -182,7 +182,6 @@ pub fn highlight<'a>( tree.clone(), source, self, - cancellation_flag, &mut injection_callback, config, 0, @@ -387,7 +386,6 @@ fn new Option<&'a HighlightConfiguration> + 'a>( tree: Tree, source: &'a [u8], highlighter: &mut Highlighter, - cancellation_flag: Option<&'a AtomicUsize>, injection_callback: &mut F, mut config: &'a HighlightConfiguration, mut depth: usize, @@ -779,7 +777,6 @@ fn next(&mut self) -> Option { self.tree.clone(), self.source, self.highlighter, - self.cancellation_flag, &mut self.injection_callback, config, self.layers[0].depth + 1, @@ -817,14 +814,11 @@ fn next(&mut self) -> Option { for prop in layer.config.query.property_settings(match_.pattern_index) { - match prop.key.as_ref() { - "local.scope-inherits" => { - scope.inherits = prop - .value - .as_ref() - .map_or(true, |r| r.as_ref() == "true"); - } - _ => {} + if prop.key.as_ref() == "local.scope-inherits" { + scope.inherits = prop + .value + .as_ref() + .map_or(true, |r| r.as_ref() == "true"); } } layer.scope_stack.push(scope); @@ -1154,6 +1148,12 @@ fn add_text<'a, F>( } } +impl Default for HtmlRenderer { + fn default() -> Self { + Self::new() + } +} + fn injection_for_match<'a>( config: &HighlightConfiguration, query: &'a Query, diff --git a/lapce-core/src/syntax.rs b/lapce-core/src/syntax.rs index 67f9b427..3d83ef4e 100644 --- a/lapce-core/src/syntax.rs +++ b/lapce-core/src/syntax.rs @@ -2,12 +2,11 @@ cell::RefCell, collections::{HashMap, HashSet}, path::Path, - rc::Rc, sync::Arc, }; use itertools::Itertools; -use tree_sitter::{Parser, Point, Query, QueryCursor, Tree}; +use tree_sitter::{Node, Parser, Point, Tree}; use xi_rope::{ spans::{Spans, SpansBuilder}, Interval, Rope, RopeDelta, @@ -16,7 +15,7 @@ use crate::{ language::LapceLanguage, lens::{Lens, LensBuilder}, - style::{Highlight, HighlightEvent, Highlighter, LineStyle, Style, SCOPES}, + style::{Highlight, HighlightEvent, Highlighter, Style, SCOPES}, }; thread_local! { @@ -34,7 +33,7 @@ pub struct Syntax { pub normal_lines: Vec, pub line_height: usize, pub lens_height: usize, - pub styles: Option>, + pub styles: Option>>, } impl Syntax { @@ -188,7 +187,7 @@ fn traverse(point: Point, text: &str) -> Point { } highlights.build() }); - Some(styles) + Some(Arc::new(styles)) } else { None }; @@ -255,6 +254,99 @@ pub fn lens_from_normal_lines( } builder.build() } + + pub fn find_matching_pair(&self, offset: usize) -> Option { + let tree = self.tree.as_ref()?; + let node = tree + .root_node() + .descendant_for_byte_range(offset, offset + 1)?; + let mut chars = node.kind().chars(); + let char = chars.next()?; + let char = matching_char(char)?; + let tag = &char.to_string(); + + if let Some(offset) = self.find_tag_in_siblings(node, true, tag) { + return Some(offset); + } + if let Some(offset) = self.find_tag_in_siblings(node, false, tag) { + return Some(offset); + } + None + } + + pub fn find_tag( + &self, + offset: usize, + previous: bool, + tag: &str, + ) -> Option { + let tree = self.tree.as_ref()?; + let node = tree + .root_node() + .descendant_for_byte_range(offset, offset + 1)?; + + if let Some(offset) = self.find_tag_in_siblings(node, previous, tag) { + return Some(offset); + } + + if let Some(offset) = self.find_tag_in_children(node, tag) { + return Some(offset); + } + + let mut node = node; + while let Some(parent) = node.parent() { + if let Some(offset) = self.find_tag_in_siblings(parent, previous, tag) { + return Some(offset); + } + node = parent; + } + None + } + + fn find_tag_in_siblings( + &self, + node: Node, + previous: bool, + tag: &str, + ) -> Option { + let mut node = node; + while let Some(sibling) = if previous { + node.prev_sibling() + } else { + node.next_sibling() + } { + if sibling.kind() == tag { + let offset = sibling.start_byte(); + return Some(offset); + } + node = sibling; + } + None + } + + fn find_tag_in_children(&self, node: Node, tag: &str) -> Option { + for i in 0..node.child_count() { + if let Some(child) = node.child(i) { + if child.kind() == tag { + let offset = child.start_byte(); + return Some(offset); + } + } + } + None + } +} + +pub fn matching_char(c: char) -> Option { + Some(match c { + '{' => '}', + '}' => '{', + '(' => ')', + ')' => '(', + '[' => ']', + ']' => '[', + _ => return None, + }) } #[cfg(test)] diff --git a/lapce-data/Cargo.toml b/lapce-data/Cargo.toml index ab544bc5..d0128dd3 100644 --- a/lapce-data/Cargo.toml +++ b/lapce-data/Cargo.toml @@ -34,11 +34,6 @@ jsonrpc-lite = "0.5.0" bit-vec = "0.5.0" parking_lot = { version = "0.11.0", features = ["deadlock_detection"] } include_dir = "0.6.0" -tree-sitter = "0.20.2" -tree-sitter-highlight = "0.20.1" -tree-sitter-rust = "0.20.0" -tree-sitter-go = "0.19.1" -tree-sitter-javascript = "0.20.0" anyhow = "1.0.32" strum = "0.19" strum_macros = "0.19" @@ -48,7 +43,6 @@ serde_json = "1.0" notify = "5.0.0-pre.13" xi-rope = { git = "https://github.com/lapce/xi-editor", features = ["serde"] } xi-unicode = "0.3.0" -fzyr = "0.1.2" fuzzy-matcher = "0.3.7" uuid = { version = "0.7.4", features = ["v4"] } lsp-types = { version = "0.89.2", features = ["proposed"] } diff --git a/lapce-data/src/buffer.rs b/lapce-data/src/buffer.rs index a8359f3a..5fed61b4 100644 --- a/lapce-data/src/buffer.rs +++ b/lapce-data/src/buffer.rs @@ -1,18 +1,15 @@ -use crossbeam_channel::Sender; +use druid::PaintCtx; use druid::{piet::PietTextLayout, Vec2}; use druid::{ - piet::{PietText, Text, TextAttribute, TextLayoutBuilder}, + piet::{Text, TextAttribute, TextLayoutBuilder}, Data, EventCtx, ExtEventSink, Target, WidgetId, WindowId, }; -use druid::{PaintCtx, Point}; -use language::{new_highlight_config, LapceLanguage}; -use lapce_core::style::{line_styles, LineStyle, LineStyles}; +use lapce_core::style::{line_styles, LineStyle, LineStyles, Style}; use lapce_core::syntax::Syntax; use lapce_proxy::dispatch::{BufferHeadResponse, NewBufferResponse}; use lsp_types::SemanticTokensLegend; use lsp_types::SemanticTokensServerCapabilities; use lsp_types::{CodeActionResponse, Position}; -use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use std::cell::RefCell; use std::cmp::{self, Ordering}; @@ -22,29 +19,20 @@ use std::str::FromStr; use std::sync::atomic::{self, AtomicU64}; use std::{borrow::Cow, collections::BTreeSet, path::PathBuf, sync::Arc, thread}; -use tree_sitter::{Node, Tree}; -use tree_sitter_highlight::{ - Highlight, HighlightConfiguration, HighlightEvent, Highlighter, -}; use unicode_width::UnicodeWidthChar; use xi_rope::{ - interval::IntervalBounds, - multiset::Subset, - rope::Rope, - spans::{Spans, SpansBuilder}, - Cursor, Delta, DeltaBuilder, Interval, RopeDelta, RopeInfo, + multiset::Subset, rope::Rope, spans::Spans, Cursor, Delta, DeltaBuilder, + Interval, RopeDelta, RopeInfo, }; use xi_unicode::EmojiExt; use crate::config::{Config, LapceTheme}; use crate::editor::EditorLocationNew; use crate::find::FindProgress; -use crate::language::SCOPES; use crate::{ command::LapceUICommand, command::LAPCE_UI_COMMAND, find::Find, - language, movement::{ColPosition, LinePosition, Movement, SelRegion, Selection}, proxy::LapceProxy, state::{Counter, Mode}, @@ -120,26 +108,6 @@ pub struct HighlightTextLayout { pub highlights: Vec<(usize, usize, String)>, } -#[derive(Clone, Debug, PartialEq)] -pub struct Style { - pub fg_color: Option, -} - -pub enum UpdateEvent { - Buffer(BufferUpdate), - SemanticTokens(BufferUpdate, Vec<(usize, usize, String)>), -} - -pub struct BufferUpdate { - pub id: BufferId, - pub path: PathBuf, - pub rope: Rope, - pub rev: u64, - pub language: LapceLanguage, - pub highlights: Arc>, - pub semantic_tokens: bool, -} - #[derive(Clone, Copy, Debug, PartialEq)] pub enum EditType { Other, @@ -244,15 +212,9 @@ pub struct Buffer { pub id: BufferId, pub rope: Rope, pub content: BufferContent, - pub line_styles: Rc>>>>>, - pub styles: Arc>, - pub semantic_tokens: bool, - pub language: Option, pub syntax: Option, pub new_line_styles: Rc>, - pub semantic_styles: Option>, - pub highlighter: Arc>, - pub highlight: Option>>, + pub semantic_styles: Option>>, pub max_len: usize, pub max_len_line: usize, pub num_lines: usize, @@ -262,12 +224,9 @@ pub struct Buffer { pub loaded: bool, pub start_to_load: Rc>, pub local: bool, - update_sender: Arc>, pub histories: im::HashMap, pub history_styles: im::HashMap>>, - pub history_line_styles: Rc< - RefCell>>>>, - >, + pub history_line_styles: Rc>>, pub history_changes: im::HashMap>>, pub find: Rc>, @@ -289,7 +248,6 @@ pub struct Buffer { pub scroll_offset: Vec2, pub code_actions: im::HashMap, - pub syntax_tree: Option>, tab_id: WidgetId, event_sink: ExtEventSink, @@ -298,35 +256,24 @@ pub struct Buffer { impl Buffer { pub fn new( content: BufferContent, - update_sender: Arc>, tab_id: WidgetId, event_sink: ExtEventSink, ) -> Self { let rope = Rope::from(""); - let language = match &content { - BufferContent::File(path) => LapceLanguage::from_path(path), - BufferContent::Local(_) => None, - }; let syntax = match &content { BufferContent::File(path) => Syntax::init(path), BufferContent::Local(_) => None, }; - let buffer = Self { + + Self { id: BufferId::next(), rope, - highlighter: Arc::new(Mutex::new(Highlighter::new())), - highlight: language - .map(|l| Arc::new(Mutex::new(new_highlight_config(l)))), - language, syntax, new_line_styles: Rc::new(RefCell::new(HashMap::new())), semantic_styles: None, content, - styles: Arc::new(SpansBuilder::new(0).build()), - line_styles: Rc::new(RefCell::new(Vec::new())), find: Rc::new(RefCell::new(Find::new(0))), find_progress: Rc::new(RefCell::new(FindProgress::Ready)), - semantic_tokens: false, max_len: 0, max_len_line: 0, num_lines: 0, @@ -335,7 +282,6 @@ pub fn new( start_to_load: Rc::new(RefCell::new(false)), loaded: false, dirty: false, - update_sender, local: false, histories: im::HashMap::new(), history_styles: im::HashMap::new(), @@ -364,12 +310,9 @@ pub fn new( scroll_offset: Vec2::ZERO, code_actions: im::HashMap::new(), - syntax_tree: None, tab_id, event_sink, - }; - *buffer.line_styles.borrow_mut() = vec![None; buffer.num_lines()]; - buffer + } } pub fn set_local(mut self) -> Self { @@ -392,7 +335,6 @@ pub fn reset_revs(&mut self) { self.deletes_from_union = Subset::new(0); self.undone_groups = BTreeSet::new(); self.tombstones = Rope::default(); - self.syntax_tree = None; } pub fn load_history(&mut self, version: &str, content: Rope) { @@ -420,41 +362,35 @@ pub fn load_content(&mut self, content: &str) { self.max_len = max_len; self.max_len_line = max_len_line; self.num_lines = self.num_lines(); - *self.line_styles.borrow_mut() = vec![None; self.num_lines()]; self.loaded = true; self.notify_update(None); } fn retrieve_history_styles(&self, version: &str, content: Rope) { if let BufferContent::File(path) = &self.content { - if let Some(highlight_config) = self.highlight.clone() { - let highlighter = self.highlighter.clone(); - let id = self.id; - let path = path.clone(); - let event_sink = self.event_sink.clone(); - let tab_id = self.tab_id; - let version = version.to_string(); - rayon::spawn(move || { - let mut highlight_config = highlight_config.lock(); - let mut highlighter = highlighter.lock(); - let highlights = rope_styles( - content, - &mut highlighter, - &mut highlight_config, - ); - - let _ = event_sink.submit_command( - LAPCE_UI_COMMAND, - LapceUICommand::UpdateHistoryStyle { - id, - path, - history: version, - highlights, - }, - Target::Widget(tab_id), - ); - }); - } + let id = self.id; + let path = path.clone(); + let tab_id = self.tab_id; + let version = version.to_string(); + let event_sink = self.event_sink.clone(); + rayon::spawn(move || { + if let Some(syntax) = + Syntax::init(&path).map(|s| s.parse(0, content, None)) + { + if let Some(styles) = syntax.styles { + let _ = event_sink.submit_command( + LAPCE_UI_COMMAND, + LapceUICommand::UpdateHistoryStyle { + id, + path, + history: version, + highlights: styles, + }, + Target::Widget(tab_id), + ); + } + } + }); } } @@ -500,19 +436,6 @@ fn trigger_history_change(&self) { } pub fn notify_update(&self, delta: Option<&RopeDelta>) { - if let Some(language) = self.language { - if let BufferContent::File(path) = &self.content { - let _ = self.update_sender.send(UpdateEvent::Buffer(BufferUpdate { - id: self.id, - path: path.clone(), - rope: self.rope.clone(), - rev: self.rev, - language, - highlights: self.styles.clone(), - semantic_tokens: self.semantic_tokens, - })); - } - } self.trigger_syntax_change(delta); self.trigger_history_change(); } @@ -810,7 +733,7 @@ fn get_hisotry_line_styles( &self, history: &str, line: usize, - ) -> Option>> { + ) -> Option>> { let rope = self.histories.get(history)?; let styles = self.history_styles.get(history)?; let mut cached_line_styles = self.history_line_styles.borrow_mut(); @@ -822,7 +745,7 @@ fn get_hisotry_line_styles( let start_offset = rope.offset_of_line(line); let end_offset = rope.offset_of_line(line + 1); - let line_styles: Vec<(usize, usize, Style)> = styles + let line_styles: Vec = styles .iter_chunks(start_offset..end_offset) .filter_map(|(iv, style)| { let start = iv.start(); @@ -830,15 +753,15 @@ fn get_hisotry_line_styles( if start > end_offset || end < start_offset { None } else { - Some(( - if start > start_offset { + Some(LineStyle { + start: if start > start_offset { start - start_offset } else { 0 }, - end - start_offset, - style.clone(), - )) + end: end - start_offset, + style: style.clone(), + }) } }) .collect(); @@ -847,6 +770,14 @@ fn get_hisotry_line_styles( Some(line_styles) } + pub fn styles(&self) -> Option<&Arc>> { + let styles = self + .semantic_styles + .as_ref() + .or_else(|| self.syntax.as_ref().and_then(|s| s.styles.as_ref())); + styles + } + fn line_style(&self, line: usize) -> Arc> { if self.new_line_styles.borrow().get(&line).is_none() { let styles = self @@ -864,42 +795,6 @@ fn line_style(&self, line: usize) -> Arc> { self.new_line_styles.borrow().get(&line).cloned().unwrap() } - fn get_line_styles(&self, line: usize) -> Arc> { - if let Some(line_styles) = - self.line_styles.borrow().get(line).and_then(|s| s.as_ref()) - { - return line_styles.clone(); - } - let start_offset = self.offset_of_line(line); - let end_offset = self.offset_of_line(line + 1); - let line_styles: Vec<(usize, usize, Style)> = self - .styles - .iter_chunks(start_offset..end_offset) - .filter_map(|(iv, style)| { - let start = iv.start(); - let end = iv.end(); - if start > end_offset || end < start_offset { - None - } else { - Some(( - if start > start_offset { - start - start_offset - } else { - 0 - }, - end - start_offset, - style.clone(), - )) - } - }) - .collect(); - let line_styles = Arc::new(line_styles); - if let Some(style) = self.line_styles.borrow_mut().get_mut(line) { - *style = Some(line_styles.clone()); - } - line_styles - } - pub fn history_text_layout( &self, ctx: &mut PaintCtx, @@ -927,13 +822,13 @@ pub fn history_text_layout( ); if let Some(styles) = self.get_hisotry_line_styles(history, line) { - for (start, end, style) in styles.iter() { - if let Some(fg_color) = style.fg_color.as_ref() { + for line_style in styles.iter() { + if let Some(fg_color) = line_style.style.fg_color.as_ref() { if let Some(fg_color) = config.get_color(&("style.".to_string() + fg_color)) { layout_builder = layout_builder.range_attribute( - start..end, + line_style.start..line_style.end, TextAttribute::TextColor(fg_color.clone()), ); } @@ -1621,8 +1516,8 @@ pub fn move_offset( (new_offset, ColPosition::Col(col)) } Movement::NextUnmatched(c) => { - if self.syntax_tree.is_some() { - let new_offset = self + if let Some(syntax) = self.syntax.as_ref() { + let new_offset = syntax .find_tag(offset, false, &c.to_string()) .unwrap_or(offset); let (_, col) = @@ -1641,8 +1536,8 @@ pub fn move_offset( } } Movement::PreviousUnmatched(c) => { - if self.syntax_tree.is_some() { - let new_offset = self + if let Some(syntax) = self.syntax.as_ref() { + let new_offset = syntax .find_tag(offset, true, &c.to_string()) .unwrap_or(offset); let (_, col) = @@ -1658,9 +1553,9 @@ pub fn move_offset( } } Movement::MatchPairs => { - if self.syntax_tree.is_some() { + if let Some(syntax) = self.syntax.as_ref() { let new_offset = - self.find_matching_pair(offset).unwrap_or(offset); + syntax.find_matching_pair(offset).unwrap_or(offset); let (_, col) = self.offset_to_line_col(new_offset, config.editor.tab_width); (new_offset, ColPosition::Col(col)) @@ -1677,89 +1572,13 @@ pub fn move_offset( } pub fn previous_unmatched(&self, c: char, offset: usize) -> Option { - if self.syntax_tree.is_some() { - self.find_tag(offset, true, &c.to_string()) + if let Some(syntax) = self.syntax.as_ref() { + syntax.find_tag(offset, true, &c.to_string()) } else { WordCursor::new(&self.rope, offset).previous_unmatched(c) } } - fn find_matching_pair(&self, offset: usize) -> Option { - let tree = self.syntax_tree.as_ref()?; - let node = tree - .root_node() - .descendant_for_byte_range(offset, offset + 1)?; - let mut chars = node.kind().chars(); - let char = chars.next()?; - let char = matching_char(char)?; - let tag = &char.to_string(); - - if let Some(offset) = self.find_tag_in_siblings(node, true, tag) { - return Some(offset); - } - if let Some(offset) = self.find_tag_in_siblings(node, false, tag) { - return Some(offset); - } - None - } - - fn find_tag(&self, offset: usize, previous: bool, tag: &str) -> Option { - let tree = self.syntax_tree.as_ref()?; - let node = tree - .root_node() - .descendant_for_byte_range(offset, offset + 1)?; - - if let Some(offset) = self.find_tag_in_siblings(node, previous, tag) { - return Some(offset); - } - - if let Some(offset) = self.find_tag_in_children(node, tag) { - return Some(offset); - } - - let mut node = node; - while let Some(parent) = node.parent() { - if let Some(offset) = self.find_tag_in_siblings(parent, previous, tag) { - return Some(offset); - } - node = parent; - } - None - } - - fn find_tag_in_siblings( - &self, - node: Node, - previous: bool, - tag: &str, - ) -> Option { - let mut node = node; - while let Some(sibling) = if previous { - node.prev_sibling() - } else { - node.next_sibling() - } { - if sibling.kind() == tag { - let offset = sibling.start_byte(); - return Some(offset); - } - node = sibling; - } - None - } - - fn find_tag_in_children(&self, node: Node, tag: &str) -> Option { - for i in 0..node.child_count() { - if let Some(child) = node.child(i) { - if child.kind() == tag { - let offset = child.start_byte(); - return Some(offset); - } - } - } - None - } - pub fn prev_code_boundary(&self, offset: usize) -> usize { WordCursor::new(&self.rope, offset).prev_code_boundary() } @@ -1768,13 +1587,6 @@ pub fn next_code_boundary(&self, offset: usize) -> usize { WordCursor::new(&self.rope, offset).next_code_boundary() } - pub fn update_syntax_tree(&mut self, rev: u64, tree: Tree) { - if rev != self.rev { - return; - } - self.syntax_tree = Some(Arc::new(tree)); - } - pub fn update_history_changes( &mut self, rev: u64, @@ -1787,22 +1599,6 @@ pub fn update_history_changes( self.history_changes.insert(history.to_string(), changes); } - pub fn update_styles( - &mut self, - rev: u64, - highlights: Spans