From d04b8833b2280409562b18d13d722ddefbbd33a5 Mon Sep 17 00:00:00 2001 From: Dimitri Sabadie Date: Fri, 1 Mar 2024 23:26:55 +0100 Subject: [PATCH] (wip) Update to tree-sitter-0.21. This is a bit premature (see #250) currently, so WIP. --- Cargo.lock | 242 +++++++++++++++------------- kak-tree-sitter/Cargo.toml | 9 +- kak-tree-sitter/src/highlighting.rs | 216 ++++++++++++------------- kak-tree-sitter/src/languages.rs | 9 +- 4 files changed, 247 insertions(+), 229 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c548ae..c7a5b35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] name = "anstream" -version = "0.6.7" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" dependencies = [ "anstyle", "anstyle-parse", @@ -27,36 +27,36 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.2" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -67,18 +67,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" [[package]] name = "cfg-if" @@ -88,9 +85,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" dependencies = [ "clap_builder", "clap_derive", @@ -98,9 +95,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", @@ -163,9 +160,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] [[package]] name = "dirs" @@ -190,9 +190,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "equivalent" @@ -202,9 +202,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" @@ -225,9 +225,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "indexmap" -version = "2.0.0" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown", @@ -244,9 +244,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "kak-tree-sitter" @@ -268,7 +268,6 @@ dependencies = [ "thiserror", "tree-sitter", "tree-sitter-highlight", - "tree-sitter-rust", "unicode-segmentation", ] @@ -307,12 +306,23 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2caa5afb8bf9f3a2652760ce7d4f62d21c4d5a423e68466fca30df82f2330164" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.0", + "windows-targets 0.52.4", +] + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.2", + "libc", + "redox_syscall", ] [[package]] @@ -323,9 +333,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.6.3" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mio" @@ -345,16 +355,22 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.2", "cfg-if", "libc", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num_threads" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" dependencies = [ "libc", ] @@ -365,11 +381,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -385,29 +407,29 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.9.5" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -417,9 +439,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -428,15 +450,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "serde" @@ -498,9 +520,9 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "syn" -version = "2.0.48" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -529,14 +551,16 @@ dependencies = [ [[package]] name = "time" -version = "0.3.28" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa", "libc", + "num-conv", "num_threads", + "powerfmt", "serde", "time-core", "time-macros", @@ -544,16 +568,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.14" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -580,9 +605,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.4" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" +checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" dependencies = [ "indexmap", "serde", @@ -593,9 +618,9 @@ dependencies = [ [[package]] name = "tree-sitter" -version = "0.20.10" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d" +checksum = "705bf7c0958d0171dd7d3a6542f2f4f21d87ed5f1dc8db52919d3a6bed9a359a" dependencies = [ "cc", "regex", @@ -603,30 +628,21 @@ dependencies = [ [[package]] name = "tree-sitter-highlight" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "042342584c5a7a0b833d9fc4e2bdab3f9868ddc6c4b339a1e01451c6720868bc" +checksum = "2f8c0df4e17827db04b150377bc992fc59a4017e4177626640e91053c53b6aa0" dependencies = [ + "lazy_static", "regex", "thiserror", "tree-sitter", ] -[[package]] -name = "tree-sitter-rust" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0832309b0b2b6d33760ce5c0e818cb47e1d72b468516bfe4134408926fa7594" -dependencies = [ - "cc", - "tree-sitter", -] - [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" @@ -661,7 +677,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -681,17 +697,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -702,9 +718,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -714,9 +730,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -726,9 +742,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -738,9 +754,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -750,9 +766,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -762,9 +778,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -774,15 +790,15 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winnow" -version = "0.5.15" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" dependencies = [ "memchr", ] diff --git a/kak-tree-sitter/Cargo.toml b/kak-tree-sitter/Cargo.toml index c584061..f82777f 100644 --- a/kak-tree-sitter/Cargo.toml +++ b/kak-tree-sitter/Cargo.toml @@ -27,9 +27,10 @@ serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" simple_logger = "4.3.3" thiserror = "1.0.57" -tree-sitter = "0.20.10" -tree-sitter-highlight = "0.20.1" +tree-sitter = "0.21" +tree-sitter-highlight = "0.21" unicode-segmentation = "1.11.0" -[dev-dependencies] -tree-sitter-rust = "0.20.4" +# #250: disabled for now as tree-sitter-rust hasn’t updated to tree-sitter-0.21 just yet +#[dev-dependencies] +#tree-sitter-rust = "0.20.4" diff --git a/kak-tree-sitter/src/highlighting.rs b/kak-tree-sitter/src/highlighting.rs index 15c7532..9d6994e 100644 --- a/kak-tree-sitter/src/highlighting.rs +++ b/kak-tree-sitter/src/highlighting.rs @@ -162,7 +162,6 @@ where #[cfg(test)] mod tests { - use tree_sitter_highlight::{Highlight, HighlightConfiguration, HighlightEvent, Highlighter}; use unicode_segmentation::UnicodeSegmentation; use super::ByteLineColMapper; @@ -279,111 +278,112 @@ mod tests { assert_eq!(mapper.col_byte(), 0); } - #[test] - fn kak_hl_ranges_from_iter() { - let source = "fn foo(a: i32, b: /* ® */ impl Into>) {}"; - let hl_names = vec![ - "constant", - "function", - "keyword", - "variable", - "punctuation", - "type", - "comment", - ]; - - let mut hl_conf = HighlightConfiguration::new( - tree_sitter_rust::language(), - tree_sitter_rust::HIGHLIGHT_QUERY, - tree_sitter_rust::INJECTIONS_QUERY, - "", - ) - .unwrap(); - hl_conf.configure(&hl_names); - - let mut hl = Highlighter::new(); - let events: Vec<_> = hl - .highlight(&hl_conf, source.as_bytes(), None, |_| None) - .unwrap() - .flatten() - .collect(); - - assert_eq!(events.len(), 70); - - assert!(matches!( - events[..], - [ - HighlightEvent::HighlightStart(Highlight(2)), - HighlightEvent::Source { start: 0, end: 2 }, - HighlightEvent::HighlightEnd, - HighlightEvent::Source { start: 2, end: 3 }, - HighlightEvent::HighlightStart(Highlight(1)), - HighlightEvent::Source { start: 3, end: 6 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 6, end: 7 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(3)), - HighlightEvent::Source { start: 7, end: 8 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 8, end: 9 }, - HighlightEvent::HighlightEnd, - HighlightEvent::Source { start: 9, end: 10 }, - HighlightEvent::HighlightStart(Highlight(5)), - HighlightEvent::Source { start: 10, end: 13 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 13, end: 14 }, - HighlightEvent::HighlightEnd, - HighlightEvent::Source { start: 14, end: 15 }, - HighlightEvent::HighlightStart(Highlight(3)), - HighlightEvent::Source { start: 15, end: 16 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 16, end: 17 }, - HighlightEvent::HighlightEnd, - HighlightEvent::Source { start: 17, end: 18 }, - HighlightEvent::HighlightStart(Highlight(6)), - HighlightEvent::Source { start: 18, end: 26 }, - HighlightEvent::HighlightEnd, - HighlightEvent::Source { start: 26, end: 27 }, - HighlightEvent::HighlightStart(Highlight(2)), - HighlightEvent::Source { start: 27, end: 31 }, - HighlightEvent::HighlightEnd, - HighlightEvent::Source { start: 31, end: 32 }, - HighlightEvent::HighlightStart(Highlight(5)), - HighlightEvent::Source { start: 32, end: 36 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 36, end: 37 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(5)), - HighlightEvent::Source { start: 37, end: 43 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 43, end: 44 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(5)), - HighlightEvent::Source { start: 44, end: 50 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 50, end: 51 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 51, end: 52 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 52, end: 53 }, - HighlightEvent::HighlightEnd, - HighlightEvent::Source { start: 53, end: 54 }, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 54, end: 55 }, - HighlightEvent::HighlightEnd, - HighlightEvent::HighlightStart(Highlight(4)), - HighlightEvent::Source { start: 55, end: 56 }, - HighlightEvent::HighlightEnd - ] - )); - } + // #250: disabled for now + // #[test] + // fn kak_hl_ranges_from_iter() { + // let source = "fn foo(a: i32, b: /* ® */ impl Into>) {}"; + // let hl_names = vec![ + // "constant", + // "function", + // "keyword", + // "variable", + // "punctuation", + // "type", + // "comment", + // ]; + + // let mut hl_conf = HighlightConfiguration::new( + // tree_sitter_rust::language(), + // tree_sitter_rust::HIGHLIGHT_QUERY, + // tree_sitter_rust::INJECTIONS_QUERY, + // "", + // ) + // .unwrap(); + // hl_conf.configure(&hl_names); + + // let mut hl = Highlighter::new(); + // let events: Vec<_> = hl + // .highlight(&hl_conf, source.as_bytes(), None, |_| None) + // .unwrap() + // .flatten() + // .collect(); + + // assert_eq!(events.len(), 70); + + // assert!(matches!( + // events[..], + // [ + // HighlightEvent::HighlightStart(Highlight(2)), + // HighlightEvent::Source { start: 0, end: 2 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::Source { start: 2, end: 3 }, + // HighlightEvent::HighlightStart(Highlight(1)), + // HighlightEvent::Source { start: 3, end: 6 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 6, end: 7 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(3)), + // HighlightEvent::Source { start: 7, end: 8 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 8, end: 9 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::Source { start: 9, end: 10 }, + // HighlightEvent::HighlightStart(Highlight(5)), + // HighlightEvent::Source { start: 10, end: 13 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 13, end: 14 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::Source { start: 14, end: 15 }, + // HighlightEvent::HighlightStart(Highlight(3)), + // HighlightEvent::Source { start: 15, end: 16 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 16, end: 17 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::Source { start: 17, end: 18 }, + // HighlightEvent::HighlightStart(Highlight(6)), + // HighlightEvent::Source { start: 18, end: 26 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::Source { start: 26, end: 27 }, + // HighlightEvent::HighlightStart(Highlight(2)), + // HighlightEvent::Source { start: 27, end: 31 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::Source { start: 31, end: 32 }, + // HighlightEvent::HighlightStart(Highlight(5)), + // HighlightEvent::Source { start: 32, end: 36 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 36, end: 37 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(5)), + // HighlightEvent::Source { start: 37, end: 43 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 43, end: 44 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(5)), + // HighlightEvent::Source { start: 44, end: 50 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 50, end: 51 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 51, end: 52 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 52, end: 53 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::Source { start: 53, end: 54 }, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 54, end: 55 }, + // HighlightEvent::HighlightEnd, + // HighlightEvent::HighlightStart(Highlight(4)), + // HighlightEvent::Source { start: 55, end: 56 }, + // HighlightEvent::HighlightEnd + // ] + // )); + // } } diff --git a/kak-tree-sitter/src/languages.rs b/kak-tree-sitter/src/languages.rs index 08cd7af..50dd247 100644 --- a/kak-tree-sitter/src/languages.rs +++ b/kak-tree-sitter/src/languages.rs @@ -25,8 +25,8 @@ pub struct Language { } impl Language { - pub fn lang(&self) -> tree_sitter::Language { - self.ts_lang + pub fn lang(&self) -> &tree_sitter::Language { + &self.ts_lang } } @@ -85,7 +85,8 @@ impl Languages { let queries = Queries::load_from_dir(queries_dir); let mut hl_config = HighlightConfiguration::new( - ts_lang, + ts_lang.clone(), + lang_name, queries.highlights.as_deref().unwrap_or(""), queries.injections.as_deref().unwrap_or(""), queries.locals.as_deref().unwrap_or(""), @@ -102,7 +103,7 @@ impl Languages { let textobject_query = queries .text_objects .as_deref() - .map(|q| Query::new(ts_lang, q).map(Some)) + .map(|q| Query::new(&ts_lang, q).map(Some)) .unwrap_or_else(|| Ok(None))?; let lang = Language {