├── .gitattributes ├── .gitignore ├── .python-version ├── LICENSE ├── LSP-typescript.sublime-commands ├── LSP-typescript.sublime-settings ├── Main.sublime-menu ├── README.md ├── commands.py ├── dependencies.json ├── messages.json ├── messages ├── 1.13.0.txt ├── 1.6.0.txt └── 2.3.0.txt ├── plugin.py ├── plugin_types.py ├── pyrightconfig.json ├── sublime-package.json └── typescript-language-server ├── package-lock.json └── package.json /.gitattributes: -------------------------------------------------------------------------------- 1 | .dependabot export-ignore 2 | .github/ export-ignore 3 | codecov.yml export-ignore 4 | mypy.ini export-ignore 5 | tests/ export-ignore 6 | tox.ini export-ignore 7 | unittesting.json export-ignore 8 | images/ export-ignore 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .mypy_cache 3 | -------------------------------------------------------------------------------- /.python-version: -------------------------------------------------------------------------------- 1 | 3.8 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 SublimeLSP 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LSP-typescript.sublime-commands: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "caption": "Preferences: LSP-typescript Settings", 4 | "command": "edit_settings", 5 | "args": { 6 | "base_file": "${packages}/LSP-typescript/LSP-typescript.sublime-settings", 7 | "default": "// Settings in here override those in \"LSP-typescript/LSP-typescript.sublime-settings\"\n\n{\n\t$0\n}\n" 8 | } 9 | }, 10 | { 11 | "caption": "LSP-typescript: Organize Imports", 12 | "command": "lsp_typescript_execute", 13 | "args": { 14 | "command_name": "_typescript.organizeImports", 15 | "command_args": ["${file}"] 16 | } 17 | }, 18 | { 19 | "caption": "LSP-typescript: Goto Source Definition", 20 | "command": "lsp_typescript_goto_source_definition", 21 | "args": { 22 | "command_name": "_typescript.goToSourceDefinition", 23 | "command_args": ["$file_uri", "$position"] 24 | }, 25 | }, 26 | ] 27 | -------------------------------------------------------------------------------- /LSP-typescript.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "initializationOptions": { 3 | "completionDisableFilterText": true, 4 | "disableAutomaticTypingAcquisition": false, 5 | "locale": "en", 6 | "maxTsServerMemory": 0, 7 | "npmLocation": "", 8 | "plugins": [], 9 | "preferences": { 10 | "allowIncompleteCompletions": true, 11 | "allowRenameOfImportPath": true, 12 | "allowTextChangesInNewFiles": true, 13 | "autoImportFileExcludePatterns": [], 14 | "disableSuggestions": false, 15 | "displayPartsForJSDoc": true, 16 | "excludeLibrarySymbolsInNavTo": true, 17 | "generateReturnInDocTemplate": true, 18 | "importModuleSpecifierEnding": "auto", 19 | "importModuleSpecifierPreference": "shortest", 20 | "includeAutomaticOptionalChainCompletions": true, 21 | "includeCompletionsForImportStatements": true, 22 | "includeCompletionsForModuleExports": true, 23 | "includeCompletionsWithClassMemberSnippets": true, 24 | "includeCompletionsWithInsertText": true, 25 | "includeCompletionsWithObjectLiteralMethodSnippets": true, 26 | "includeCompletionsWithSnippetText": true, 27 | "includePackageJsonAutoImports": "auto", 28 | "interactiveInlayHints": true, 29 | "jsxAttributeCompletionStyle": "auto", 30 | "lazyConfiguredProjectsFromExternalProject": false, 31 | "organizeImportsIgnoreCase": "auto", 32 | "organizeImportsCollation": "ordinal", 33 | "organizeImportsCollationLocale": "en", 34 | "organizeImportsNumericCollation": false, 35 | "organizeImportsAccentCollation": true, 36 | "organizeImportsCaseFirst": false, 37 | "providePrefixAndSuffixTextForRename": true, 38 | "provideRefactorNotApplicableReason": true, 39 | "quotePreference": "auto", 40 | "useLabelDetailsInCompletionEntries": true, 41 | }, 42 | "tsserver.logDirectory": "", 43 | "tsserver.logVerbosity": "off", 44 | "tsserver.path": "", 45 | "tsserver.fallbackPath": "", 46 | "tsserver.trace": "off", 47 | "tsserver.useSyntaxServer": "auto", 48 | }, 49 | "settings": { 50 | "statusText": "$version, $source", 51 | "diagnostics.ignoredCodes": [], 52 | 53 | // Implicit Project Configuration 54 | "implicitProjectConfiguration.checkJs": false, 55 | "implicitProjectConfiguration.experimentalDecorators": false, 56 | "implicitProjectConfiguration.module": "ESNext", 57 | "implicitProjectConfiguration.strictFunctionTypes": true, 58 | "implicitProjectConfiguration.strictNullChecks": true, 59 | "implicitProjectConfiguration.target": "ES2020", 60 | 61 | // Formatting options. 62 | "javascript.format.insertSpaceAfterCommaDelimiter": true, 63 | "javascript.format.insertSpaceAfterConstructor": false, 64 | "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true, 65 | "javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": true, 66 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false, 67 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false, 68 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true, 69 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, 70 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, 71 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, 72 | "javascript.format.insertSpaceAfterSemicolonInForStatements": true, 73 | "javascript.format.insertSpaceAfterTypeAssertion": false, 74 | "javascript.format.insertSpaceBeforeAndAfterBinaryOperators": true, 75 | "javascript.format.insertSpaceBeforeFunctionParenthesis": false, 76 | "javascript.format.insertSpaceBeforeTypeAnnotation": false, 77 | "javascript.format.placeOpenBraceOnNewLineForControlBlocks": false, 78 | "javascript.format.placeOpenBraceOnNewLineForFunctions": false, 79 | "javascript.format.semicolons": "ignore", // ignore | insert | remove 80 | "javascript.format.trimTrailingWhitespace": true, 81 | "typescript.format.insertSpaceAfterCommaDelimiter": true, 82 | "typescript.format.insertSpaceAfterConstructor": false, 83 | "typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true, 84 | "typescript.format.insertSpaceAfterKeywordsInControlFlowStatements": true, 85 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false, 86 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false, 87 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true, 88 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, 89 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, 90 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, 91 | "typescript.format.insertSpaceAfterSemicolonInForStatements": true, 92 | "typescript.format.insertSpaceAfterTypeAssertion": false, 93 | "typescript.format.insertSpaceBeforeAndAfterBinaryOperators": true, 94 | "typescript.format.insertSpaceBeforeFunctionParenthesis": false, 95 | "typescript.format.insertSpaceBeforeTypeAnnotation": false, 96 | "typescript.format.placeOpenBraceOnNewLineForControlBlocks": false, 97 | "typescript.format.placeOpenBraceOnNewLineForFunctions": false, 98 | "typescript.format.semicolons": "ignore", // ignore | insert | remove 99 | "typescript.format.trimTrailingWhitespace": true, 100 | 101 | // Inlay hints options. 102 | "javascript.inlayHints.includeInlayEnumMemberValueHints": false, 103 | "javascript.inlayHints.includeInlayFunctionLikeReturnTypeHints": false, 104 | "javascript.inlayHints.includeInlayFunctionParameterTypeHints": false, 105 | "javascript.inlayHints.includeInlayParameterNameHints": "none", // none | literals | all 106 | "javascript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName": false, 107 | "javascript.inlayHints.includeInlayPropertyDeclarationTypeHints": false, 108 | "javascript.inlayHints.includeInlayVariableTypeHints": false, 109 | "javascript.inlayHints.includeInlayVariableTypeHintsWhenTypeMatchesName": false, 110 | "typescript.inlayHints.includeInlayEnumMemberValueHints": false, 111 | "typescript.inlayHints.includeInlayFunctionLikeReturnTypeHints": false, 112 | "typescript.inlayHints.includeInlayFunctionParameterTypeHints": false, 113 | "typescript.inlayHints.includeInlayParameterNameHints": "none", // none | literals | all 114 | "typescript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName": false, 115 | "typescript.inlayHints.includeInlayPropertyDeclarationTypeHints": false, 116 | "typescript.inlayHints.includeInlayVariableTypeHints": false, 117 | "typescript.inlayHints.includeInlayVariableTypeHintsWhenTypeMatchesName": false, 118 | 119 | // Code Lens options. 120 | "javascript.implementationsCodeLens.enabled": false, 121 | "javascript.referencesCodeLens.enabled": false, 122 | "javascript.referencesCodeLens.showOnAllFunctions": false, 123 | "typescript.implementationsCodeLens.enabled": false, 124 | "typescript.referencesCodeLens.enabled": false, 125 | "typescript.referencesCodeLens.showOnAllFunctions": false, 126 | }, 127 | "command": [ 128 | "${node_bin}", 129 | "${server_path}", 130 | "--stdio" 131 | ], 132 | "selector": "source.js, source.jsx, source.ts, source.tsx", 133 | "schemes": [ 134 | "file", // regular files 135 | "buffer", // in-memory buffers 136 | ], 137 | } 138 | -------------------------------------------------------------------------------- /Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "preferences", 4 | "children": [ 5 | { 6 | "caption": "Package Settings", 7 | "mnemonic": "P", 8 | "id": "package-settings", 9 | "children": [ 10 | { 11 | "caption": "LSP", 12 | "id": "lsp-settings", 13 | "children": [ 14 | { 15 | "caption": "Servers", 16 | "id": "lsp-servers", 17 | "children": [ 18 | { 19 | "caption": "LSP-typescript", 20 | "command": "edit_settings", 21 | "args": { 22 | "base_file": "${packages}/LSP-typescript/LSP-typescript.sublime-settings", 23 | "default": "// Settings in here override those in \"LSP-typescript/LSP-typescript.sublime-settings\"\n\n{\n\t$0\n}\n", 24 | } 25 | } 26 | ] 27 | } 28 | ] 29 | } 30 | ] 31 | } 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LSP-typescript 2 | 3 | TypeScript and JavaScript support for Sublime's LSP plugin provided through [TypeScript Language Server](https://github.com/typescript-language-server/typescript-language-server). 4 | 5 | ## Installation 6 | 7 | * Install [`LSP`](https://packagecontrol.io/packages/LSP) and `LSP-typescript` from Package Control. 8 | * For ST4: The TypeScript and React (TSX) syntaxes are built-in so no need to install anything else. 9 | * For ST3: If you are working with TypeScript install [TypeScript Syntax](https://packagecontrol.io/packages/TypeScript%20Syntax). If you are working with React install [JSCustom](https://packagecontrol.io/packages/JSCustom). 10 | * Restart Sublime. 11 | 12 | ## Configuration 13 | 14 | Open the configuration file using the Command Palette `Preferences: LSP-typescript Settings` command or open it from the Sublime menu. 15 | 16 | ## Organize Imports command 17 | 18 | To sort or remove unused imports you can trigger the `LSP-typescript: Organize Imports` command from the Command Palette or create a key binding. For example: 19 | 20 | ```json 21 | { "keys": ["ctrl+k"], "command": "lsp_execute", 22 | "args": { 23 | "session_name": "LSP-typescript", 24 | "command_name": "_typescript.organizeImports", 25 | "command_args": ["${file}"] 26 | } 27 | }, 28 | ``` 29 | 30 | ## Code Actions on Save 31 | 32 | The server supports the following code actions that can be specified in the global `lsp_code_actions_on_save` setting and run on saving files: 33 | 34 | - `source.addMissingImports.ts` - adds imports for used but not imported symbols 35 | - `source.fixAll.ts` - despite the name, fixes a couple of specific issues: unreachable code, await in non-async functions, incorrectly implemented interface 36 | - `source.organizeImports.ts` - organizes and removes unused imports 37 | - `source.removeUnused.ts` - removes declared but unused variables 38 | - `source.removeUnusedImports.ts` - removes unused imports 39 | - `source.sortImports.ts` - sorts imports 40 | 41 | ## Goto Source Definition command 42 | 43 | TypeScript 4.7+ supports Go To Source Definition. It’s similar to Go To Definition, but it never returns results inside declaration files. Instead, it tries to find corresponding implementation files (like .js or .ts files), and find definitions there — even if those files are normally shadowed by .d.ts files. 44 | 45 | This comes in handy most often when you need to peek at the implementation of a function you're importing from a library instead of its type declaration in a .d.ts file. 46 | 47 | Run `LSP-typescript: Goto Source Definition` from the Command Palette to invoke this functionality or bind `lsp_typescript_goto_source_definition` to a custom key binding. 48 | 49 | ## Inlay hints 50 | 51 | Inlay hints are short textual annotations that show parameter names, type hints. 52 | 53 | ![inlay-hints](./images/inlay-hints.png) 54 | 55 | To enable inlay hints: 56 | 57 | 1. Open the command palette and select `Preferences: LSP Settings`, then enable `show_inlay_hints`: 58 | 59 | ```js 60 | { 61 | "show_inlay_hints": true 62 | } 63 | ``` 64 | 65 | 2. Modify the following settings through `Preferences: LSP-typescript Settings`: 66 | 67 | ```js 68 | { 69 | "settings": { 70 | // Javascript inlay hints options. 71 | "javascript.inlayHints.includeInlayEnumMemberValueHints": false, 72 | "javascript.inlayHints.includeInlayFunctionLikeReturnTypeHints": false, 73 | "javascript.inlayHints.includeInlayFunctionParameterTypeHints": false, 74 | "javascript.inlayHints.includeInlayParameterNameHints": "none", 75 | "javascript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName": false, 76 | "javascript.inlayHints.includeInlayPropertyDeclarationTypeHints": false, 77 | "javascript.inlayHints.includeInlayVariableTypeHints": false, 78 | // Typescript inlay hints options. 79 | "typescript.inlayHints.includeInlayEnumMemberValueHints": false, 80 | "typescript.inlayHints.includeInlayFunctionLikeReturnTypeHints": false, 81 | "typescript.inlayHints.includeInlayFunctionParameterTypeHints": false, 82 | "typescript.inlayHints.includeInlayParameterNameHints": "none", 83 | "typescript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName": false, 84 | "typescript.inlayHints.includeInlayPropertyDeclarationTypeHints": false, 85 | "typescript.inlayHints.includeInlayVariableTypeHints": false, 86 | } 87 | } 88 | ``` 89 | 90 | Note: Inlay hints require TypeScript 4.4+. 91 | 92 | ## Usage in projects that also use Flow 93 | 94 | TypeScript can [check vanilla JavaScript](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html), but may break on JavaScript with Flow types in it. To keep LSP-typescript enabled for TS and vanilla JS, while ignoring Flow-typed files, you must install [JSCustom](https://packagecontrol.io/packages/JSCustom) and configure it like so: 95 | 96 | ```json 97 | { 98 | "configurations": { 99 | "Flow": { 100 | "scope": "source.js.flow", 101 | "flow_types": true, 102 | "jsx": true 103 | } 104 | } 105 | } 106 | ``` 107 | 108 | Also install [ApplySyntax](https://packagecontrol.io/packages/ApplySyntax) and configure it like so: 109 | 110 | ```json 111 | { 112 | "syntaxes": [ 113 | { 114 | "syntax": "User/JS Custom/Syntaxes/Flow", 115 | "match": "all", 116 | "rules": [ 117 | { "file_path": ".*\\.jsx?$" }, 118 | { "first_line": "^/[/\\*] *@flow" } 119 | ] 120 | } 121 | ] 122 | } 123 | ``` 124 | 125 | And then configure LSP-typescript like so: 126 | 127 | ```json 128 | { 129 | "selector": "source.js - source.js.flow, source.jsx, source.ts, source.tsx" 130 | } 131 | ``` 132 | 133 | This works only on Sublime Text 4, and your project must have a `// @flow` or `/* @flow */` in each Flow-typed file. For more information, see [this issue](https://github.com/sublimelsp/LSP-typescript/issues/60). 134 | -------------------------------------------------------------------------------- /commands.py: -------------------------------------------------------------------------------- 1 | from LSP.plugin.core.protocol import Location, LocationLink 2 | from LSP.plugin.core.typing import List, Union 3 | from LSP.plugin.execute_command import LspExecuteCommand 4 | from LSP.plugin.locationpicker import LocationPicker 5 | 6 | 7 | SESSION_NAME = __package__ 8 | 9 | 10 | class LspTypescriptExecuteCommand(LspExecuteCommand): 11 | session_name = SESSION_NAME 12 | 13 | 14 | class LspTypescriptGotoSourceDefinitionCommand(LspTypescriptExecuteCommand): 15 | def handle_success_async(self, result: Union[List[Location], List[LocationLink]], command_name: str) -> None: 16 | window = self.view.window() 17 | if not result: 18 | if window: 19 | window.status_message('No source definitions found') 20 | return 21 | session = self.session_by_name() 22 | if not session: 23 | return 24 | if len(result) == 1: 25 | args = { 26 | 'location': result[0], 27 | 'session_name': self.session_name, 28 | } 29 | if window: 30 | window.run_command('lsp_open_location', args) 31 | else: 32 | LocationPicker(self.view, session, result, side_by_side=False) 33 | -------------------------------------------------------------------------------- /dependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "*": { 3 | "*": [ 4 | "lsp_utils", 5 | "sublime_lib" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.6.0": "messages/1.6.0.txt" 3 | } 4 | -------------------------------------------------------------------------------- /messages/1.13.0.txt: -------------------------------------------------------------------------------- 1 | # Features and Fixes 2 | 3 | - Experimental inlay hints implementation was removed and replaced by an official implementation which is now controlled by the `show_inlay_hints` setting in the main LSP Settings. More information: https://github.com/sublimelsp/LSP-typescript/blob/master/README.md#inlay-hints 4 | - Added `LSP-typescript: Goto Source Definition` command. More information: https://github.com/sublimelsp/LSP-typescript/blob/master/README.md#goto-source-definition-command 5 | -------------------------------------------------------------------------------- /messages/1.6.0.txt: -------------------------------------------------------------------------------- 1 | # Added support for experimental Inlay Hints 2 | 3 | Inlay hints are short textual annotations that show parameter names, type hints. 4 | 5 | To enable inlay hints, modify the following settings through `Preferences: LSP-typescript Settings`: 6 | 7 | ```js 8 | { 9 | "settings": { 10 | // Javascript inlay hints options. 11 | "javascript.inlayHints.includeInlayEnumMemberValueHints": false, 12 | "javascript.inlayHints.includeInlayFunctionLikeReturnTypeHints": false, 13 | "javascript.inlayHints.includeInlayFunctionParameterTypeHints": false, 14 | "javascript.inlayHints.includeInlayParameterNameHints": "none", 15 | "javascript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName": false, 16 | "javascript.inlayHints.includeInlayPropertyDeclarationTypeHints": false, 17 | "javascript.inlayHints.includeInlayVariableTypeHints": false, 18 | // Typescript inlay hints options. 19 | "typescript.inlayHints.includeInlayEnumMemberValueHints": false, 20 | "typescript.inlayHints.includeInlayFunctionLikeReturnTypeHints": false, 21 | "typescript.inlayHints.includeInlayFunctionParameterTypeHints": false, 22 | "typescript.inlayHints.includeInlayParameterNameHints": "none", 23 | "typescript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName": false, 24 | "typescript.inlayHints.includeInlayPropertyDeclarationTypeHints": false, 25 | "typescript.inlayHints.includeInlayVariableTypeHints": false, 26 | } 27 | } 28 | ``` 29 | 30 | Note: Inlay hints require TypeScript 4.4+. 31 | -------------------------------------------------------------------------------- /messages/2.3.0.txt: -------------------------------------------------------------------------------- 1 | # Features and Fixes 2 | 3 | Server now starts separate instance of the typescript (tsServer) process for handling semantic requests. This should 4 | improve performance in large projects (especially during loading). 5 | -------------------------------------------------------------------------------- /plugin.py: -------------------------------------------------------------------------------- 1 | from .plugin_types import TypescriptVersionNotificationParams 2 | from LSP.plugin import Session 3 | from LSP.plugin import uri_to_filename 4 | from LSP.plugin.core.protocol import Location, Point, TextDocumentPositionParams 5 | from LSP.plugin.core.typing import Any, Callable, List, Mapping, Tuple 6 | from LSP.plugin.core.views import point_to_offset 7 | from LSP.plugin.locationpicker import LocationPicker 8 | from lsp_utils import notification_handler 9 | from lsp_utils import NpmClientHandler 10 | from lsp_utils import request_handler 11 | import os 12 | import sublime 13 | 14 | 15 | def plugin_loaded() -> None: 16 | LspTypescriptPlugin.setup() 17 | 18 | 19 | def plugin_unloaded() -> None: 20 | LspTypescriptPlugin.cleanup() 21 | 22 | 23 | class LspTypescriptPlugin(NpmClientHandler): 24 | package_name = __package__ 25 | server_directory = 'typescript-language-server' 26 | server_binary_path = os.path.join(server_directory, 'node_modules', 'typescript-language-server', 'lib', 'cli.mjs') 27 | 28 | @classmethod 29 | def minimum_node_version(cls) -> Tuple[int, int, int]: 30 | return (14, 16, 0) 31 | 32 | @request_handler('_typescript.rename') 33 | def on_typescript_rename(self, params: TextDocumentPositionParams, respond: Callable[[None], None]) -> None: 34 | filename = uri_to_filename(params['textDocument']['uri']) 35 | view = sublime.active_window().open_file(filename) 36 | if view: 37 | lsp_point = Point.from_lsp(params['position']) 38 | point = point_to_offset(lsp_point, view) 39 | sel = view.sel() 40 | sel.clear() 41 | sel.add_all([point]) 42 | view.run_command('lsp_symbol_rename') 43 | # Server doesn't require any specific response. 44 | respond(None) 45 | 46 | @notification_handler('$/typescriptVersion') 47 | def on_typescript_version_async(self, params: TypescriptVersionNotificationParams) -> None: 48 | session = self.weaksession() 49 | if not session: 50 | return 51 | version_template = session.config.settings.get('statusText') 52 | if not version_template or not isinstance(version_template, str): 53 | return 54 | status_text = version_template.replace('$version', params['version']).replace('$source', params['source']) 55 | if status_text: 56 | session.set_config_status_async(status_text) 57 | 58 | def on_pre_server_command(self, command: Mapping[str, Any], done_callback: Callable[[], None]) -> bool: 59 | command_name = command['command'] 60 | if command_name == 'editor.action.showReferences': 61 | session = self.weaksession() 62 | if not session: 63 | return False 64 | self._handle_show_references(session, command['arguments'][2]) 65 | done_callback() 66 | return True 67 | return False 68 | 69 | def _handle_show_references(self, session: Session, references: List[Location]) -> None: 70 | view = session.window.active_view() 71 | if not view: 72 | return 73 | if len(references) == 1: 74 | args = { 75 | 'location': references[0], 76 | 'session_name': session.config.name, 77 | } 78 | session.window.run_command('lsp_open_location', args) 79 | elif references: 80 | LocationPicker(view, session, references, side_by_side=False) 81 | else: 82 | sublime.status_message('No references found') 83 | -------------------------------------------------------------------------------- /plugin_types.py: -------------------------------------------------------------------------------- 1 | from LSP.plugin.core.typing import Literal, TypedDict, Union 2 | 3 | 4 | TypescriptVersionNotificationParams = TypedDict('TypescriptVersionNotificationParams', { 5 | 'version': str, 6 | 'source': Union[Literal['bundled'], Literal['user-setting'], Literal['workspace']] 7 | }) 8 | -------------------------------------------------------------------------------- /pyrightconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "pythonVersion": "3.11" 3 | } 4 | -------------------------------------------------------------------------------- /sublime-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "contributions": { 3 | "settings": [ 4 | { 5 | "file_patterns": [ 6 | "/LSP-typescript.sublime-settings" 7 | ], 8 | "schema": { 9 | "$id": "sublime://settings/LSP-typescript", 10 | "definitions": { 11 | "PluginConfig": { 12 | "properties": { 13 | "initializationOptions": { 14 | "type": "object", 15 | "additionalProperties": false, 16 | "properties": { 17 | "hostInfo": { 18 | "type": "string", 19 | "markdownDescription": "Information about the host, for example `Emacs 24.4` or `Sublime Text version 3075`. This value is only relevant when using `yarn pnp` which might apply special logic for certain values." 20 | }, 21 | "completionDisableFilterText": { 22 | "type": "boolean", 23 | "default": false, 24 | "markdownDescription": "Don't set `filterText` property on completion items." 25 | }, 26 | "disableAutomaticTypingAcquisition": { 27 | "type": "boolean", 28 | "default": false, 29 | "markdownDescription": "Disables tsserver from automatically fetching missing type definitions (`@types` packages) for external modules." 30 | }, 31 | "locale": { 32 | "type": "string", 33 | "pattern": "^([a-z]+)([_\\-]([a-z]+))?$", 34 | "enum": [ 35 | "cs", 36 | "de", 37 | "en", 38 | "es", 39 | "fr", 40 | "it", 41 | "ja", 42 | "ko", 43 | "pl", 44 | "pt-br", 45 | "ru", 46 | "tr", 47 | "zh-cn", 48 | "zh-tw" 49 | ], 50 | "default": "en", 51 | "markdownDescription": "The locale to use for showing diagnostics." 52 | }, 53 | "maxTsServerMemory": { 54 | "type": "number", 55 | "markdownDescription": "The maximum size of the V8's old memory section in megabytes (for example `4096` means 4GB). The default value is dynamically configured by Node so can differ per system. Increase for very big projects that exceed allowed memory usage." 56 | }, 57 | "npmLocation": { 58 | "type": "string", 59 | "markdownDescription": "Specifies the path to the NPM executable used for Automatic Type Acquisition." 60 | }, 61 | "plugins": { 62 | "type": "array", 63 | "default": [], 64 | "items": { 65 | "type": "object", 66 | "properties": { 67 | "name": { 68 | "type": "string", 69 | "description": "The name of the plugin." 70 | }, 71 | "location": { 72 | "type": "string", 73 | "description": "The location of the plugin." 74 | }, 75 | "languages": { 76 | "type": "array", 77 | "description": "The additional language IDs that extend what the language server allows by default.", 78 | "items": { 79 | "type": "string" 80 | } 81 | }, 82 | "configNamespace": { 83 | "type": "string", 84 | "description": "The namespace that the language server will use to request workspace configuration from for the corresponding `languages`. If `languages` is not specified then this has no effect." 85 | } 86 | }, 87 | "defaultSnippets": [ 88 | { 89 | "body": { 90 | "name": "$0", 91 | "location": "$1" 92 | } 93 | } 94 | ] 95 | } 96 | }, 97 | "preferences": { 98 | "type": "object", 99 | "properties": { 100 | "allowIncompleteCompletions": { 101 | "type": "boolean", 102 | "default": true, 103 | "markdownDescription": "Allows import module names to be resolved in the initial completions request." 104 | }, 105 | "disableSuggestions": { 106 | "type": "boolean", 107 | }, 108 | "quotePreference": { 109 | "enum": [ 110 | "auto", 111 | "double", 112 | "single" 113 | ], 114 | }, 115 | "autoImportFileExcludePatterns": { 116 | "type": "array", 117 | "default": [], 118 | "markdownDescription": "Glob patterns of files to exclude from auto imports. Requires using TypeScript 4.8 or newer in the workspace.\n\nRelative paths are resolved relative to the workspace root." 119 | }, 120 | "includeCompletionsForModuleExports": { 121 | "type": "boolean", 122 | "markdownDescription": "If enabled, TypeScript will search through all external modules' exports and add them to the completions list. This affects lone identifier completions but not completions on the right hand side of `obj.`." 123 | }, 124 | "includeCompletionsForImportStatements": { 125 | "type": "boolean", 126 | "markdownDescription": "Enables auto-import-style completions on partially-typed import statements. E.g., allows `import write|` to be completed to `import { writeFile } from \"fs\"`." 127 | }, 128 | "includeCompletionsWithSnippetText": { 129 | "type": "boolean", 130 | "markdownDescription": "Allows completions to be formatted with snippet text, indicated by `CompletionItem[\"isSnippet\"]`." 131 | }, 132 | "includeCompletionsWithInsertText": { 133 | "type": "boolean", 134 | "markdownDescription": "If enabled, the completion list will include completions with invalid identifier names. For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `[\"x\"]`." 135 | }, 136 | "includeAutomaticOptionalChainCompletions": { 137 | "type": "boolean", 138 | "markdownDescription": "Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined values, with insertion text to replace preceding `.` tokens with `?.`." 139 | }, 140 | "includeCompletionsWithClassMemberSnippets": { 141 | "type": "boolean", 142 | "markdownDescription": "If enabled, completions for class members (e.g. methods and properties) will include a whole declaration for the member. E.g., `class A { f| }` could be completed to `class A { foo(): number {} }`, instead of `class A { foo }`.\n\nRequires TypeScript 4.5+." 143 | }, 144 | "includeCompletionsWithObjectLiteralMethodSnippets": { 145 | "type": "boolean", 146 | "default": true, 147 | "markdownDescription": "If enabled, object literal methods will have a method declaration completion entry in addition to the regular completion entry containing just the method name. E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`, in addition to `const objectLiteral: T = { foo }`. Requires TypeScript v4.7.2." 148 | }, 149 | "useLabelDetailsInCompletionEntries": { 150 | "type": "boolean", 151 | "default": true, 152 | "markdownDescription": "Indicates whether {@link CompletionEntry.labelDetails completion entry label details} are supported. If not, contents of `labelDetails` may be included in the {@link CompletionEntry.name} property. Only supported if the client supports `textDocument.completion.completionItem.labelDetailsSupport` capability and a compatible TypeScript version is used. Requires TypeScript v4.7.2." 153 | }, 154 | "importModuleSpecifierPreference": { 155 | "enum": [ 156 | "shortest", 157 | "project-relative", 158 | "relative", 159 | "non-relative" 160 | ], 161 | }, 162 | "importModuleSpecifierEnding": { 163 | "enum": [ 164 | "auto", 165 | "minimal", 166 | "index", 167 | "js" 168 | ], 169 | "markdownDescription": "Determines whether we import `foo/index.ts` as \"foo\", \"foo/index\", or \"foo/index.js\"." 170 | }, 171 | "allowTextChangesInNewFiles": { 172 | "type": "boolean", 173 | }, 174 | "lazyConfiguredProjectsFromExternalProject": { 175 | "type": "boolean", 176 | }, 177 | "organizeImportsIgnoreCase": { 178 | "enum": [ 179 | "auto", 180 | true, 181 | false 182 | ], 183 | "default": "auto", 184 | "markdownDescription": "Indicates whether imports should be organized in a case-insensitive manner." 185 | }, 186 | "organizeImportsCollation": { 187 | "enum": [ 188 | "ordinal", 189 | "unicode", 190 | ], 191 | "default": "ordinal", 192 | "markdownDescription": "Indicates whether imports should be organized via an `\"ordinal\"` (binary) comparison using the numeric value of their code points, or via `\"unicode\"` collation (via the [Unicode Collation Algorithm](https://unicode.org/reports/tr10/#Scope)) using rules associated with the locale specified in `organizeImportsCollationLocale`." 193 | }, 194 | "organizeImportsCollationLocale": { 195 | "type": "string", 196 | "default": "en", 197 | "markdownDescription": "Indicates the locale to use for `\"unicode\"` collation. If not specified, the locale `\"en\"` is used as an invariant for the sake of consistent sorting. Use `\"auto\"` to use the detected UI locale.\n\nThis preference is ignored if `organizeImportsCollation` is not `\"unicode\"`." 198 | }, 199 | "organizeImportsNumericCollation": { 200 | "type": "boolean", 201 | "default": false, 202 | "markdownDescription": "Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`.\n\nThis preference is ignored if `organizeImportsCollation` is not `\"unicode\"`." 203 | }, 204 | "organizeImportsAccentCollation": { 205 | "type": "boolean", 206 | "default": true, 207 | "markdownDescription": "Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified in `organizeImportsCollationLocale`.\n\nThis preference is ignored if {@link organizeImportsCollation} is not `\"unicode\"`." 208 | }, 209 | "organizeImportsCaseFirst": { 210 | "enum": [ 211 | "upper", 212 | "lower", 213 | false, 214 | ], 215 | "default": false, 216 | "markdownDescription": "Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale specified in `organizeImportsCollationLocale` is used.\n\nThis preference is ignored if `organizeImportsCollation` is not `\"unicode\"`. This preference is also ignored if we are using case-insensitive sorting, which occurs when `organizeImportsIgnoreCase` is `true`, or if `organizeImportsIgnoreCase` is `\"auto\"` and the auto-detected case sensitivity is determined to be case-insensitive." 217 | }, 218 | "providePrefixAndSuffixTextForRename": { 219 | "type": "boolean", 220 | }, 221 | "provideRefactorNotApplicableReason": { 222 | "type": "boolean", 223 | "default": true 224 | }, 225 | "allowRenameOfImportPath": { 226 | "type": "boolean", 227 | "default": true 228 | }, 229 | "includePackageJsonAutoImports": { 230 | "enum": [ 231 | "auto", 232 | "on", 233 | "off" 234 | ], 235 | "default": "auto" 236 | }, 237 | "displayPartsForJSDoc": { 238 | "type": "boolean", 239 | "default": true 240 | }, 241 | "excludeLibrarySymbolsInNavTo": { 242 | "type": "boolean", 243 | "default": true 244 | }, 245 | "generateReturnInDocTemplate": { 246 | "type": "boolean", 247 | "default": true 248 | }, 249 | "interactiveInlayHints": { 250 | "type": "boolean", 251 | "default": true 252 | }, 253 | "jsxAttributeCompletionStyle": { 254 | "enum": [ 255 | "auto", 256 | "braces", 257 | "none" 258 | ], 259 | "default": "auto", 260 | "markdownEnumDescriptions": [ 261 | "Insert `={}` or `=\"\"` after attribute names based on the prop type.", 262 | "Insert `={}` after attribute names.", 263 | "Only insert attribute names." 264 | ], 265 | "markdownDescription": "Preferred style for JSX attribute completions.\n\nRequires TypeScript 4.5+." 266 | } 267 | } 268 | }, 269 | "tsserver.logDirectory": { 270 | "type": "string", 271 | "default": "", 272 | "markdownDescription": "The path to the directory where the `tsserver` log files will be created. If not provided, the log files will be created within the workspace, inside the `.log` directory. If no workspace root is provided when initializating the server and no custom path is specified then the logs will not be created." 273 | }, 274 | "tsserver.logVerbosity": { 275 | "enum": [ 276 | "off", 277 | "terse", 278 | "normal", 279 | "requestTime", 280 | "verbose" 281 | ], 282 | "default": "off", 283 | "markdownDescription": "Verbosity of the information logged into the `tsserver` log files.\n\nLog levels from least to most amount of details: `'terse'`, `'normal'`, `'requestTime`', `'verbose'`. Enabling particular level also enables all lower levels.", 284 | }, 285 | "tsserver.path": { 286 | "type": "string", 287 | "default": "", 288 | "markdownDescription": "The path to the `tsserver.js` file or the typescript lib directory. For example: `/Users/me/typescript/lib/tsserver.js`. By default the TypeScript from workspace is used and otherwise fall-backs to the bundled version of TypeScript." 289 | }, 290 | "tsserver.fallbackPath": { 291 | "type": "string", 292 | "default": "", 293 | "markdownDescription": "The path to the `tsserver.js` file or the typescript lib directory to use when `tsserver.path` is unspecified/invalid and the `tsserver` isn't available via the current workspace. For example: `/Users/me/typescript/lib/tsserver.js`. Note: The path should point at the `[...]/typescript/lib/tssserver.js` file or the `[...]/typescript/lib/` directory and not the shell script (`[...]/node_modules/.bin/tsserver`) but for backward-compatibility reasons, the server will try to do the right thing even when passed a path to the shell script." 294 | }, 295 | "tsserver.trace": { 296 | "enum": [ 297 | "off", 298 | "messages", 299 | "verbose" 300 | ], 301 | "default": "off", 302 | "markdownDescription": "The verbosity of logging of the tsserver communication.\n\nDelivered through the LSP messages and not related to file logging." 303 | }, 304 | "tsserver.useSyntaxServer": { 305 | "enum": [ 306 | "auto", 307 | "never" 308 | ], 309 | "default": "auto", 310 | "markdownDescription": "Controls if TypeScript launches a dedicated server to more quickly handle syntax related operations, such as computing diagnostics or code folding.", 311 | "markdownEnumDescriptions": [ 312 | "Spawn both a full server and a lighter weight server dedicated to syntax operations. The syntax server is used to speed up syntax operations and provide IntelliSense while projects are loading.", 313 | "Don't use a dedicated syntax server. Use a single server to handle all IntelliSense operations." 314 | ] 315 | }, 316 | } 317 | }, 318 | "settings": { 319 | "type": "object", 320 | "additionalProperties": false, 321 | "properties": { 322 | "statusText": { 323 | "type": "string", 324 | "default": "$version, $source", 325 | "markdownDescription": "The text to be shown next to the server indicator in the status bar. Can use two template variables `$version` and `$source` that carry information about used TypeScript version." 326 | }, 327 | "completions.completeFunctionCalls": { 328 | "type": "boolean", 329 | "default": false, 330 | "markdownDescription": "Complete functions with their parameter signature.\n\nThis functionality relies on LSP client resolving the completion using the `completionItem/resolve` call. If the client can't do that before inserting the completion then it's not safe to enable it as it will result in some completions having a snippet type without actually being snippets, which can then cause problems when inserting them." 331 | }, 332 | "diagnostics.ignoredCodes": { 333 | "type": "array", 334 | "items": { 335 | "type": "number", 336 | "uniqueItems": true 337 | }, 338 | "default": [], 339 | "markdownDescription": "Diagnostics code to be omitted when reporting diagnostics. See https://github.com/microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json for a full list of valid codes." 340 | }, 341 | "implicitProjectConfiguration.checkJs": { 342 | "description": "Enable error reporting in type-checked JavaScript files.", 343 | "type": "boolean", 344 | "default": false, 345 | "markdownDescription": "Enable error reporting in type-checked JavaScript files.\n\nSee more: https://www.typescriptlang.org/tsconfig#checkJs" 346 | }, 347 | "implicitProjectConfiguration.experimentalDecorators": { 348 | "description": "Enable experimental support for TC39 stage 2 draft decorators.", 349 | "type": "boolean", 350 | "markdownDescription": "Enable experimental support for TC39 stage 2 draft decorators.\n\nSee more: https://www.typescriptlang.org/tsconfig#experimentalDecorators" 351 | }, 352 | "implicitProjectConfiguration.module": { 353 | "description": "Specify what module code is generated.", 354 | "type": "string", 355 | "anyOf": [ 356 | { 357 | "enum": [ 358 | "CommonJS", 359 | "AMD", 360 | "System", 361 | "UMD", 362 | "ES6", 363 | "ES2015", 364 | "ES2020", 365 | "ESNext", 366 | "None", 367 | "ES2022", 368 | "Node16", 369 | "NodeNext" 370 | ] 371 | }, 372 | { 373 | "pattern": "^([Cc][Oo][Mm][Mm][Oo][Nn][Jj][Ss]|[AaUu][Mm][Dd]|[Ss][Yy][Ss][Tt][Ee][Mm]|[Ee][Ss]([356]|20(1[567]|2[02])|[Nn][Ee][Xx][Tt])|[Nn][Oo][dD][Ee]16|[Nn][Oo][Dd][Ed][Nn][Ee][Xx][Tt]|[Nn][Oo][Nn][Ee])$" 374 | } 375 | ], 376 | "markdownDescription": "Specify what module code is generated.\n\nSee more: https://www.typescriptlang.org/tsconfig#module" 377 | }, 378 | "implicitProjectConfiguration.strictFunctionTypes": { 379 | "description": "When assigning functions, check to ensure parameters and the return values are subtype-compatible.", 380 | "type": "boolean", 381 | "default": false, 382 | "markdownDescription": "When assigning functions, check to ensure parameters and the return values are subtype-compatible.\n\nSee more: https://www.typescriptlang.org/tsconfig#strictFunctionTypes" 383 | }, 384 | "implicitProjectConfiguration.strictNullChecks": { 385 | "description": "When type checking, take into account `null` and `undefined`.", 386 | "type": "boolean", 387 | "default": false, 388 | "markdownDescription": "When type checking, take into account `null` and `undefined`.\n\nSee more: https://www.typescriptlang.org/tsconfig#strictNullChecks" 389 | }, 390 | "implicitProjectConfiguration.target": { 391 | "description": "Set the JavaScript language version for emitted JavaScript and include compatible library declarations.", 392 | "type": "string", 393 | "default": "ES3", 394 | "anyOf": [ 395 | { 396 | "enum": [ 397 | "ES3", 398 | "ES5", 399 | "ES6", 400 | "ES2015", 401 | "ES2016", 402 | "ES2017", 403 | "ES2018", 404 | "ES2019", 405 | "ES2020", 406 | "ES2021", 407 | "ES2022", 408 | "ESNext" 409 | ] 410 | }, 411 | { 412 | "pattern": "^([Ee][Ss]([356]|(20(1[56789]|2[012]))|[Nn][Ee][Xx][Tt]))$" 413 | } 414 | ], 415 | "markdownDescription": "Set the JavaScript language version for emitted JavaScript and include compatible library declarations.\n\nSee more: https://www.typescriptlang.org/tsconfig#target" 416 | }, 417 | "typescript.format.insertSpaceAfterCommaDelimiter": { 418 | "type": "boolean", 419 | "default": true 420 | }, 421 | "typescript.format.insertSpaceAfterConstructor": { 422 | "type": "boolean", 423 | "default": false 424 | }, 425 | "typescript.format.insertSpaceAfterSemicolonInForStatements": { 426 | "type": "boolean", 427 | "default": true 428 | }, 429 | "typescript.format.insertSpaceBeforeAndAfterBinaryOperators": { 430 | "type": "boolean", 431 | "default": true 432 | }, 433 | "typescript.format.insertSpaceAfterKeywordsInControlFlowStatements": { 434 | "type": "boolean", 435 | "default": true 436 | }, 437 | "typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": { 438 | "type": "boolean", 439 | "default": true 440 | }, 441 | "typescript.format.insertSpaceBeforeFunctionParenthesis": { 442 | "type": "boolean", 443 | "default": false 444 | }, 445 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": { 446 | "type": "boolean", 447 | "default": false 448 | }, 449 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": { 450 | "type": "boolean", 451 | "default": false 452 | }, 453 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": { 454 | "type": "boolean", 455 | "default": false 456 | }, 457 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": { 458 | "type": "boolean", 459 | "default": true 460 | }, 461 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": { 462 | "type": "boolean", 463 | "default": false 464 | }, 465 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": { 466 | "type": "boolean", 467 | "default": false 468 | }, 469 | "typescript.format.insertSpaceAfterTypeAssertion": { 470 | "type": "boolean", 471 | "default": false 472 | }, 473 | "typescript.format.insertSpaceBeforeTypeAnnotation": { 474 | "type": "boolean", 475 | "default": false 476 | }, 477 | "typescript.format.placeOpenBraceOnNewLineForFunctions": { 478 | "type": "boolean", 479 | "default": false 480 | }, 481 | "typescript.format.placeOpenBraceOnNewLineForControlBlocks": { 482 | "type": "boolean", 483 | "default": false 484 | }, 485 | "typescript.format.semicolons": { 486 | "type": "string", 487 | "default": "ignore", 488 | "description": "Defines handling of optional semicolons. Requires using TypeScript 3.7 or newer in the workspace.", 489 | "scope": "resource", 490 | "enum": [ 491 | "ignore", 492 | "insert", 493 | "remove" 494 | ] 495 | }, 496 | "typescript.format.trimTrailingWhitespace": { 497 | "type": "boolean", 498 | "default": true 499 | }, 500 | "typescript.inlayHints.includeInlayEnumMemberValueHints": { 501 | "type": "boolean", 502 | "default": false, 503 | "markdownDescription": "Enable/disable inlay hints for member values in enum declarations: \n\n ```typescript\n enum MyValue {\n A /* = 0 */;\n B /* = 1 */;\n }\n ```\n \n Require TypeScript 4.4+." 504 | }, 505 | "typescript.inlayHints.includeInlayFunctionLikeReturnTypeHints": { 506 | "type": "boolean", 507 | "default": false, 508 | "markdownDescription": "Enable/disable inlay hints for implicit return types on function signatures:\n\n ```typescript\n function foo() /* :number */ {\n return Date.now();\n }\n ```\n Require TypeScript 4.4+." 509 | }, 510 | "typescript.inlayHints.includeInlayFunctionParameterTypeHints": { 511 | "type": "boolean", 512 | "default": false, 513 | "markdownDescription": "Enable/disable inlay hints for parameter names: \n\n ```typescript\n parseInt(/* str: */ '123', /* radix: */ 8)\n ```\n Require TypeScript 4.4+." 514 | }, 515 | "typescript.inlayHints.includeInlayParameterNameHints": { 516 | "enum": [ 517 | "all", 518 | "literals", 519 | "none" 520 | ], 521 | "default": "none", 522 | "markdownEnumDescriptions": [ 523 | "Enable parameter name hints for literal and non-literal arguments.", 524 | "Enable parameter name hints only for literal arguments.", 525 | "Disable parameter name hints." 526 | ] 527 | }, 528 | "typescript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName": { 529 | "type": "boolean", 530 | "default": false, 531 | "markdownDescription": "" 532 | }, 533 | "typescript.inlayHints.includeInlayPropertyDeclarationTypeHints": { 534 | "type": "boolean", 535 | "default": false, 536 | "markdownDescription": "Enable/disable inlay hints for implicit types on property declarations: \n\n ```typescript\n class Foo {\n prop /* :number */ = Date.now;\n }\n ```\n Require TypeScript 4.4+." 537 | }, 538 | "typescript.inlayHints.includeInlayVariableTypeHints": { 539 | "type": "boolean", 540 | "default": false, 541 | "markdownDescription": "Enable/disable inlay hints for implicit variable types: \n\n ```typescript\n const foo /* :number */ = Date.now();\n ``` \n Require TypeScript 4.4+." 542 | }, 543 | "typescript.inlayHints.includeInlayVariableTypeHintsWhenTypeMatchesName": { 544 | "type": "boolean", 545 | "default": false, 546 | "markdownDescription": "When disabled then type hints on variables whose name is identical to the type name won't be shown. Requires using TypeScript 4.8+ in the workspace." 547 | }, 548 | "javascript.implementationsCodeLens.enabled": { 549 | "type": "boolean", 550 | "default": false, 551 | "markdownDescription": "Enable/disable implementations CodeLens. This CodeLens shows the implementers of an interface." 552 | }, 553 | "javascript.referencesCodeLens.enabled": { 554 | "type": "boolean", 555 | "default": false, 556 | "markdownDescription": "Enable/disable references CodeLens in JavaScript files." 557 | }, 558 | "javascript.referencesCodeLens.showOnAllFunctions": { 559 | "type": "boolean", 560 | "default": false, 561 | "markdownDescription": "Enable/disable references CodeLens on all functions in JavaScript files." 562 | }, 563 | "typescript.implementationsCodeLens.enabled": { 564 | "type": "boolean", 565 | "default": false, 566 | "markdownDescription": "Enable/disable implementations CodeLens. This CodeLens shows the implementers of an interface." 567 | }, 568 | "typescript.referencesCodeLens.enabled": { 569 | "type": "boolean", 570 | "default": false, 571 | "markdownDescription": "Enable/disable references CodeLens in TypeScript files." 572 | }, 573 | "typescript.referencesCodeLens.showOnAllFunctions": { 574 | "type": "boolean", 575 | "default": false, 576 | "markdownDescription": "Enable/disable references CodeLens on all functions in TypeScript files." 577 | }, 578 | "javascript.format.insertSpaceAfterCommaDelimiter": { 579 | "type": "boolean", 580 | "default": true 581 | }, 582 | "javascript.format.insertSpaceAfterConstructor": { 583 | "type": "boolean", 584 | "default": false 585 | }, 586 | "javascript.format.insertSpaceAfterSemicolonInForStatements": { 587 | "type": "boolean", 588 | "default": true 589 | }, 590 | "javascript.format.insertSpaceBeforeAndAfterBinaryOperators": { 591 | "type": "boolean", 592 | "default": true 593 | }, 594 | "javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": { 595 | "type": "boolean", 596 | "default": true 597 | }, 598 | "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": { 599 | "type": "boolean", 600 | "default": true 601 | }, 602 | "javascript.format.insertSpaceBeforeFunctionParenthesis": { 603 | "type": "boolean", 604 | "default": false 605 | }, 606 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": { 607 | "type": "boolean", 608 | "default": false 609 | }, 610 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": { 611 | "type": "boolean", 612 | "default": false 613 | }, 614 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": { 615 | "type": "boolean", 616 | "default": false 617 | }, 618 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": { 619 | "type": "boolean", 620 | "default": true 621 | }, 622 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": { 623 | "type": "boolean", 624 | "default": false 625 | }, 626 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": { 627 | "type": "boolean", 628 | "default": false 629 | }, 630 | "javascript.format.insertSpaceAfterTypeAssertion": { 631 | "type": "boolean", 632 | "default": false 633 | }, 634 | "javascript.format.insertSpaceBeforeTypeAnnotation": { 635 | "type": "boolean", 636 | "default": false 637 | }, 638 | "javascript.format.placeOpenBraceOnNewLineForFunctions": { 639 | "type": "boolean", 640 | "default": false 641 | }, 642 | "javascript.format.placeOpenBraceOnNewLineForControlBlocks": { 643 | "type": "boolean", 644 | "default": false 645 | }, 646 | "javascript.format.semicolons": { 647 | "type": "string", 648 | "default": "ignore", 649 | "description": "Defines handling of optional semicolons. Requires using TypeScript 3.7 or newer in the workspace.", 650 | "scope": "resource", 651 | "enum": [ 652 | "ignore", 653 | "insert", 654 | "remove" 655 | ] 656 | }, 657 | "javascript.format.trimTrailingWhitespace": { 658 | "type": "boolean", 659 | "default": true 660 | }, 661 | "javascript.inlayHints.includeInlayEnumMemberValueHints": { 662 | "type": "boolean", 663 | "default": false, 664 | "markdownDescription": "Enable/disable inlay hints for member values in enum declarations: \n\n ```typescript\n enum MyValue {\n A /* = 0 */;\n B /* = 1 */;\n }\n ```\n \n Require TypeScript 4.4+." 665 | }, 666 | "javascript.inlayHints.includeInlayFunctionLikeReturnTypeHints": { 667 | "type": "boolean", 668 | "default": false, 669 | "markdownDescription": "Enable/disable inlay hints for implicit return types on function signatures:\n\n ```typescript\n function foo() /* :number */ {\n return Date.now();\n }\n ```\n Require TypeScript 4.4+." 670 | }, 671 | "javascript.inlayHints.includeInlayFunctionParameterTypeHints": { 672 | "type": "boolean", 673 | "default": false, 674 | "markdownDescription": "Enable/disable inlay hints for parameter names: \n\n ```typescript\n parseInt(/* str: */ '123', /* radix: */ 8)\n ```\n Require TypeScript 4.4+." 675 | }, 676 | "javascript.inlayHints.includeInlayParameterNameHints": { 677 | "enum": [ 678 | "all", 679 | "literals", 680 | "none" 681 | ], 682 | "default": "none", 683 | "markdownEnumDescriptions": [ 684 | "Enable parameter name hints for literal and non-literal arguments.", 685 | "Enable parameter name hints only for literal arguments.", 686 | "Disable parameter name hints." 687 | ] 688 | }, 689 | "javascript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName": { 690 | "type": "boolean", 691 | "default": false, 692 | "markdownDescription": "" 693 | }, 694 | "javascript.inlayHints.includeInlayPropertyDeclarationTypeHints": { 695 | "type": "boolean", 696 | "default": false, 697 | "markdownDescription": "Enable/disable inlay hints for implicit types on property declarations: \n\n ```typescript\n class Foo {\n prop /* :number */ = Date.now;\n }\n ```\n Require TypeScript 4.4+." 698 | }, 699 | "javascript.inlayHints.includeInlayVariableTypeHints": { 700 | "type": "boolean", 701 | "default": false, 702 | "markdownDescription": "Enable/disable inlay hints for implicit variable types: \n\n ```typescript\n const foo /* :number */ = Date.now();\n ``` \n Require TypeScript 4.4+." 703 | }, 704 | "javascript.inlayHints.includeInlayVariableTypeHintsWhenTypeMatchesName": { 705 | "type": "boolean", 706 | "default": false, 707 | "markdownDescription": "When disabled then type hints on variables whose name is identical to the type name won't be shown. Requires using TypeScript 4.8+ in the workspace." 708 | }, 709 | } 710 | } 711 | } 712 | } 713 | }, 714 | "type": "object", 715 | "allOf": [ 716 | { 717 | "$ref": "sublime://settings/LSP-plugin-base" 718 | }, 719 | { 720 | "$ref": "sublime://settings/LSP-typescript#/definitions/PluginConfig" 721 | } 722 | ] 723 | } 724 | }, 725 | { 726 | "file_patterns": [ 727 | "/*.sublime-project" 728 | ], 729 | "schema": { 730 | "properties": { 731 | "settings": { 732 | "properties": { 733 | "LSP": { 734 | "properties": { 735 | "LSP-typescript": { 736 | "$ref": "sublime://settings/LSP-typescript#/definitions/PluginConfig" 737 | } 738 | } 739 | } 740 | } 741 | } 742 | } 743 | } 744 | }, 745 | { 746 | "file_patterns": [ 747 | "LSP.sublime-settings" 748 | ], 749 | "schema": { 750 | "properties": { 751 | "lsp_code_actions_on_save": { 752 | "properties": { 753 | "source.addMissingImports.ts": { 754 | "type": "boolean" 755 | }, 756 | "source.fixAll.ts": { 757 | "type": "boolean" 758 | }, 759 | "source.organizeImports.ts": { 760 | "type": "boolean" 761 | }, 762 | "source.removeUnused.ts": { 763 | "type": "boolean" 764 | }, 765 | "source.removeUnusedImports.ts": { 766 | "type": "boolean" 767 | }, 768 | "source.sortImports.ts": { 769 | "type": "boolean" 770 | } 771 | } 772 | } 773 | } 774 | } 775 | }, 776 | ] 777 | } 778 | } 779 | -------------------------------------------------------------------------------- /typescript-language-server/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lsp-typescript", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "name": "lsp-typescript", 8 | "dependencies": { 9 | "typescript": "5.8.3", 10 | "typescript-language-server": "4.3.4" 11 | } 12 | }, 13 | "node_modules/typescript": { 14 | "version": "5.8.3", 15 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", 16 | "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", 17 | "license": "Apache-2.0", 18 | "bin": { 19 | "tsc": "bin/tsc", 20 | "tsserver": "bin/tsserver" 21 | }, 22 | "engines": { 23 | "node": ">=14.17" 24 | } 25 | }, 26 | "node_modules/typescript-language-server": { 27 | "version": "4.3.4", 28 | "resolved": "https://registry.npmjs.org/typescript-language-server/-/typescript-language-server-4.3.4.tgz", 29 | "integrity": "sha512-0pQ4ffAarsf10VwFhyyyqNJhuDd4r6f4dSsQN38WdbQ3WVxqi08p/bI//v1VnOV5CSVd4AeOUY/jfJYheHTQPQ==", 30 | "license": "Apache-2.0", 31 | "bin": { 32 | "typescript-language-server": "lib/cli.mjs" 33 | }, 34 | "engines": { 35 | "node": ">=18" 36 | } 37 | } 38 | }, 39 | "dependencies": { 40 | "typescript": { 41 | "version": "5.8.3", 42 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", 43 | "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==" 44 | }, 45 | "typescript-language-server": { 46 | "version": "4.3.4", 47 | "resolved": "https://registry.npmjs.org/typescript-language-server/-/typescript-language-server-4.3.4.tgz", 48 | "integrity": "sha512-0pQ4ffAarsf10VwFhyyyqNJhuDd4r6f4dSsQN38WdbQ3WVxqi08p/bI//v1VnOV5CSVd4AeOUY/jfJYheHTQPQ==" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /typescript-language-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lsp-typescript", 3 | "private": true, 4 | "dependencies": { 5 | "typescript": "5.8.3", 6 | "typescript-language-server": "4.3.4" 7 | } 8 | } 9 | --------------------------------------------------------------------------------