├── .cargo └── config.toml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── plugin.toml ├── rust-logo.png ├── src └── main.rs └── volt.toml /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-wasi" 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # These are backup files generated by rustfmt 6 | **/*.rs.bk 7 | 8 | lapce-rust.wasm 9 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "adler" 7 | version = "1.0.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 10 | 11 | [[package]] 12 | name = "anyhow" 13 | version = "1.0.61" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "508b352bb5c066aac251f6daf6b36eccd03e8a88e8081cd44959ea277a3af9a8" 16 | 17 | [[package]] 18 | name = "autocfg" 19 | version = "1.1.0" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 22 | 23 | [[package]] 24 | name = "bitflags" 25 | version = "1.3.2" 26 | source = "registry+https://github.com/rust-lang/crates.io-index" 27 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 28 | 29 | [[package]] 30 | name = "bytes" 31 | version = "1.2.1" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" 34 | 35 | [[package]] 36 | name = "cfg-if" 37 | version = "1.0.0" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 40 | 41 | [[package]] 42 | name = "crc32fast" 43 | version = "1.3.0" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" 46 | dependencies = [ 47 | "cfg-if", 48 | ] 49 | 50 | [[package]] 51 | name = "flate2" 52 | version = "1.0.22" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" 55 | dependencies = [ 56 | "cfg-if", 57 | "crc32fast", 58 | "libc", 59 | "miniz_oxide", 60 | ] 61 | 62 | [[package]] 63 | name = "fnv" 64 | version = "1.0.7" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 67 | 68 | [[package]] 69 | name = "form_urlencoded" 70 | version = "1.0.1" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 73 | dependencies = [ 74 | "matches", 75 | "percent-encoding", 76 | ] 77 | 78 | [[package]] 79 | name = "http" 80 | version = "0.2.8" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" 83 | dependencies = [ 84 | "bytes", 85 | "fnv", 86 | "itoa", 87 | ] 88 | 89 | [[package]] 90 | name = "idna" 91 | version = "0.2.3" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 94 | dependencies = [ 95 | "matches", 96 | "unicode-bidi", 97 | "unicode-normalization", 98 | ] 99 | 100 | [[package]] 101 | name = "itoa" 102 | version = "1.0.1" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" 105 | 106 | [[package]] 107 | name = "jsonrpc-lite" 108 | version = "0.5.0" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | checksum = "a98d245f26984add78277a5306ca0cf774863d4eddb4912b31d94ee3fa1a22d4" 111 | dependencies = [ 112 | "serde", 113 | "serde_derive", 114 | "serde_json", 115 | ] 116 | 117 | [[package]] 118 | name = "lapce-plugin" 119 | version = "0.1.1" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "1c169cb693c2c10ff40addb0429697d90f506c938d405932b2c46e529bcb555c" 122 | dependencies = [ 123 | "anyhow", 124 | "bytes", 125 | "http", 126 | "jsonrpc-lite", 127 | "lapce-wasi-experimental-http", 128 | "once_cell", 129 | "psp-types", 130 | "serde", 131 | "serde_json", 132 | ] 133 | 134 | [[package]] 135 | name = "lapce-rust" 136 | version = "0.3.1932" 137 | dependencies = [ 138 | "anyhow", 139 | "flate2", 140 | "lapce-plugin", 141 | "serde", 142 | "serde_json", 143 | ] 144 | 145 | [[package]] 146 | name = "lapce-wasi-experimental-http" 147 | version = "0.10.0" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | checksum = "caf7608ac13ab536e2481cdbe0cb4e6ecf34f19e0b3dcd6bcd002fe959ce810e" 150 | dependencies = [ 151 | "anyhow", 152 | "bytes", 153 | "http", 154 | "thiserror", 155 | "tracing", 156 | ] 157 | 158 | [[package]] 159 | name = "libc" 160 | version = "0.2.126" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" 163 | 164 | [[package]] 165 | name = "log" 166 | version = "0.4.17" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 169 | dependencies = [ 170 | "cfg-if", 171 | ] 172 | 173 | [[package]] 174 | name = "lsp-types" 175 | version = "0.93.0" 176 | source = "registry+https://github.com/rust-lang/crates.io-index" 177 | checksum = "70c74e2173b2b31f8655d33724b4b45ac13f439386f66290f539c22b144c2212" 178 | dependencies = [ 179 | "bitflags", 180 | "serde", 181 | "serde_json", 182 | "serde_repr", 183 | "url", 184 | ] 185 | 186 | [[package]] 187 | name = "matches" 188 | version = "0.1.9" 189 | source = "registry+https://github.com/rust-lang/crates.io-index" 190 | checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" 191 | 192 | [[package]] 193 | name = "miniz_oxide" 194 | version = "0.4.4" 195 | source = "registry+https://github.com/rust-lang/crates.io-index" 196 | checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" 197 | dependencies = [ 198 | "adler", 199 | "autocfg", 200 | ] 201 | 202 | [[package]] 203 | name = "once_cell" 204 | version = "1.13.0" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" 207 | 208 | [[package]] 209 | name = "percent-encoding" 210 | version = "2.1.0" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 213 | 214 | [[package]] 215 | name = "pin-project-lite" 216 | version = "0.2.9" 217 | source = "registry+https://github.com/rust-lang/crates.io-index" 218 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 219 | 220 | [[package]] 221 | name = "proc-macro2" 222 | version = "1.0.34" 223 | source = "registry+https://github.com/rust-lang/crates.io-index" 224 | checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" 225 | dependencies = [ 226 | "unicode-xid", 227 | ] 228 | 229 | [[package]] 230 | name = "psp-types" 231 | version = "0.1.0" 232 | source = "registry+https://github.com/rust-lang/crates.io-index" 233 | checksum = "7edd2a687afe6f35676710d6c949faa5d0be0a2098dd81bb9dea1922cce859de" 234 | dependencies = [ 235 | "lsp-types", 236 | "serde", 237 | "serde_json", 238 | ] 239 | 240 | [[package]] 241 | name = "quote" 242 | version = "1.0.10" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" 245 | dependencies = [ 246 | "proc-macro2", 247 | ] 248 | 249 | [[package]] 250 | name = "ryu" 251 | version = "1.0.9" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" 254 | 255 | [[package]] 256 | name = "serde" 257 | version = "1.0.132" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" 260 | dependencies = [ 261 | "serde_derive", 262 | ] 263 | 264 | [[package]] 265 | name = "serde_derive" 266 | version = "1.0.132" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" 269 | dependencies = [ 270 | "proc-macro2", 271 | "quote", 272 | "syn", 273 | ] 274 | 275 | [[package]] 276 | name = "serde_json" 277 | version = "1.0.73" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" 280 | dependencies = [ 281 | "itoa", 282 | "ryu", 283 | "serde", 284 | ] 285 | 286 | [[package]] 287 | name = "serde_repr" 288 | version = "0.1.9" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" 291 | dependencies = [ 292 | "proc-macro2", 293 | "quote", 294 | "syn", 295 | ] 296 | 297 | [[package]] 298 | name = "syn" 299 | version = "1.0.82" 300 | source = "registry+https://github.com/rust-lang/crates.io-index" 301 | checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" 302 | dependencies = [ 303 | "proc-macro2", 304 | "quote", 305 | "unicode-xid", 306 | ] 307 | 308 | [[package]] 309 | name = "thiserror" 310 | version = "1.0.32" 311 | source = "registry+https://github.com/rust-lang/crates.io-index" 312 | checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" 313 | dependencies = [ 314 | "thiserror-impl", 315 | ] 316 | 317 | [[package]] 318 | name = "thiserror-impl" 319 | version = "1.0.32" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" 322 | dependencies = [ 323 | "proc-macro2", 324 | "quote", 325 | "syn", 326 | ] 327 | 328 | [[package]] 329 | name = "tinyvec" 330 | version = "1.6.0" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 333 | dependencies = [ 334 | "tinyvec_macros", 335 | ] 336 | 337 | [[package]] 338 | name = "tinyvec_macros" 339 | version = "0.1.0" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 342 | 343 | [[package]] 344 | name = "tracing" 345 | version = "0.1.36" 346 | source = "registry+https://github.com/rust-lang/crates.io-index" 347 | checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" 348 | dependencies = [ 349 | "cfg-if", 350 | "log", 351 | "pin-project-lite", 352 | "tracing-attributes", 353 | "tracing-core", 354 | ] 355 | 356 | [[package]] 357 | name = "tracing-attributes" 358 | version = "0.1.22" 359 | source = "registry+https://github.com/rust-lang/crates.io-index" 360 | checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" 361 | dependencies = [ 362 | "proc-macro2", 363 | "quote", 364 | "syn", 365 | ] 366 | 367 | [[package]] 368 | name = "tracing-core" 369 | version = "0.1.29" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" 372 | dependencies = [ 373 | "once_cell", 374 | ] 375 | 376 | [[package]] 377 | name = "unicode-bidi" 378 | version = "0.3.8" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" 381 | 382 | [[package]] 383 | name = "unicode-normalization" 384 | version = "0.1.21" 385 | source = "registry+https://github.com/rust-lang/crates.io-index" 386 | checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" 387 | dependencies = [ 388 | "tinyvec", 389 | ] 390 | 391 | [[package]] 392 | name = "unicode-xid" 393 | version = "0.2.2" 394 | source = "registry+https://github.com/rust-lang/crates.io-index" 395 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 396 | 397 | [[package]] 398 | name = "url" 399 | version = "2.2.2" 400 | source = "registry+https://github.com/rust-lang/crates.io-index" 401 | checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" 402 | dependencies = [ 403 | "form_urlencoded", 404 | "idna", 405 | "matches", 406 | "percent-encoding", 407 | "serde", 408 | ] 409 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lapce-rust" 3 | version = "0.3.1932" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "1.0" 8 | flate2 = "1.0.22" 9 | serde_json = "1.0.59" 10 | serde = { version = "1.0", features = ["derive"] } 11 | lapce-plugin = "0.1.1" 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lapce-rust 2 | 3 | Lapce plugin for Rust programming language, which provides the LSP through [Rust-Analyzer](https://github.com/rust-lang/rust-analyzer) 4 | -------------------------------------------------------------------------------- /plugin.toml: -------------------------------------------------------------------------------- 1 | name = "lapce-rust" 2 | display-name = "Rust" 3 | description = "Rust for Lapce: powered by Rust Analyzer" 4 | version = "0.1.8" 5 | author = "Lapce" 6 | repository = "lapce/lapce-rust" 7 | wasm = "lapce-rust.wasm" 8 | 9 | [configuration] 10 | language_id = "rust" 11 | [configuration.options.diagnostics] 12 | enable = false 13 | enableExperimental = false 14 | -------------------------------------------------------------------------------- /rust-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lapce/lapce-rust/445c6a71b05d16095489d91925cad094b3284e10/rust-logo.png -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use std::{fs::File, path::PathBuf}; 2 | 3 | use anyhow::Result; 4 | use flate2::read::GzDecoder; 5 | use lapce_plugin::{ 6 | psp_types::{ 7 | lsp_types::{request::Initialize, DocumentFilter, InitializeParams, MessageType, Url}, 8 | Request, 9 | }, 10 | register_plugin, Http, LapcePlugin, PLUGIN_RPC, 11 | }; 12 | use serde::{Deserialize, Serialize}; 13 | use serde_json::Value; 14 | 15 | #[derive(Default)] 16 | struct State {} 17 | 18 | #[derive(Debug, Clone, Serialize, Deserialize)] 19 | pub struct PluginInfo { 20 | arch: String, 21 | os: String, 22 | configuration: Configuration, 23 | } 24 | 25 | #[derive(Debug, Clone, Serialize, Deserialize)] 26 | pub struct Configuration { 27 | language_id: String, 28 | options: Option, 29 | } 30 | 31 | register_plugin!(State); 32 | 33 | fn initialize(params: InitializeParams) -> Result<()> { 34 | let server_path = params 35 | .initialization_options 36 | .as_ref() 37 | .and_then(|options| options.get("serverPath")) 38 | .and_then(|server_path| server_path.as_str()) 39 | .and_then(|server_path| { 40 | if !server_path.is_empty() { 41 | Some(server_path) 42 | } else { 43 | None 44 | } 45 | }); 46 | 47 | if let Some(server_path) = server_path { 48 | // TODO: once nightly is released, update plugin api to use request version of start lsp 49 | // that will inform us of the error 50 | PLUGIN_RPC.start_lsp( 51 | Url::parse(&format!("urn:{}", server_path))?, 52 | Vec::new(), 53 | vec![DocumentFilter { 54 | language: Some("rust".to_string()), 55 | scheme: None, 56 | pattern: None, 57 | }], 58 | params.initialization_options, 59 | ); 60 | return Ok(()); 61 | } 62 | 63 | let arch = match std::env::var("VOLT_ARCH").as_deref() { 64 | Ok("x86_64") => "x86_64", 65 | Ok("aarch64") => "aarch64", 66 | _ => return Ok(()), 67 | }; 68 | let os = match std::env::var("VOLT_OS").as_deref() { 69 | Ok("linux") => "unknown-linux-gnu", 70 | Ok("macos") => "apple-darwin", 71 | Ok("windows") => "pc-windows-msvc", 72 | 73 | _ => return Ok(()), 74 | }; 75 | let file_name = format!("rust-analyzer-{}-{}", arch, os); 76 | let file_path = PathBuf::from(&file_name); 77 | let gz_path = PathBuf::from(file_name.clone() + ".gz"); 78 | if !file_path.exists() { 79 | let result: Result<()> = { 80 | let url = format!( 81 | "https://github.com/rust-lang/rust-analyzer/releases/download/2024-04-22/{}.gz", 82 | file_name 83 | ); 84 | { 85 | let mut resp = Http::get(&url)?; 86 | let body = resp.body_read_all()?; 87 | std::fs::write(&gz_path, body)?; 88 | let mut gz = GzDecoder::new(File::open(&gz_path)?); 89 | let mut file = File::create(&file_path)?; 90 | std::io::copy(&mut gz, &mut file)?; 91 | } 92 | std::fs::remove_file(&gz_path)?; 93 | Ok(()) 94 | }; 95 | if result.is_err() { 96 | PLUGIN_RPC.window_show_message( 97 | MessageType::ERROR, 98 | "can't download rust-analyzer, please use server path in the settings.".to_string(), 99 | ); 100 | return Ok(()); 101 | } 102 | } 103 | 104 | let volt_uri = std::env::var("VOLT_URI")?; 105 | let server_path = Url::parse(&volt_uri)?.join(&file_name)?; 106 | PLUGIN_RPC.start_lsp( 107 | server_path, 108 | Vec::new(), 109 | vec![DocumentFilter { 110 | language: Some("rust".to_string()), 111 | scheme: None, 112 | pattern: None, 113 | }], 114 | params.initialization_options, 115 | ); 116 | Ok(()) 117 | } 118 | 119 | impl LapcePlugin for State { 120 | fn handle_request(&mut self, _id: u64, method: String, params: Value) { 121 | #[allow(clippy::single_match)] 122 | match method.as_str() { 123 | Initialize::METHOD => { 124 | let params: InitializeParams = serde_json::from_value(params).unwrap(); 125 | if let Err(e) = initialize(params) { 126 | PLUGIN_RPC.stderr(&format!("plugin returned with error: {e}")) 127 | } 128 | } 129 | _ => {} 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /volt.toml: -------------------------------------------------------------------------------- 1 | name = "lapce-rust" 2 | version = "0.3.1932" 3 | author = "Lapce" 4 | display-name = "Rust" 5 | description = "Rust for Lapce: powered by Rust Analyzer" 6 | wasm = "lapce-rust.wasm" 7 | icon = "rust-logo.png" 8 | repository = "https://github.com/lapce/lapce-rust" 9 | 10 | [activation] 11 | language = ["rust"] 12 | workspace-contains = ["*/Cargo.toml"] 13 | 14 | [config."serverPath"] 15 | default = "" 16 | description = "Path to rust-analyzer executable. When empty, it points to the bundled binary." 17 | 18 | [config."diagnostics.enable"] 19 | default = true 20 | description = "Whether to show native rust-analyzer diagnostics." 21 | 22 | [config."diagnostics.experimental.enable"] 23 | default = true 24 | description = "Whether to show native rust-analyzer diagnostics." 25 | 26 | [config."checkOnSave"] 27 | default = true 28 | description = "Run the check command for diagnostics on save." 29 | 30 | [config."check.command"] 31 | default = "check" 32 | description = "Cargo command to use for `cargo check`." 33 | --------------------------------------------------------------------------------