lsp-javascript.el (48600B)
1 ;;; lsp-javascript.el --- description -*- lexical-binding: t; -*- 2 3 ;; Copyright (C) 2020 emacs-lsp maintainers 4 5 ;; Author: emacs-lsp maintainers 6 ;; Keywords: lsp, 7 8 ;; This program is free software; you can redistribute it and/or modify 9 ;; it under the terms of the GNU General Public License as published by 10 ;; the Free Software Foundation, either version 3 of the License, or 11 ;; (at your option) any later version. 12 13 ;; This program is distributed in the hope that it will be useful, 14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ;; GNU General Public License for more details. 17 18 ;; You should have received a copy of the GNU General Public License 19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>. 20 21 ;;; Commentary: 22 23 ;; LSP Clients for the JavaScript and TypeScript Programming Languages. 24 25 ;;; Code: 26 27 (require 'lsp-mode) 28 29 (lsp-dependency 'javascript-typescript-langserver 30 '(:system "javascript-typescript-stdio") 31 '(:npm :package "javascript-typescript-langserver" 32 :path "javascript-typescript-stdio")) 33 34 (defgroup lsp-typescript-javascript nil 35 "Support for TypeScript/JavaScript, using Sourcegraph's JavaScript/TypeScript language server." 36 :group 'lsp-mode 37 :link '(url-link "https://github.com/sourcegraph/javascript-typescript-langserver")) 38 39 ;; Original name can be confused with initializationOptions. Preferences is just one option of initializationOptions. 40 (define-obsolete-variable-alias 41 'lsp-clients-typescript-init-opts 42 'lsp-clients-typescript-preferences 43 "lsp-mode 9.0.0") 44 45 (defcustom lsp-clients-typescript-javascript-server-args '() 46 "Extra arguments for the typescript-language-server language server." 47 :group 'lsp-typescript-javascript 48 :risky t 49 :type '(repeat string)) 50 51 (defun lsp-typescript-javascript-tsx-jsx-activate-p (filename &optional _) 52 "Check if the js-ts lsp server should be enabled based on FILENAME." 53 (or (string-match-p "\\.[cm]js\\|\\.[jt]sx?\\'" filename) 54 (and (derived-mode-p 'js-mode 'js-ts-mode 'typescript-mode 'typescript-ts-mode) 55 (not (derived-mode-p 'json-mode))))) 56 57 ;; Unmaintained sourcegraph server 58 (lsp-register-client 59 (make-lsp-client :new-connection (lsp-stdio-connection (lambda () 60 (cons (lsp-package-path 'javascript-typescript-langserver) 61 lsp-clients-typescript-javascript-server-args))) 62 :activation-fn 'lsp-typescript-javascript-tsx-jsx-activate-p 63 :priority -3 64 :completion-in-comments? t 65 :server-id 'jsts-ls 66 :download-server-fn (lambda (_client callback error-callback _update?) 67 (lsp-package-ensure 68 'javascript-typescript-langserver 69 callback 70 error-callback)) 71 :initialized-fn (lambda (_workspace) 72 (warn (concat "The javascript-typescript-langserver (jsts-ls) is unmaintained; " 73 "it is recommended to use ts-ls or deno-ls instead."))))) 74 75 (defgroup lsp-typescript nil 76 "LSP support for TypeScript, using Theia/Typefox's TypeScript Language Server." 77 :group 'lsp-mode 78 :link '(url-link "https://github.com/theia-ide/typescript-language-server")) 79 80 (defcustom lsp-clients-typescript-tls-path "typescript-language-server" 81 "Path to the typescript-language-server binary." 82 :group 'lsp-typescript 83 :risky t 84 :type 'string) 85 86 (defcustom lsp-clients-typescript-server-args '("--stdio") 87 "Extra arguments for the typescript-language-server language server." 88 :group 'lsp-typescript 89 :risky t 90 :type '(repeat string)) 91 92 (defcustom lsp-clients-typescript-disable-automatic-typing-acquisition nil 93 "Disable tsserver from automatically fetching missing type definitions. 94 \(@types packages) for external modules." 95 :group 'lsp-typescript 96 :type 'boolean) 97 98 (defcustom lsp-clients-typescript-log-verbosity "info" 99 "The verbosity level of the information printed in the log by tsserver." 100 :group 'lsp-typescript 101 :type '(choice 102 (const "off") 103 (const "terse") 104 (const "normal") 105 (const "requesttime") 106 (const "verbose"))) 107 108 (defcustom lsp-clients-typescript-max-ts-server-memory nil 109 "The maximum size of the V8's old memory section in megabytes. 110 \(for example 4096 means 4GB). The default value is dynamically configured 111 by Node so can differ per system. Increase for very big projects that 112 exceed allowed memory usage." 113 :group 'lsp-typescript 114 :type 'integer) 115 116 (defcustom lsp-clients-typescript-npm-location nil 117 "Specifies the path to the NPM exec used for Automatic Type Acquisition." 118 :group 'lsp-typescript 119 :type 'string) 120 121 (defcustom lsp-clients-typescript-prefer-use-project-ts-server nil 122 "When set, prefers using the tsserver.js from your project. This 123 can allow loading plugins configured in your tsconfig.json." 124 :group 'lsp-typescript 125 :type 'boolean) 126 127 (defcustom lsp-clients-typescript-plugins (vector) 128 "The list of plugins to load. 129 It should be a vector of plist with keys `:location' and `:name' 130 where `:name' is the name of the package and `:location' is the 131 directory containing the package. Example: 132 \(vector 133 \(list :name \"@vsintellicode/typescript-intellicode-plugin\" 134 :location \"<path>.vscode/extensions/visualstudioexptteam. 135 vscodeintellicode-1.1.9/\"))" 136 :group 'lsp-typescript 137 :type '(restricted-sexp :tag "Vector" 138 :match-alternatives 139 (lambda (xs) 140 (and (vectorp xs) (seq-every-p 141 (-lambda ((&plist :name :location)) 142 (and name location)) 143 xs))))) 144 145 (defcustom lsp-clients-typescript-preferences nil 146 "Preferences passed to the Typescript (tsserver) process. 147 See https://github.com/typescript-language-server/typescript-language-server#initializationoptions for the list of preferences available in the latest version of TypeScript." 148 :group 'lsp-typescript 149 :type 'plist) 150 151 (defcustom lsp-clients-typescript-tsserver nil 152 "Options related to the tsserver process. See below for more info. 153 See https://github.com/typescript-language-server/typescript-language-server#initializationoptions for the list of tsserver available in the latest version of TypeScript." 154 :group 'lsp-typescript 155 :type 'plist) 156 157 (defcustom lsp-typescript-tsdk nil 158 "Specifies the folder path containing tsserver and lib*.d.ts files to use." 159 :type '(repeat string) 160 :group 'lsp-vetur 161 :package-version '(lsp-mode . "6.1")) 162 163 (defcustom lsp-typescript-disable-automatic-type-acquisition nil 164 "Disables automatic type acquisition. 165 Automatic type acquisition fetches `@types` packages from npm to improve 166 IntelliSense for external libraries." 167 :type 'boolean 168 :group 'lsp-vetur 169 :package-version '(lsp-mode . "6.1")) 170 171 (defcustom lsp-typescript-npm nil 172 "Specifies the path to the NPM exec used for Automatic Type Acquisition. 173 Requires using TypeScript 2.3.4 or newer in the 174 workspace." 175 :type '(repeat string) 176 :group 'lsp-vetur 177 :package-version '(lsp-mode . "6.1")) 178 179 (defcustom lsp-typescript-check-npm-is-installed t 180 "Check if NPM is installed for Automatic Type Acquisition." 181 :type 'boolean 182 :group 'lsp-vetur 183 :package-version '(lsp-mode . "6.1")) 184 185 (defcustom lsp-javascript-references-code-lens-enabled nil 186 "Enable/disable references CodeLens in JavaScript files." 187 :type 'boolean 188 :group 'lsp-vetur 189 :package-version '(lsp-mode . "6.1")) 190 191 (defcustom lsp-typescript-references-code-lens-enabled nil 192 "Enable/disable references CodeLens in TypeScript files." 193 :type 'boolean 194 :group 'lsp-vetur 195 :package-version '(lsp-mode . "6.1")) 196 197 (defcustom lsp-typescript-implementations-code-lens-enabled nil 198 "Enable/disable implementations CodeLens. 199 This CodeLens shows the implementers of an interface." 200 :type 'boolean 201 :group 'lsp-vetur 202 :package-version '(lsp-mode . "6.1")) 203 204 (defcustom lsp-typescript-tsserver-log "off" 205 "Enables logging of the TS server to a file. 206 This log can be used to diagnose TS Server issues. The log may contain file 207 paths, source code, and other potentially sensitive information 208 from your project." 209 :type '(choice 210 (const "off") 211 (const "terse") 212 (const "normal") 213 (const "verbose")) 214 :group 'lsp-vetur 215 :package-version '(lsp-mode . "6.1")) 216 217 (defcustom lsp-typescript-tsserver-plugin-paths nil 218 "Additional paths to discover Typescript Language Service plugins. 219 Requires using TypeScript 2.3.0 or newer in the 220 workspace." 221 :type '(repeat string) 222 :package-version '(lsp-mode . "6.1")) 223 224 (defcustom lsp-typescript-tsserver-trace "off" 225 "Enables tracing of messages sent to the TS server. 226 This trace can be used to diagnose TS Server issues. The trace may contain 227 file paths, source code, and other potentially sensitive 228 information from your project." 229 :type '(choice 230 (const "off") 231 (const "messages") 232 (const "verbose")) 233 :package-version '(lsp-mode . "6.1")) 234 235 (defcustom lsp-javascript-suggest-complete-function-calls nil 236 "Complete functions with their parameter signature." 237 :type 'boolean 238 :package-version '(lsp-mode . "6.1")) 239 240 (defcustom lsp-typescript-suggest-complete-function-calls nil 241 "Complete functions with their parameter signature." 242 :type 'boolean 243 :package-version '(lsp-mode . "6.1")) 244 245 (defcustom lsp-typescript-report-style-checks-as-warnings t 246 "Report style checks as warnings." 247 :type 'boolean 248 :package-version '(lsp-mode . "6.1")) 249 250 (defcustom lsp-typescript-validate-enable t 251 "Enable/disable TypeScript validation." 252 :type 'boolean 253 :package-version '(lsp-mode . "6.1")) 254 255 (defcustom lsp-typescript-format-enable t 256 "Enable/disable default TypeScript formatter." 257 :type 'boolean 258 :package-version '(lsp-mode . "6.1")) 259 260 (defcustom lsp-typescript-format-insert-space-after-comma-delimiter t 261 "Defines space handling after a comma delimiter." 262 :type 'boolean 263 :package-version '(lsp-mode . "6.1")) 264 265 (defcustom lsp-typescript-format-insert-space-after-constructor nil 266 "Defines space handling after the constructor keyword. 267 Requires using TypeScript 2.3.0 or newer in the workspace." 268 :type 'boolean 269 :package-version '(lsp-mode . "6.1")) 270 271 (defcustom lsp-typescript-format-insert-space-after-semicolon-in-for-statements t 272 "Defines space handling after a semicolon in a for statement." 273 :type 'boolean 274 :package-version '(lsp-mode . "6.1")) 275 276 (defcustom lsp-typescript-format-insert-space-before-and-after-binary-operators t 277 "Defines space handling after a binary operator." 278 :type 'boolean 279 :package-version '(lsp-mode . "6.1")) 280 281 (defcustom lsp-typescript-format-insert-space-after-keywords-in-control-flow-statements t 282 "Defines space handling after keywords in a control flow statement." 283 :type 'boolean 284 :package-version '(lsp-mode . "6.1")) 285 286 (defcustom lsp-typescript-format-insert-space-after-function-keyword-for-anonymous-functions t 287 "Defines space handling after function keyword for anonymous functions." 288 :type 'boolean 289 :package-version '(lsp-mode . "6.1")) 290 291 (defcustom lsp-typescript-format-insert-space-before-function-parenthesis nil 292 "Defines space handling before function argument parentheses." 293 :type 'boolean 294 :package-version '(lsp-mode . "6.1")) 295 296 (defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-empty-braces nil 297 "Defines space handling after opening/before closing empty braces." 298 :type 'boolean 299 :package-version '(lsp-mode . "6.1")) 300 301 (defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis nil 302 "Defines space handling after opening/before closing non-empty parenthesis." 303 :type 'boolean 304 :package-version '(lsp-mode . "6.1")) 305 306 (defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets nil 307 "Defines space handling after opening and before closing non-empty brackets." 308 :type 'boolean 309 :package-version '(lsp-mode . "6.1")) 310 311 (defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-braces t 312 "Defines space handling after opening and before closing non-empty braces. 313 Requires using TypeScript 2.3.0 or newer in the workspace." 314 :type 'boolean 315 :package-version '(lsp-mode . "6.1")) 316 317 (defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-template-string-braces nil 318 "Defines space handling after opening/before closing template string braces." 319 :type 'boolean 320 :package-version '(lsp-mode . "6.1")) 321 322 (defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces nil 323 "Defines space handling after opening/before closing JSX expression braces." 324 :type 'boolean 325 :package-version '(lsp-mode . "6.1")) 326 327 (defcustom lsp-typescript-format-insert-space-after-type-assertion nil 328 "Defines space handling after type assertions in TypeScript. 329 Requires using TypeScript 2.4 or newer in the workspace." 330 :type 'boolean 331 :package-version '(lsp-mode . "6.1")) 332 333 (defcustom lsp-typescript-format-place-open-brace-on-new-line-for-functions nil 334 "Defines whether an open brace is put onto a new line for functions or not." 335 :type 'boolean 336 :package-version '(lsp-mode . "6.1")) 337 338 (defcustom lsp-typescript-format-place-open-brace-on-new-line-for-control-blocks nil 339 "Defines whether an open brace is put onto a newline for control blocks." 340 :type 'boolean 341 :package-version '(lsp-mode . "6.1")) 342 343 (defcustom lsp-javascript-validate-enable t 344 "Enable/disable JavaScript validation." 345 :type 'boolean 346 :package-version '(lsp-mode . "6.1")) 347 348 (defcustom lsp-javascript-format-enable t 349 "Enable/disable default JavaScript formatter." 350 :type 'boolean 351 :package-version '(lsp-mode . "6.1")) 352 353 (defcustom lsp-javascript-format-insert-space-after-comma-delimiter t 354 "Defines space handling after a comma delimiter." 355 :type 'boolean 356 :package-version '(lsp-mode . "6.1")) 357 358 (defcustom lsp-javascript-format-insert-space-after-constructor nil 359 "Defines space handling after the constructor keyword. 360 Requires using TypeScript 2.3.0 or newer in the workspace." 361 :type 'boolean 362 :package-version '(lsp-mode . "6.1")) 363 364 (defcustom lsp-javascript-format-insert-space-after-semicolon-in-for-statements t 365 "Defines space handling after a semicolon in a for statement." 366 :type 'boolean 367 :package-version '(lsp-mode . "6.1")) 368 369 (defcustom lsp-javascript-format-insert-space-before-and-after-binary-operators t 370 "Defines space handling after a binary operator." 371 :type 'boolean 372 :package-version '(lsp-mode . "6.1")) 373 374 (defcustom lsp-javascript-format-insert-space-after-keywords-in-control-flow-statements t 375 "Defines space handling after keywords in a control flow statement." 376 :type 'boolean 377 :package-version '(lsp-mode . "6.1")) 378 379 (defcustom lsp-javascript-format-insert-space-after-function-keyword-for-anonymous-functions t 380 "Defines space handling after function keyword for anonymous functions." 381 :type 'boolean 382 :package-version '(lsp-mode . "6.1")) 383 384 (defcustom lsp-javascript-format-insert-space-before-function-parenthesis nil 385 "Defines space handling before function argument parentheses." 386 :type 'boolean 387 :package-version '(lsp-mode . "6.1")) 388 389 (defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-empty-braces nil 390 "Defines space handling after opening/before closing empty braces." 391 :type 'boolean 392 :package-version '(lsp-mode . "6.1")) 393 394 (defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis nil 395 "Defines space handling after opening and before closing non-empty parenthesis." 396 :type 'boolean 397 :package-version '(lsp-mode . "6.1")) 398 399 (defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-brackets nil 400 "Defines space handling after opening and before closing non-empty brackets." 401 :type 'boolean 402 :package-version '(lsp-mode . "6.1")) 403 404 (defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-braces t 405 "Defines space handling after opening and before closing non-empty braces. 406 Requires using TypeScript 2.3.0 or newer in the workspace." 407 :type 'boolean 408 :package-version '(lsp-mode . "6.1")) 409 410 (defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-template-string-braces nil 411 "Defines space handling after opening/before closing template string braces." 412 :type 'boolean 413 :package-version '(lsp-mode . "6.1")) 414 415 (defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces nil 416 "Defines space handling after opening/before closing JSX expression braces." 417 :type 'boolean 418 :package-version '(lsp-mode . "6.1")) 419 420 (defcustom lsp-javascript-format-place-open-brace-on-new-line-for-functions nil 421 "Defines whether an open brace is put onto a new line for functions or not." 422 :type 'boolean 423 :package-version '(lsp-mode . "6.1")) 424 425 (defcustom lsp-javascript-format-place-open-brace-on-new-line-for-control-blocks nil 426 "Defines whether an open brace is put onto a new line for control blocks or not." 427 :type 'boolean 428 :package-version '(lsp-mode . "6.1")) 429 430 (defcustom lsp-javascript-implicit-project-config-check-js nil 431 "Enable/disable semantic checking of JavaScript files. 432 Existing jsconfig.json or tsconfig.json files override this setting. 433 Requires using TypeScript 2.3.1 or newer in the workspace." 434 :type 'boolean 435 :package-version '(lsp-mode . "6.1")) 436 437 (defcustom lsp-javascript-implicit-project-config-experimental-decorators nil 438 nil 439 :type 'boolean 440 :package-version '(lsp-mode . "6.1")) 441 442 (defcustom lsp-javascript-suggest-names t 443 "Enable/disable including unique names from the file in JavaScript suggestions." 444 :type 'boolean 445 :package-version '(lsp-mode . "6.1")) 446 447 (defcustom lsp-typescript-tsc-auto-detect "on" 448 "Controls auto detection of tsc tasks." 449 :type '(choice 450 (const "on") 451 (const "off") 452 (const "build") 453 (const "watch")) 454 :package-version '(lsp-mode . "6.1")) 455 456 (defcustom lsp-javascript-suggest-paths t 457 "Enable/disable suggestions for paths in import statements and require calls." 458 :type 'boolean 459 :package-version '(lsp-mode . "6.1")) 460 461 (defcustom lsp-typescript-suggest-paths t 462 "Enable/disable suggestions for paths in import statements and require calls." 463 :type 'boolean 464 :package-version '(lsp-mode . "6.1")) 465 466 (defcustom lsp-javascript-suggest-auto-imports t 467 "Enable/disable auto import suggestions. 468 Requires using TypeScript 2.6.1 or newer in the workspace." 469 :type 'boolean 470 :package-version '(lsp-mode . "6.1")) 471 472 (defcustom lsp-typescript-suggest-auto-imports t 473 "Enable/disable auto import suggestions. Requires using 474 TypeScript 2.6.1 or newer in the workspace." 475 :type 'boolean 476 :package-version '(lsp-mode . "6.1")) 477 478 (defcustom lsp-javascript-suggest-complete-js-docs t 479 "Enable/disable suggestion to complete JSDoc comments." 480 :type 'boolean 481 :package-version '(lsp-mode . "6.1")) 482 483 (defcustom lsp-typescript-suggest-complete-js-docs t 484 "Enable/disable suggestion to complete JSDoc comments." 485 :type 'boolean 486 :package-version '(lsp-mode . "6.1")) 487 488 (defcustom lsp-typescript-locale nil 489 nil 490 :type '(choice 491 (const "de") 492 (const "es") 493 (const "en") 494 (const "fr") 495 (const "it") 496 (const "ja") 497 (const "ko") 498 (const "ru") 499 (const "zh-CN") 500 (const "zh-TW") 501 (const :tag "default" nil)) 502 :package-version '(lsp-mode . "6.1")) 503 504 (defcustom lsp-javascript-suggestion-actions-enabled t 505 "Enable/disable suggestion diagnostics for JavaScript files in 506 the editor. Requires using TypeScript 2.8 or newer in the 507 workspace." 508 :type 'boolean 509 :package-version '(lsp-mode . "6.1")) 510 511 (defcustom lsp-typescript-suggestion-actions-enabled t 512 "Enable/disable suggestion diagnostics for TypeScript files in 513 the editor. Requires using TypeScript 2.8 or newer in the 514 workspace." 515 :type 'boolean 516 :package-version '(lsp-mode . "6.1")) 517 518 (defcustom lsp-javascript-preferences-quote-style "auto" nil 519 :type '(choice 520 (const "auto") 521 (const "single") 522 (const "double")) 523 :package-version '(lsp-mode . "6.1")) 524 525 (defcustom lsp-typescript-preferences-quote-style "auto" nil 526 :type '(choice 527 (const "auto") 528 (const "single") 529 (const "double")) 530 :package-version '(lsp-mode . "6.1")) 531 532 (defcustom lsp-javascript-preferences-import-module-specifier "auto" 533 "Preferred path style for auto imports." 534 :type '(choice 535 (const "auto") 536 (const "relative") 537 (const "non-relative")) 538 :package-version '(lsp-mode . "6.1")) 539 540 (defcustom lsp-typescript-preferences-import-module-specifier "auto" 541 "Infer the shortest path type." 542 :type '(choice 543 (const "auto") 544 (const "relative") 545 (const "non-relative")) 546 :package-version '(lsp-mode . "6.1")) 547 548 (defcustom lsp-javascript-preferences-rename-shorthand-properties t 549 "Enable/disable introducing aliases for object shorthand 550 properties during renames. Requires using TypeScript 3.4 or newer 551 in the workspace." 552 :type 'boolean 553 :package-version '(lsp-mode . "6.1")) 554 555 (defcustom lsp-typescript-preferences-rename-shorthand-properties t 556 "Enable/disable introducing aliases for object shorthand 557 properties during renames. Requires using TypeScript 3.4 or newer 558 in the workspace." 559 :type 'boolean 560 :package-version '(lsp-mode . "6.1")) 561 562 (defcustom lsp-typescript-update-imports-on-file-move-enabled "prompt" 563 "Enable/disable automatic updating of import paths when you 564 rename or move a file in VS Code. Requires using TypeScript 2.9 565 or newer in the workspace." 566 :type '(choice 567 (const "prompt") 568 (const "always") 569 (const "never")) 570 :package-version '(lsp-mode . "6.1")) 571 572 (defcustom lsp-javascript-update-imports-on-file-move-enabled "prompt" 573 "Prompt on each rename." 574 :type '(choice 575 (const "prompt") 576 (const "always") 577 (const "never")) 578 :package-version '(lsp-mode . "6.1")) 579 580 (defcustom lsp-typescript-auto-closing-tags t 581 "Enable/disable automatic closing of JSX tags. Requires using 582 TypeScript 3.0 or newer in the workspace." 583 :type 'boolean 584 :package-version '(lsp-mode . "6.1")) 585 586 (defcustom lsp-javascript-auto-closing-tags t 587 "Enable/disable automatic closing of JSX tags. Requires using 588 TypeScript 3.0 or newer in the workspace." 589 :type 'boolean 590 :package-version '(lsp-mode . "6.1")) 591 592 (defcustom lsp-javascript-suggest-enabled t 593 "Enabled/disable autocomplete suggestions." 594 :type 'boolean 595 :package-version '(lsp-mode . "6.1")) 596 597 (defcustom lsp-typescript-suggest-enabled t 598 "Enabled/disable autocomplete suggestions." 599 :type 'boolean 600 :package-version '(lsp-mode . "6.1")) 601 602 (defcustom lsp-typescript-surveys-enabled t 603 "Enabled/disable occasional surveys that help us improve VS 604 Code's JavaScript and TypeScript support." 605 :type 'boolean 606 :package-version '(lsp-mode . "6.1")) 607 608 (defcustom lsp-javascript-display-enum-member-value-hints nil 609 "Show inlay hints for enum member values." 610 :type 'boolean 611 :package-version '(lsp-mode . "9.0.0")) 612 613 (defcustom lsp-javascript-display-return-type-hints nil 614 "Show inlay hints for function return types." 615 :type 'boolean 616 :package-version '(lsp-mode . "9.0.0")) 617 618 (defcustom lsp-javascript-display-parameter-type-hints nil 619 "Show inlay hints for function parameters." 620 :type 'boolean 621 :package-version '(lsp-mode . "9.0.0")) 622 623 (defcustom lsp-javascript-display-parameter-name-hints "none" 624 "Level of hinting for parameter types." 625 :type '(choice (const :tag "none" "none") 626 (const :tag "literals" "literals") 627 (const :tag "all" "all")) 628 :package-version '(lsp-mode . "9.0.0")) 629 630 (defcustom lsp-javascript-display-parameter-name-hints-when-argument-matches-name nil 631 "Show inlay hints for function parameters even when argument matches 632 name (e.g. `data' variable passed as `data' parameter)." 633 :type 'boolean 634 :package-version '(lsp-mode . "9.0.0")) 635 636 (defcustom lsp-javascript-display-property-declaration-type-hints nil 637 "Show inlay hints for property declaration types." 638 :type 'boolean 639 :package-version '(lsp-mode . "9.0.0")) 640 641 (defcustom lsp-javascript-display-variable-type-hints nil 642 "Show inlay hints for variable types." 643 :type 'boolean 644 :package-version '(lsp-mode . "9.0.0")) 645 646 (defcustom lsp-javascript-completions-complete-function-calls t 647 "Complete function calls." 648 :type 'boolean 649 :package-version '(lsp-mode . "9.0.0")) 650 651 (lsp-register-custom-settings 652 '(("javascript.autoClosingTags" lsp-javascript-auto-closing-tags t) 653 ("javascript.implicitProjectConfig.checkJs" lsp-javascript-implicit-project-config-check-js t) 654 ("javascript.implicitProjectConfig.experimentalDecorators" lsp-javascript-implicit-project-config-experimental-decorators t) 655 ("javascript.preferences.importModuleSpecifier" lsp-javascript-preferences-import-module-specifier) 656 ("javascript.preferences.quoteStyle" lsp-javascript-preferences-quote-style) 657 ("javascript.preferences.renameShorthandProperties" lsp-javascript-preferences-rename-shorthand-properties t) 658 ("javascript.referencesCodeLens.enabled" lsp-javascript-references-code-lens-enabled t) 659 ("javascript.suggest.autoImports" lsp-javascript-suggest-auto-imports t) 660 ("javascript.suggest.completeFunctionCalls" lsp-javascript-suggest-complete-function-calls t) 661 ("javascript.suggest.completeJSDocs" lsp-javascript-suggest-complete-js-docs t) 662 ("javascript.suggest.enabled" lsp-javascript-suggest-enabled t) 663 ("javascript.suggest.names" lsp-javascript-suggest-names t) 664 ("javascript.suggest.paths" lsp-javascript-suggest-paths t) 665 ("javascript.suggestionActions.enabled" lsp-javascript-suggestion-actions-enabled t) 666 ("javascript.updateImportsOnFileMove.enabled" lsp-javascript-update-imports-on-file-move-enabled) 667 ("javascript.validate.enable" lsp-javascript-validate-enable t) 668 ("javascript.format.enable" lsp-javascript-format-enable t) 669 ("javascript.format.insertSpaceAfterCommaDelimiter" lsp-javascript-format-insert-space-after-comma-delimiter t) 670 ("javascript.format.insertSpaceAfterConstructor" lsp-javascript-format-insert-space-after-constructor t) 671 ("javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions" lsp-javascript-format-insert-space-after-function-keyword-for-anonymous-functions t) 672 ("javascript.format.insertSpaceAfterKeywordsInControlFlowStatements" lsp-javascript-format-insert-space-after-keywords-in-control-flow-statements t) 673 ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces t) 674 ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-empty-braces t) 675 ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-braces t) 676 ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-brackets t) 677 ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis t) 678 ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-template-string-braces t) 679 ("javascript.format.insertSpaceAfterSemicolonInForStatements" lsp-javascript-format-insert-space-after-semicolon-in-for-statements t) 680 ("javascript.format.insertSpaceBeforeAndAfterBinaryOperators" lsp-javascript-format-insert-space-before-and-after-binary-operators t) 681 ("javascript.format.insertSpaceBeforeFunctionParenthesis" lsp-javascript-format-insert-space-before-function-parenthesis t) 682 ("javascript.format.placeOpenBraceOnNewLineForControlBlocks" lsp-javascript-format-place-open-brace-on-new-line-for-control-blocks t) 683 ("javascript.format.placeOpenBraceOnNewLineForFunctions" lsp-javascript-format-place-open-brace-on-new-line-for-functions t) 684 ("typescript.autoClosingTags" lsp-typescript-auto-closing-tags t) 685 ("typescript.check.npmIsInstalled" lsp-typescript-check-npm-is-installed t) 686 ("typescript.disableAutomaticTypeAcquisition" lsp-typescript-disable-automatic-type-acquisition t) 687 ("typescript.implementationsCodeLens.enabled" lsp-typescript-implementations-code-lens-enabled t) 688 ("typescript.locale" lsp-typescript-locale) 689 ("typescript.npm" lsp-typescript-npm) 690 ("typescript.preferences.importModuleSpecifier" lsp-typescript-preferences-import-module-specifier) 691 ("typescript.preferences.quoteStyle" lsp-typescript-preferences-quote-style) 692 ("typescript.preferences.renameShorthandProperties" lsp-typescript-preferences-rename-shorthand-properties t) 693 ("typescript.referencesCodeLens.enabled" lsp-typescript-references-code-lens-enabled t) 694 ("typescript.reportStyleChecksAsWarnings" lsp-typescript-report-style-checks-as-warnings t) 695 ("typescript.suggest.autoImports" lsp-typescript-suggest-auto-imports t) 696 ("typescript.suggest.completeFunctionCalls" lsp-typescript-suggest-complete-function-calls t) 697 ("typescript.suggest.completeJSDocs" lsp-typescript-suggest-complete-js-docs t) 698 ("typescript.suggest.enabled" lsp-typescript-suggest-enabled t) 699 ("typescript.suggest.paths" lsp-typescript-suggest-paths t) 700 ("typescript.suggestionActions.enabled" lsp-typescript-suggestion-actions-enabled t) 701 ("typescript.surveys.enabled" lsp-typescript-surveys-enabled t) 702 ("typescript.tsc.autoDetect" lsp-typescript-tsc-auto-detect) 703 ("typescript.tsdk" lsp-typescript-tsdk) 704 ("typescript.tsserver.log" lsp-typescript-tsserver-log) 705 ("typescript.tsserver.pluginPaths" lsp-typescript-tsserver-plugin-paths) 706 ("typescript.tsserver.trace" lsp-typescript-tsserver-trace) 707 ("typescript.updateImportsOnFileMove.enabled" lsp-typescript-update-imports-on-file-move-enabled) 708 ("typescript.validate.enable" lsp-typescript-validate-enable t) 709 ("typescript.format.enable" lsp-typescript-format-enable t) 710 ("typescript.format.insertSpaceAfterCommaDelimiter" lsp-typescript-format-insert-space-after-comma-delimiter t) 711 ("typescript.format.insertSpaceAfterConstructor" lsp-typescript-format-insert-space-after-constructor t) 712 ("typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions" lsp-typescript-format-insert-space-after-function-keyword-for-anonymous-functions t) 713 ("typescript.format.insertSpaceAfterKeywordsInControlFlowStatements" lsp-typescript-format-insert-space-after-keywords-in-control-flow-statements t) 714 ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces t) 715 ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-empty-braces t) 716 ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-braces t) 717 ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets t) 718 ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis t) 719 ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-template-string-braces t) 720 ("typescript.format.insertSpaceAfterSemicolonInForStatements" lsp-typescript-format-insert-space-after-semicolon-in-for-statements t) 721 ("typescript.format.insertSpaceAfterTypeAssertion" lsp-typescript-format-insert-space-after-type-assertion t) 722 ("typescript.format.insertSpaceBeforeAndAfterBinaryOperators" lsp-typescript-format-insert-space-before-and-after-binary-operators t) 723 ("typescript.format.insertSpaceBeforeFunctionParenthesis" lsp-typescript-format-insert-space-before-function-parenthesis t) 724 ("typescript.format.placeOpenBraceOnNewLineForControlBlocks" lsp-typescript-format-place-open-brace-on-new-line-for-control-blocks t) 725 ("typescript.format.placeOpenBraceOnNewLineForFunctions" lsp-typescript-format-place-open-brace-on-new-line-for-functions t) 726 ("typescript.inlayHints.includeInlayEnumMemberValueHints" lsp-javascript-display-enum-member-value-hints t) 727 ("typescript.inlayHints.includeInlayFunctionLikeReturnTypeHints" lsp-javascript-display-return-type-hints t) 728 ("typescript.inlayHints.includeInlayFunctionParameterTypeHints" lsp-javascript-display-parameter-type-hints t) 729 ("typescript.inlayHints.includeInlayParameterNameHints" lsp-javascript-display-parameter-name-hints nil) 730 ("typescript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName" lsp-javascript-display-parameter-name-hints-when-argument-matches-name t) 731 ("typescript.inlayHints.includeInlayPropertyDeclarationTypeHints" lsp-javascript-display-property-declaration-type-hints t) 732 ("typescript.inlayHints.includeInlayVariableTypeHints" lsp-javascript-display-variable-type-hints t) 733 ("javascript.inlayHints.includeInlayEnumMemberValueHints" lsp-javascript-display-enum-member-value-hints t) 734 ("javascript.inlayHints.includeInlayFunctionLikeReturnTypeHints" lsp-javascript-display-return-type-hints t) 735 ("javascript.inlayHints.includeInlayFunctionParameterTypeHints" lsp-javascript-display-parameter-type-hints t) 736 ("javascript.inlayHints.includeInlayParameterNameHints" lsp-javascript-display-parameter-name-hints nil) 737 ("javascript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName" lsp-javascript-display-parameter-name-hints-when-argument-matches-name t) 738 ("javascript.inlayHints.includeInlayPropertyDeclarationTypeHints" lsp-javascript-display-property-declaration-type-hints t) 739 ("javascript.inlayHints.includeInlayVariableTypeHints" lsp-javascript-display-variable-type-hints t) 740 ("completions.completeFunctionCalls" lsp-javascript-completions-complete-function-calls t))) 741 742 (lsp-dependency 'typescript-language-server 743 '(:system lsp-clients-typescript-tls-path) 744 '(:npm :package "typescript-language-server" 745 :path "typescript-language-server")) 746 747 (lsp-dependency 'typescript 748 '(:system "tsserver") 749 '(:npm :package "typescript" 750 :path "tsserver")) 751 752 (defun lsp-javascript--rename (_workspace args) 753 (let ((path (lsp--uri-to-path (lsp-get (lsp-get args :textDocument) :uri)))) 754 (if (f-exists? path) 755 (with-current-buffer (find-file path) 756 (goto-char (lsp--position-to-point 757 (lsp-get args :position)))) 758 (error "There is no file %s" path))) 759 (call-interactively #'lsp-rename) 760 nil) 761 762 (defun lsp-javascript-rename-file () 763 "Rename current file and all it's references in other files." 764 (interactive) 765 (let* ((name (buffer-name)) 766 (old (buffer-file-name)) 767 (basename (file-name-nondirectory old))) 768 (unless (and old (file-exists-p old)) 769 (error "Buffer '%s' is not visiting a file." name)) 770 (let ((new (read-file-name "New name: " (file-name-directory old) basename nil basename))) 771 (when (get-file-buffer new) 772 (error "A buffer named '%s' already exists." new)) 773 (when (file-exists-p new) 774 (error "A file named '%s' already exists." new)) 775 (lsp--send-execute-command 776 "_typescript.applyRenameFile" 777 (vector (list :sourceUri (lsp--buffer-uri) 778 :targetUri (lsp--path-to-uri new)))) 779 (mkdir (file-name-directory new) t) 780 (rename-file old new) 781 (rename-buffer new) 782 (set-visited-file-name new) 783 (set-buffer-modified-p nil) 784 (lsp-disconnect) 785 (setq-local lsp-buffer-uri nil) 786 (lsp) 787 (lsp--info "Renamed '%s' to '%s'." name (file-name-nondirectory new))))) 788 789 (defun lsp-javascript-initialized? () 790 (when-let* ((workspace (lsp-find-workspace 'ts-ls (buffer-file-name)))) 791 (eq 'initialized (lsp--workspace-status workspace)))) 792 793 (defun lsp-clients-typescript-require-resolve (&optional dir) 794 "Get the location of the typescript. 795 Use Node.js require. 796 The node_modules directory structure is suspect 797 and should be trusted as little as possible. 798 If you call require in Node.js, 799 it should take into account the various hooks. 800 For example, yarn PnP. 801 802 Optional argument DIR specifies the working directory 803 to run the command in." 804 (when-let* 805 ((default-directory (or dir default-directory)) 806 (output 807 (string-trim-right 808 (shell-command-to-string 809 "node -e \"console.log(require.resolve('typescript'))\""))) 810 (not-empty (not (string-empty-p output)))) 811 (f-parent output))) 812 813 (defun lsp-clients-typescript-server-path () 814 "Return the TS server path based on settings." 815 (if-let* ((use-project-ts lsp-clients-typescript-prefer-use-project-ts-server) 816 (server-path (lsp-clients-typescript-require-resolve)) 817 (server-path-exist (f-exists? server-path))) 818 server-path 819 (if (memq system-type '(cygwin windows-nt ms-dos)) 820 ;; The Windows environment does not recognize the top-level PATH returned by `lsp-package-path', 821 ;; so the real PATH is returned through Node.js. 822 (lsp-clients-typescript-require-resolve (f-parent (lsp-package-path 'typescript))) 823 (lsp-package-path 'typescript)))) 824 825 (lsp-register-client 826 (make-lsp-client :new-connection (lsp-stdio-connection (lambda () 827 `(,(lsp-package-path 'typescript-language-server) 828 ,@lsp-clients-typescript-server-args))) 829 :activation-fn 'lsp-typescript-javascript-tsx-jsx-activate-p 830 :priority -2 831 :completion-in-comments? t 832 :initialization-options (lambda () 833 (append 834 (when lsp-clients-typescript-disable-automatic-typing-acquisition 835 (list :disableAutomaticTypingAcquisition lsp-clients-typescript-disable-automatic-typing-acquisition)) 836 (when lsp-clients-typescript-log-verbosity 837 (list :logVerbosity lsp-clients-typescript-log-verbosity)) 838 (when lsp-clients-typescript-max-ts-server-memory 839 (list :maxTsServerMemory lsp-clients-typescript-max-ts-server-memory)) 840 (when lsp-clients-typescript-npm-location 841 (list :npmLocation lsp-clients-typescript-npm-location)) 842 (when lsp-clients-typescript-plugins 843 (list :plugins lsp-clients-typescript-plugins)) 844 (when lsp-clients-typescript-preferences 845 (list :preferences lsp-clients-typescript-preferences)) 846 `(:tsserver ( :path ,(lsp-clients-typescript-server-path) 847 ,@lsp-clients-typescript-tsserver)))) 848 :initialized-fn (lambda (workspace) 849 (with-lsp-workspace workspace 850 (lsp--set-configuration 851 (ht-merge (lsp-configuration-section "javascript") 852 (lsp-configuration-section "typescript") 853 (lsp-configuration-section "completions") 854 (lsp-configuration-section "diagnostics")))) 855 (let ((caps (lsp--workspace-server-capabilities workspace)) 856 (format-enable (or lsp-javascript-format-enable lsp-typescript-format-enable))) 857 (lsp:set-server-capabilities-document-formatting-provider? caps format-enable) 858 (lsp:set-server-capabilities-document-range-formatting-provider? caps format-enable))) 859 :ignore-messages '("readFile .*? requested by TypeScript but content not available") 860 :server-id 'ts-ls 861 :request-handlers (ht ("_typescript.rename" #'lsp-javascript--rename)) 862 :download-server-fn (lambda (_client callback error-callback _update?) 863 (lsp-package-ensure 864 'typescript 865 (-partial #'lsp-package-ensure 866 'typescript-language-server 867 callback 868 error-callback) 869 error-callback)))) 870 871 872 (defgroup lsp-flow nil 873 "LSP support for the Flow Javascript type checker." 874 :group 'lsp-mode 875 :link '(url-link "https://flow.org")) 876 877 (defcustom lsp-clients-flow-server "flow" 878 "The Flow executable to use. 879 Leave as just the executable name to use the default behavior of 880 finding the executable with variable `exec-path'." 881 :group 'lsp-flow 882 :risky t 883 :type 'file) 884 885 (defcustom lsp-clients-flow-server-args '("lsp") 886 "Extra arguments for starting the Flow language server." 887 :group 'lsp-flow 888 :risky t 889 :type '(repeat string)) 890 891 (defun lsp-clients-flow-tag-file-present-p (file-name) 892 "Check if the '// @flow' or `/* @flow */' tag is present in 893 the contents of FILE-NAME." 894 (if-let* ((buffer (find-buffer-visiting file-name))) 895 (with-current-buffer buffer 896 (lsp-clients-flow-tag-string-present-p)) 897 (with-temp-buffer 898 (insert-file-contents file-name) 899 (lsp-clients-flow-tag-string-present-p)))) 900 901 (defun lsp-clients-flow-tag-string-present-p () 902 "Helper for `lsp-clients-flow-tag-file-present-p' that works 903 with the file contents." 904 (save-excursion 905 (goto-char (point-min)) 906 (let (stop found) 907 (while (not stop) 908 (unless (re-search-forward "[^\n[:space:]]" nil t) 909 (setq stop t)) 910 (if (= (point) (point-min)) (setq stop t) (backward-char)) 911 (cond ((or (looking-at-p "//+[ ]*@flow") 912 (looking-at-p "/\\**[ ]*@flow") 913 (looking-at-p "[ ]*\\*[ ]*@flow")) 914 (setq found t) (setq stop t)) 915 ((or (looking-at-p "//") (looking-at-p "*")) 916 (forward-line)) 917 ((looking-at-p "/\\*") 918 (save-excursion 919 (unless (re-search-forward "*/" nil t) (setq stop t))) 920 (forward-line)) 921 (t (setq stop t)))) 922 found))) 923 924 (defun lsp-clients-flow-project-p (file-name) 925 "Check if FILE-NAME is part of a Flow project, that is, if 926 there is a .flowconfig file in the folder hierarchy." 927 (locate-dominating-file file-name ".flowconfig")) 928 929 (defun lsp-clients-flow-activate-p (file-name _mode) 930 "Check if the Flow language server should be enabled for a 931 particular FILE-NAME and MODE." 932 (and (derived-mode-p 'js-mode 'web-mode 'js2-mode 'flow-js2-mode 'rjsx-mode) 933 (not (derived-mode-p 'json-mode)) 934 (or (lsp-clients-flow-project-p file-name) 935 (lsp-clients-flow-tag-file-present-p file-name)))) 936 937 (lsp-register-client 938 (make-lsp-client :new-connection 939 (lsp-stdio-connection (lambda () 940 (cons lsp-clients-flow-server 941 lsp-clients-flow-server-args))) 942 :priority -1 943 :activation-fn 'lsp-clients-flow-activate-p 944 :server-id 'flow-ls)) 945 946 (defgroup lsp-deno nil 947 "LSP support for the Deno language server." 948 :group 'lsp-mode 949 :link '(url-link "https://deno.land/")) 950 951 (defcustom lsp-clients-deno-server "deno" 952 "The Deno executable to use. 953 Leave as just the executable name to use the default behavior of 954 finding the executable with variable `exec-path'." 955 :group 'lsp-deno 956 :risky t 957 :type 'file 958 :package-version '(lsp-mode . "8.0.0")) 959 960 (defcustom lsp-clients-deno-server-args '("lsp") 961 "Extra arguments for starting the Deno language server." 962 :group 'lsp-deno 963 :risky t 964 :type '(repeat string) 965 :package-version '(lsp-mode . "8.0.0")) 966 967 (defcustom lsp-clients-deno-enable-lint t 968 "Controls if linting information will be provided by the Deno Language Server." 969 :group 'lsp-deno 970 :risky t 971 :type 'boolean 972 :package-version '(lsp-mode . "8.0.0")) 973 974 (defcustom lsp-clients-deno-enable-code-lens-references t 975 "Enables or disables the display of code lens information." 976 :group 'lsp-deno 977 :risky t 978 :type 'boolean 979 :package-version '(lsp-mode . "8.0.0")) 980 981 (defcustom lsp-clients-deno-enable-code-lens-references-all-functions t 982 "Enables or disables the display of code lens information for all functions. 983 Setting this variable to `non-nil' implicitly enables 984 `lsp-clients-deno-enable-code-lens-references'." 985 :group 'lsp-deno 986 :risky t 987 :type 'boolean 988 :package-version '(lsp-mode . "8.0.0")) 989 990 (defcustom lsp-clients-deno-enable-code-lens-implementations t 991 "Enables or disables the display of code lens information for implementations." 992 :group 'lsp-deno 993 :risky t 994 :type 'boolean 995 :package-version '(lsp-mode . "8.0.0")) 996 997 (defcustom lsp-clients-deno-config nil 998 "The file path to a tsconfig.json file. 999 The path can be either be relative to the workspace, or an 1000 absolute path. 1001 1002 Examples: `./tsconfig.json', 1003 `/path/to/tsconfig.json', `C:\\path\\to\\tsconfig.json'" 1004 :group 'lsp-deno 1005 :risky t 1006 :type 'file 1007 :package-version '(lsp-mode . "8.0.0")) 1008 1009 (defcustom lsp-clients-deno-import-map nil 1010 "The file path to an import map. 1011 Import maps provide a way to relocate modules based on their 1012 specifiers. The path can either be relative to the workspace, or 1013 an absolute path. 1014 1015 Examples: `./import-map.json', 1016 `/path/to/import-map.json', `C:\\path\\to\\import-map.json'." 1017 :group 'lsp-deno 1018 :risky t 1019 :type 'file 1020 :package-version '(lsp-mode . "8.0.0")) 1021 1022 (defcustom lsp-clients-deno-enable-unstable nil 1023 "Controls if code will be type checked with Deno's unstable APIs." 1024 :group 'lsp-deno 1025 :risky t 1026 :type 'boolean 1027 :package-version '(lsp-mode . "8.0.0")) 1028 1029 (defun lsp-clients-deno--make-init-options () 1030 "Initialization options for the Deno language server." 1031 `( :enable t 1032 :config ,lsp-clients-deno-config 1033 :importMap ,lsp-clients-deno-import-map 1034 :lint ,(lsp-json-bool lsp-clients-deno-enable-lint) 1035 :unstable ,(lsp-json-bool lsp-clients-deno-enable-unstable) 1036 :codeLens ( :implementations ,(lsp-json-bool lsp-clients-deno-enable-code-lens-implementations) 1037 :references ,(lsp-json-bool (or lsp-clients-deno-enable-code-lens-references 1038 lsp-clients-deno-enable-code-lens-references-all-functions)) 1039 :referencesAllFunctions ,(lsp-json-bool lsp-clients-deno-enable-code-lens-references-all-functions)))) 1040 1041 (lsp-register-client 1042 (make-lsp-client :new-connection 1043 (lsp-stdio-connection (lambda () 1044 (cons lsp-clients-deno-server 1045 lsp-clients-deno-server-args))) 1046 :initialization-options #'lsp-clients-deno--make-init-options 1047 :priority -5 1048 :activation-fn #'lsp-typescript-javascript-tsx-jsx-activate-p 1049 :server-id 'deno-ls)) 1050 1051 (lsp-consistency-check lsp-javascript) 1052 1053 (provide 'lsp-javascript) 1054 ;;; lsp-javascript.el ends here