├── .cargo └── config.toml ├── .editorconfig ├── .lapce └── settings.toml ├── .rustfmt.toml ├── .vscode ├── extensions.json └── settings.json ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── Makefile.toml ├── README.md ├── src └── main.rs ├── ts-logo-512.svg └── volt.toml /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [install] 2 | root = "." 3 | 4 | [build] 5 | target = "wasm32-wasi" 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | charset = utf-8 3 | end_of_line = lf 4 | insert_final_newline = true 5 | 6 | [*.{toml,json,rs}] 7 | indent_size = 2 8 | indent_style = space 9 | -------------------------------------------------------------------------------- /.lapce/settings.toml: -------------------------------------------------------------------------------- 1 | [lapce-rust.checkOnSave] 2 | command = "clippy" 3 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | reorder_imports = true 2 | match_arm_leading_pipes = "always" 3 | newline_style = "unix" 4 | tab_spaces = 2 5 | # imports_granularity = "Crate" 6 | # group_imports = "StdExternalCrate" 7 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "zerotaskx.rust-extension-pack", 4 | "Swellaby.rust-pack" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "rust-analyzer.checkOnSave.command": "clippy" 3 | } 4 | -------------------------------------------------------------------------------- /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 = "anyhow" 7 | version = "1.0.66" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" 10 | 11 | [[package]] 12 | name = "bitflags" 13 | version = "1.3.2" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 16 | 17 | [[package]] 18 | name = "bytes" 19 | version = "1.2.1" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" 22 | 23 | [[package]] 24 | name = "cfg-if" 25 | version = "1.0.0" 26 | source = "registry+https://github.com/rust-lang/crates.io-index" 27 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 28 | 29 | [[package]] 30 | name = "crossbeam-channel" 31 | version = "0.5.6" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" 34 | dependencies = [ 35 | "cfg-if", 36 | "crossbeam-utils", 37 | ] 38 | 39 | [[package]] 40 | name = "crossbeam-utils" 41 | version = "0.8.12" 42 | source = "registry+https://github.com/rust-lang/crates.io-index" 43 | checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" 44 | dependencies = [ 45 | "cfg-if", 46 | ] 47 | 48 | [[package]] 49 | name = "fnv" 50 | version = "1.0.7" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 53 | 54 | [[package]] 55 | name = "form_urlencoded" 56 | version = "1.1.0" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 59 | dependencies = [ 60 | "percent-encoding", 61 | ] 62 | 63 | [[package]] 64 | name = "http" 65 | version = "0.2.8" 66 | source = "registry+https://github.com/rust-lang/crates.io-index" 67 | checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" 68 | dependencies = [ 69 | "bytes", 70 | "fnv", 71 | "itoa", 72 | ] 73 | 74 | [[package]] 75 | name = "idna" 76 | version = "0.3.0" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" 79 | dependencies = [ 80 | "unicode-bidi", 81 | "unicode-normalization", 82 | ] 83 | 84 | [[package]] 85 | name = "itoa" 86 | version = "1.0.4" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" 89 | 90 | [[package]] 91 | name = "jsonrpc-lite" 92 | version = "0.5.0" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "a98d245f26984add78277a5306ca0cf774863d4eddb4912b31d94ee3fa1a22d4" 95 | dependencies = [ 96 | "serde", 97 | "serde_derive", 98 | "serde_json", 99 | ] 100 | 101 | [[package]] 102 | name = "lapce-plugin" 103 | version = "0.1.0" 104 | source = "git+https://github.com/lapce/lapce-plugin-rust.git#768bb44edf5ca3d777a5ba13ec8d2de10b80cdae" 105 | dependencies = [ 106 | "anyhow", 107 | "bytes", 108 | "crossbeam-channel", 109 | "http", 110 | "jsonrpc-lite", 111 | "once_cell", 112 | "psp-types", 113 | "serde", 114 | "serde_json", 115 | "wasi-experimental-http", 116 | ] 117 | 118 | [[package]] 119 | name = "lapce-typescript" 120 | version = "0.0.0" 121 | dependencies = [ 122 | "anyhow", 123 | "lapce-plugin", 124 | "serde", 125 | "serde_json", 126 | ] 127 | 128 | [[package]] 129 | name = "log" 130 | version = "0.4.17" 131 | source = "registry+https://github.com/rust-lang/crates.io-index" 132 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 133 | dependencies = [ 134 | "cfg-if", 135 | ] 136 | 137 | [[package]] 138 | name = "lsp-types" 139 | version = "0.93.2" 140 | source = "registry+https://github.com/rust-lang/crates.io-index" 141 | checksum = "9be6e9c7e2d18f651974370d7aff703f9513e0df6e464fd795660edc77e6ca51" 142 | dependencies = [ 143 | "bitflags", 144 | "serde", 145 | "serde_json", 146 | "serde_repr", 147 | "url", 148 | ] 149 | 150 | [[package]] 151 | name = "once_cell" 152 | version = "1.16.0" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" 155 | 156 | [[package]] 157 | name = "percent-encoding" 158 | version = "2.2.0" 159 | source = "registry+https://github.com/rust-lang/crates.io-index" 160 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 161 | 162 | [[package]] 163 | name = "pin-project-lite" 164 | version = "0.2.9" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 167 | 168 | [[package]] 169 | name = "proc-macro2" 170 | version = "1.0.47" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" 173 | dependencies = [ 174 | "unicode-ident", 175 | ] 176 | 177 | [[package]] 178 | name = "psp-types" 179 | version = "0.1.0" 180 | source = "git+https://github.com/lapce/psp-types?branch=master#b7680c844e8faa1b79c800210b4d5526771e7de0" 181 | dependencies = [ 182 | "lsp-types", 183 | "serde", 184 | "serde_json", 185 | ] 186 | 187 | [[package]] 188 | name = "quote" 189 | version = "1.0.21" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" 192 | dependencies = [ 193 | "proc-macro2", 194 | ] 195 | 196 | [[package]] 197 | name = "ryu" 198 | version = "1.0.11" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" 201 | 202 | [[package]] 203 | name = "serde" 204 | version = "1.0.147" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" 207 | dependencies = [ 208 | "serde_derive", 209 | ] 210 | 211 | [[package]] 212 | name = "serde_derive" 213 | version = "1.0.147" 214 | source = "registry+https://github.com/rust-lang/crates.io-index" 215 | checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" 216 | dependencies = [ 217 | "proc-macro2", 218 | "quote", 219 | "syn", 220 | ] 221 | 222 | [[package]] 223 | name = "serde_json" 224 | version = "1.0.87" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" 227 | dependencies = [ 228 | "itoa", 229 | "ryu", 230 | "serde", 231 | ] 232 | 233 | [[package]] 234 | name = "serde_repr" 235 | version = "0.1.9" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" 238 | dependencies = [ 239 | "proc-macro2", 240 | "quote", 241 | "syn", 242 | ] 243 | 244 | [[package]] 245 | name = "syn" 246 | version = "1.0.103" 247 | source = "registry+https://github.com/rust-lang/crates.io-index" 248 | checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" 249 | dependencies = [ 250 | "proc-macro2", 251 | "quote", 252 | "unicode-ident", 253 | ] 254 | 255 | [[package]] 256 | name = "thiserror" 257 | version = "1.0.37" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" 260 | dependencies = [ 261 | "thiserror-impl", 262 | ] 263 | 264 | [[package]] 265 | name = "thiserror-impl" 266 | version = "1.0.37" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" 269 | dependencies = [ 270 | "proc-macro2", 271 | "quote", 272 | "syn", 273 | ] 274 | 275 | [[package]] 276 | name = "tinyvec" 277 | version = "1.6.0" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 280 | dependencies = [ 281 | "tinyvec_macros", 282 | ] 283 | 284 | [[package]] 285 | name = "tinyvec_macros" 286 | version = "0.1.0" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 289 | 290 | [[package]] 291 | name = "tracing" 292 | version = "0.1.37" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" 295 | dependencies = [ 296 | "cfg-if", 297 | "log", 298 | "pin-project-lite", 299 | "tracing-attributes", 300 | "tracing-core", 301 | ] 302 | 303 | [[package]] 304 | name = "tracing-attributes" 305 | version = "0.1.23" 306 | source = "registry+https://github.com/rust-lang/crates.io-index" 307 | checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" 308 | dependencies = [ 309 | "proc-macro2", 310 | "quote", 311 | "syn", 312 | ] 313 | 314 | [[package]] 315 | name = "tracing-core" 316 | version = "0.1.30" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" 319 | dependencies = [ 320 | "once_cell", 321 | ] 322 | 323 | [[package]] 324 | name = "unicode-bidi" 325 | version = "0.3.8" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" 328 | 329 | [[package]] 330 | name = "unicode-ident" 331 | version = "1.0.5" 332 | source = "registry+https://github.com/rust-lang/crates.io-index" 333 | checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" 334 | 335 | [[package]] 336 | name = "unicode-normalization" 337 | version = "0.1.22" 338 | source = "registry+https://github.com/rust-lang/crates.io-index" 339 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 340 | dependencies = [ 341 | "tinyvec", 342 | ] 343 | 344 | [[package]] 345 | name = "url" 346 | version = "2.3.1" 347 | source = "registry+https://github.com/rust-lang/crates.io-index" 348 | checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" 349 | dependencies = [ 350 | "form_urlencoded", 351 | "idna", 352 | "percent-encoding", 353 | "serde", 354 | ] 355 | 356 | [[package]] 357 | name = "wasi-experimental-http" 358 | version = "0.9.0" 359 | source = "git+https://github.com/lapce/wasi-experimental-http#3685f0893ef19c1cca5b16a11ba01ff7ade14a5f" 360 | dependencies = [ 361 | "anyhow", 362 | "bytes", 363 | "http", 364 | "thiserror", 365 | "tracing", 366 | ] 367 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "lapce-typescript" 4 | version = "0.0.0" 5 | resolver = "2" 6 | 7 | [target.'cfg(target_os = "wasi")'.dependencies] 8 | 9 | # default deps for all lapce plugins 10 | anyhow = "1.0" 11 | serde_json = "1.0" 12 | serde = { version = "1.0", features = ["derive"] } 13 | lapce-plugin = { git = "https://github.com/lapce/lapce-plugin-rust.git" } 14 | 15 | [profile.release] 16 | lto = true 17 | opt-level = 's' 18 | codegen-units = 1 19 | strip = true 20 | panic = 'abort' 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Makefile.toml: -------------------------------------------------------------------------------- 1 | [tasks.default] 2 | clear = true 3 | dependencies = [ 4 | "fmt", 5 | "check", 6 | "clippy", 7 | "release", 8 | ] 9 | 10 | [tasks.fmt] 11 | command = "cargo" 12 | args = ["fmt"] 13 | 14 | [tasks.release] 15 | dependencies = ["build-release"] 16 | 17 | [tasks.dev] 18 | dependencies = ["build-dev"] 19 | 20 | [tasks.check] 21 | command = "cargo" 22 | args = ["check"] 23 | 24 | [tasks.clippy] 25 | command = "cargo" 26 | args = ["clippy"] 27 | 28 | [tasks.build-dev] 29 | command = "cargo" 30 | args = ["install", "--path", ".", "--no-track", "--debug"] 31 | 32 | [tasks.build-release] 33 | command = "cargo" 34 | args = ["install", "--path", ".", "--no-track"] 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lapce plugin for Typescript/Javascript (`typescript-language-server`) 2 | 3 | ## Prerequisites 4 | 5 | Install `typescript-language-server` and `typescript` (Requires NodeJS) via `npm` or your system package manager 6 | Server needs to be in one of the paths included in `PATH` environment variable 7 | 8 | ```shell 9 | npm i --global typescript-language-server@2 typescript 10 | ``` 11 | 12 | ## Available configuration 13 | 14 | ```toml 15 | [lapce-typescript.volt] 16 | serverPath = "" 17 | serverArgs = ["--stdio"] # --stdio is required for all LSPs written in nodejs 18 | ``` 19 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use anyhow::{anyhow, Result}; 2 | use lapce_plugin::{ 3 | psp_types::{ 4 | lsp_types::{request::Initialize, DocumentFilter, DocumentSelector, InitializeParams, Url}, 5 | Request, 6 | }, 7 | register_plugin, LapcePlugin, VoltEnvironment, PLUGIN_RPC, 8 | }; 9 | use serde_json::Value; 10 | 11 | #[derive(Default)] 12 | struct State {} 13 | 14 | register_plugin!(State); 15 | 16 | macro_rules! string { 17 | ( $x:expr ) => { 18 | String::from($x) 19 | }; 20 | } 21 | 22 | macro_rules! ok { 23 | ( $x:expr ) => { 24 | match ($x) { 25 | | Ok(v) => v, 26 | | Err(e) => return Err(anyhow!(e)), 27 | } 28 | }; 29 | } 30 | fn initialize(params: InitializeParams) -> Result<()> { 31 | let document_selector: DocumentSelector = vec![ 32 | DocumentFilter { 33 | language: Some(string!("typescript")), 34 | pattern: Some(string!("**/*.ts")), 35 | scheme: None, 36 | }, 37 | DocumentFilter { 38 | language: Some(string!("javascript")), 39 | pattern: Some(string!("**/*.js")), 40 | scheme: None, 41 | }, 42 | DocumentFilter { 43 | language: Some(string!("typescriptreact")), 44 | pattern: Some(string!("**/*.tsx")), 45 | scheme: None, 46 | }, 47 | DocumentFilter { 48 | language: Some(string!("javascriptreact")), 49 | pattern: Some(string!("**/*.jsx")), 50 | scheme: None, 51 | }, 52 | ]; 53 | let mut server_args = vec![string!("--stdio")]; 54 | 55 | if let Some(options) = params.initialization_options.as_ref() { 56 | if let Some(volt) = options.get("volt") { 57 | if let Some(args) = volt.get("serverArgs") { 58 | if let Some(args) = args.as_array() { 59 | if !args.is_empty() { 60 | server_args = vec![]; 61 | } 62 | for arg in args { 63 | if let Some(arg) = arg.as_str() { 64 | server_args.push(arg.to_string()); 65 | } 66 | } 67 | } 68 | } 69 | 70 | if let Some(server_path) = volt.get("serverPath") { 71 | if let Some(server_path) = server_path.as_str() { 72 | if !server_path.is_empty() { 73 | let server_uri = ok!(Url::parse(&format!("urn:{}", server_path))); 74 | PLUGIN_RPC.start_lsp( 75 | server_uri, 76 | server_args, 77 | document_selector, 78 | params.initialization_options, 79 | ); 80 | return Ok(()); 81 | } 82 | } 83 | } 84 | } 85 | } 86 | 87 | let server_uri = match VoltEnvironment::operating_system().as_deref() { 88 | | Ok("windows") => ok!(Url::parse("urn:typescript-language-server.cmd")), 89 | | _ => ok!(Url::parse("urn:typescript-language-server")), 90 | }; 91 | 92 | PLUGIN_RPC.start_lsp( 93 | server_uri, 94 | server_args, 95 | document_selector, 96 | params.initialization_options, 97 | ); 98 | 99 | Ok(()) 100 | } 101 | 102 | impl LapcePlugin for State { 103 | fn handle_request(&mut self, _id: u64, method: String, params: Value) { 104 | #[allow(clippy::single_match)] 105 | match method.as_str() { 106 | | Initialize::METHOD => { 107 | let params: InitializeParams = serde_json::from_value(params).unwrap(); 108 | if let Err(e) = initialize(params) { 109 | PLUGIN_RPC.stderr(&format!("plugin returned with error: {e}")) 110 | } 111 | } 112 | | _ => {} 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /ts-logo-512.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /volt.toml: -------------------------------------------------------------------------------- 1 | name = "lapce-typescript" 2 | version = "2022.11.0" 3 | author = "panekj" 4 | display-name = "TS / JS" 5 | description = "Typescript & Javascript language support" 6 | wasm = "bin/lapce-typescript.wasm" 7 | icon = "ts-logo-512.svg" 8 | 9 | [activation] 10 | language = ["typescript", "typescriptreact", "javascript", "javascriptreact"] 11 | workspace-contains = ["*/package.json", "*/*.ts", "*/*.js", "*/*.tsx", "*/*.jsx"] 12 | 13 | [config."volt.serverPath"] 14 | default = "" 15 | description = "Path to typescript-language-server" 16 | 17 | [config."volt.serverArgs"] 18 | default = ["--stdio"] 19 | description = "LSP server arguments to pass when launching" 20 | 21 | # [config.""] 22 | --------------------------------------------------------------------------------