Skip to content

Commit af15c9b

Browse files
committed
feat: port upstream tsserver settings from typescript-language-features
Sync portable features from the latest VS Code upstream by source comparison, preserving all coc-specific behavior: - add typescript/javascript.format.indentSwitchCase format option - add typescript/javascript.preferences.autoImportSpecifierExcludeRegexes - add typescript/javascript.preferences.organizeImports.* preferences (unicodeCollation, caseSensitivity, typeOrder, caseFirst, accentCollation, locale, numericCollation) - add implementationsCodeLens.showOnInterfaceMethods and showOnAllClassMethods filtering - add typescript.workspaceSymbols.excludeLibrarySymbols and send excludeLibrarySymbolsInNavTo in configure preferences Add coc-test unit tests covering each ported feature.
1 parent d19e3b1 commit af15c9b

10 files changed

Lines changed: 629 additions & 15 deletions

Readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ Checkout `:h coc-configuration` for guide of coc.nvim's configuration.
147147
- `typescript.updateImportsOnFileMove.enabled`: Enable/disable automatic updating of import paths when you rename or move a file in VS Code. Default: `"prompt"`
148148
Valid options: ["prompt","always","never"]
149149
- `typescript.implementationsCodeLens.enabled`: Enable codeLens for implementations Default: `false`
150+
- `typescript.implementationsCodeLens.showOnInterfaceMethods`: Show implementations CodeLens on interface methods. Default: `false`
151+
- `typescript.implementationsCodeLens.showOnAllClassMethods`: Show implementations CodeLens on all class methods. Default: `false`
150152
- `typescript.referencesCodeLens.enabled`: Enable codeLens for references Default: `false`
151153
- `typescript.referencesCodeLens.showOnAllFunctions`: Enable/disable references CodeLens on all functions in typescript files. Default: `false`
152154
- `typescript.preferences.importModuleSpecifier`: Preferred path style for auto imports. Default: `"shortest"`
@@ -161,6 +163,8 @@ Checkout `:h coc-configuration` for guide of coc.nvim's configuration.
161163
Valid options: ["auto","single","double"]
162164
- `typescript.preferences.useAliasesForRenames`: Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace. Default: `true`
163165
- `typescript.preferences.autoImportFileExcludePatterns`: Specify glob patterns of files to exclude from auto imports. Requires using TypeScript 4.8 or newer in the workspace.
166+
- `typescript.preferences.autoImportSpecifierExcludeRegexes`: Specify regular expressions for restricting auto imports. Requires using TypeScript 5.9+ in the workspace.
167+
- `typescript.preferences.organizeImports`: Controls how Organize Imports sorts imports (`unicodeCollation`, `caseSensitivity`, `typeOrder`, `caseFirst`, `accentCollation`, `locale`, `numericCollation`).
164168
- `typescript.preferences.preferTypeOnlyAutoImports`: Include the `type` keyword in auto-imports whenever possible. Requires using TypeScript 5.3+ in the workspace.
165169
- `typescript.preferences.renameShorthandProperties`: Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace. Default: `true`
166170
- `typescript.suggestionActions.enabled`: Enable/disable suggestion diagnostics for TypeScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace. Default: `true`
@@ -192,16 +196,20 @@ Checkout `:h coc-configuration` for guide of coc.nvim's configuration.
192196
- `typescript.format.placeOpenBraceOnNewLineForControlBlocks`: Defines whether an open brace is put onto a new line for control blocks or not. Default: `false`
193197
- `typescript.format.semicolons`: Defines handling of optional semicolons. Requires using TypeScript 3.7 or newer in the workspace. Default: `"ignore"`
194198
Valid options: ["ignore","insert","remove"]
199+
- `typescript.format.indentSwitchCase`: Defines whether an indent is inserted when a `case` or `default` clause is inside a `switch` statement. Default: `true`
195200
- `typescript.suggest.includeAutomaticOptionalChainCompletions`: Enable/disable showing completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+ and strict null checks to be enabled. Default: `true`
196201
- `typescript.workspaceSymbols.scope`: Controls which files are searched by [go to symbol in workspace](https://code.visualstudio.com/docs/editor/editingevolved#_open-symbol-by-name). Default: `"allOpenProjects"`
197202
Valid options: ["allOpenProjects","currentProject"]
203+
- `typescript.workspaceSymbols.excludeLibrarySymbols`: Exclude symbols from library files (e.g. `node_modules`) when searching for symbols in the workspace. Default: `true`
198204
- `typescript.autoClosingTags`: Enable/disable automatic closing of JSX tags. Default: `true`
199205
- `typescript.preferGoToSourceDefinition`: Makes Go to Definition avoid type declaration files when possible by triggering Go to Source Definition instead. Requires using TypeScript 4.7+ in the workspace. Default: `false`
200206
- `javascript.showUnused`: Show unused variable hint. Default: `true`
201207
- `javascript.showDeprecated`: Show deprecated variable hint. Default: `true`
202208
- `javascript.updateImportsOnFileMove.enabled`: Enable/disable automatic updating of import paths when you rename or move a file in VS Code. Default: `"prompt"`
203209
Valid options: ["prompt","always","never"]
204210
- `javascript.implementationsCodeLens.enabled`: Enable/disable implementations CodeLens. This CodeLens shows the implementers of an interface. Default: `false`
211+
- `javascript.implementationsCodeLens.showOnInterfaceMethods`: Show implementations CodeLens on interface methods. Default: `false`
212+
- `javascript.implementationsCodeLens.showOnAllClassMethods`: Show implementations CodeLens on all class methods. Default: `false`
205213
- `javascript.referencesCodeLens.enabled`: Enable/disable references CodeLens in JavaScript files. Default: `false`
206214
- `javascript.referencesCodeLens.showOnAllFunctions`: Enable/disable references CodeLens on all functions in JavaScript files. Default: `false`
207215
- `javascript.preferences.importModuleSpecifier`: Preferred path style for auto imports. Default: `"shortest"`
@@ -214,6 +222,8 @@ Checkout `:h coc-configuration` for guide of coc.nvim's configuration.
214222
Valid options: ["auto","single","double"]
215223
- `javascript.preferences.useAliasesForRenames`: Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace. Default: `true`
216224
- `javascript.preferences.autoImportFileExcludePatterns`: Specify glob patterns of files to exclude from auto imports. Requires using TypeScript 4.8 or newer in the workspace.
225+
- `javascript.preferences.autoImportSpecifierExcludeRegexes`: Specify regular expressions for restricting auto imports. Requires using TypeScript 5.9+ in the workspace.
226+
- `javascript.preferences.organizeImports`: Controls how Organize Imports sorts imports (`unicodeCollation`, `caseSensitivity`, `typeOrder`, `caseFirst`, `accentCollation`, `locale`, `numericCollation`).
217227
- `javascript.preferences.renameShorthandProperties`: Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace. Default: `true`
218228
- `javascript.validate.enable`: Enable/disable JavaScript validation. Default: `true`
219229
- `javascript.suggestionActions.enabled`: Enable/disable suggestion diagnostics for JavaScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace. Default: `true`
@@ -265,6 +275,7 @@ Checkout `:h coc-configuration` for guide of coc.nvim's configuration.
265275
- `javascript.preferGoToSourceDefinition`: Makes Go to Definition avoid type declaration files when possible by triggering Go to Source Definition instead. Requires using TypeScript 4.7+ in the workspace. Default: `false`
266276
- `javascript.format.semicolons`: Defines handling of optional semicolons. Requires using TypeScript 3.7 or newer in the workspace. Default: `"ignore"`
267277
Valid options: ["ignore","insert","remove"]
278+
- `javascript.format.indentSwitchCase`: Defines whether an indent is inserted when a `case` or `default` clause is inside a `switch` statement. Default: `true`
268279
- `javascript.suggest.completeJSDocs`: Enable/disable suggestion to complete JSDoc comments. Default: `true`
269280
- `typescript.suggest.completeJSDocs`: Enable/disable suggestion to complete JSDoc comments. Default: `true`
270281
- `javascript.suggest.objectLiteralMethodSnippets.enabled`: Enable/disable snippet completions for methods in object literals. Requires using TypeScript 4.7+ in the workspace Default: `true`

package.json

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,18 @@
429429
"default": false,
430430
"description": "Enable codeLens for implementations"
431431
},
432+
"typescript.implementationsCodeLens.showOnInterfaceMethods": {
433+
"type": "boolean",
434+
"scope": "window",
435+
"default": false,
436+
"description": "Show implementations CodeLens on interface methods."
437+
},
438+
"typescript.implementationsCodeLens.showOnAllClassMethods": {
439+
"type": "boolean",
440+
"scope": "window",
441+
"default": false,
442+
"description": "Show implementations CodeLens on all class methods, including those not declared abstract."
443+
},
432444
"typescript.referencesCodeLens.enabled": {
433445
"type": "boolean",
434446
"scope": "window",
@@ -533,6 +545,88 @@
533545
"markdownDescription": "Specify glob patterns of files to exclude from auto imports. Requires using TypeScript 4.8 or newer in the workspace.",
534546
"scope": "resource"
535547
},
548+
"typescript.preferences.autoImportSpecifierExcludeRegexes": {
549+
"type": "array",
550+
"items": {
551+
"type": "string"
552+
},
553+
"markdownDescription": "Specify regular expressions for restricting auto imports. Auto imports will be excluded when the import specifier matches the regular expressions. Requires using TypeScript 5.9 or newer in the workspace.",
554+
"scope": "resource"
555+
},
556+
"typescript.preferences.organizeImports": {
557+
"type": "object",
558+
"markdownDescription": "Controls how `Organize Imports` sorts imports.",
559+
"properties": {
560+
"caseSensitivity": {
561+
"type": "string",
562+
"enum": [
563+
"auto",
564+
"caseInsensitive",
565+
"caseSensitive"
566+
],
567+
"default": "auto",
568+
"markdownEnumDescriptions": [
569+
"Uses TypeScript defaults.",
570+
"Treats all imports as case insensitive.",
571+
"Treats all imports as case sensitive."
572+
]
573+
},
574+
"typeOrder": {
575+
"type": "string",
576+
"enum": [
577+
"auto",
578+
"last",
579+
"inline",
580+
"first"
581+
],
582+
"default": "auto",
583+
"markdownEnumDescriptions": [
584+
"Uses TypeScript defaults.",
585+
"Sort type-only imports last.",
586+
"Sort type-only imports inline.",
587+
"Sort type-only imports first."
588+
]
589+
},
590+
"unicodeCollation": {
591+
"type": "string",
592+
"enum": [
593+
"ordinal",
594+
"unicode"
595+
],
596+
"default": "ordinal",
597+
"markdownEnumDescriptions": [
598+
"Uses TypeScript defaults.",
599+
"Uses Unicode collation."
600+
]
601+
},
602+
"locale": {
603+
"type": "string",
604+
"markdownDescription": "Locale used for organizing imports when using unicode collation."
605+
},
606+
"numericCollation": {
607+
"type": "boolean",
608+
"markdownDescription": "Compare number sequences numerically when using unicode collation."
609+
},
610+
"accentCollation": {
611+
"type": "boolean",
612+
"markdownDescription": "Accent-insensitive compare when using unicode collation."
613+
},
614+
"caseFirst": {
615+
"type": "string",
616+
"enum": [
617+
"default",
618+
"upper",
619+
"lower"
620+
],
621+
"default": "default",
622+
"markdownEnumDescriptions": [
623+
"Uses TypeScript defaults.",
624+
"Uppercase imports first.",
625+
"Lowercase imports first."
626+
]
627+
}
628+
}
629+
},
536630
"typescript.preferences.preferTypeOnlyAutoImports": {
537631
"type": "boolean",
538632
"default": false,
@@ -725,6 +819,12 @@
725819
"remove"
726820
]
727821
},
822+
"typescript.format.indentSwitchCase": {
823+
"type": "boolean",
824+
"default": true,
825+
"description": "Defines whether an indent is inserted when a `case` or `default` clause is inside a `switch` statement.",
826+
"scope": "resource"
827+
},
728828
"typescript.suggest.includeAutomaticOptionalChainCompletions": {
729829
"type": "boolean",
730830
"default": true,
@@ -745,6 +845,12 @@
745845
"default": "allOpenProjects",
746846
"scope": "window"
747847
},
848+
"typescript.workspaceSymbols.excludeLibrarySymbols": {
849+
"type": "boolean",
850+
"default": true,
851+
"markdownDescription": "Exclude symbols from library files (e.g. `node_modules`) when searching for symbols in the workspace.",
852+
"scope": "window"
853+
},
748854
"typescript.autoClosingTags": {
749855
"type": "boolean",
750856
"default": true,
@@ -791,6 +897,18 @@
791897
"description": "Enable/disable implementations CodeLens. This CodeLens shows the implementers of an interface.",
792898
"default": false
793899
},
900+
"javascript.implementationsCodeLens.showOnInterfaceMethods": {
901+
"type": "boolean",
902+
"scope": "window",
903+
"default": false,
904+
"description": "Show implementations CodeLens on interface methods."
905+
},
906+
"javascript.implementationsCodeLens.showOnAllClassMethods": {
907+
"type": "boolean",
908+
"scope": "window",
909+
"default": false,
910+
"description": "Show implementations CodeLens on all class methods, including those not declared abstract."
911+
},
794912
"javascript.referencesCodeLens.enabled": {
795913
"type": "boolean",
796914
"scope": "window",
@@ -879,6 +997,88 @@
879997
"markdownDescription": "Specify glob patterns of files to exclude from auto imports. Requires using TypeScript 4.8 or newer in the workspace.",
880998
"scope": "resource"
881999
},
1000+
"javascript.preferences.autoImportSpecifierExcludeRegexes": {
1001+
"type": "array",
1002+
"items": {
1003+
"type": "string"
1004+
},
1005+
"markdownDescription": "Specify regular expressions for restricting auto imports. Auto imports will be excluded when the import specifier matches the regular expressions. Requires using TypeScript 5.9 or newer in the workspace.",
1006+
"scope": "resource"
1007+
},
1008+
"javascript.preferences.organizeImports": {
1009+
"type": "object",
1010+
"markdownDescription": "Controls how `Organize Imports` sorts imports.",
1011+
"properties": {
1012+
"caseSensitivity": {
1013+
"type": "string",
1014+
"enum": [
1015+
"auto",
1016+
"caseInsensitive",
1017+
"caseSensitive"
1018+
],
1019+
"default": "auto",
1020+
"markdownEnumDescriptions": [
1021+
"Uses TypeScript defaults.",
1022+
"Treats all imports as case insensitive.",
1023+
"Treats all imports as case sensitive."
1024+
]
1025+
},
1026+
"typeOrder": {
1027+
"type": "string",
1028+
"enum": [
1029+
"auto",
1030+
"last",
1031+
"inline",
1032+
"first"
1033+
],
1034+
"default": "auto",
1035+
"markdownEnumDescriptions": [
1036+
"Uses TypeScript defaults.",
1037+
"Sort type-only imports last.",
1038+
"Sort type-only imports inline.",
1039+
"Sort type-only imports first."
1040+
]
1041+
},
1042+
"unicodeCollation": {
1043+
"type": "string",
1044+
"enum": [
1045+
"ordinal",
1046+
"unicode"
1047+
],
1048+
"default": "ordinal",
1049+
"markdownEnumDescriptions": [
1050+
"Uses TypeScript defaults.",
1051+
"Uses Unicode collation."
1052+
]
1053+
},
1054+
"locale": {
1055+
"type": "string",
1056+
"markdownDescription": "Locale used for organizing imports when using unicode collation."
1057+
},
1058+
"numericCollation": {
1059+
"type": "boolean",
1060+
"markdownDescription": "Compare number sequences numerically when using unicode collation."
1061+
},
1062+
"accentCollation": {
1063+
"type": "boolean",
1064+
"markdownDescription": "Accent-insensitive compare when using unicode collation."
1065+
},
1066+
"caseFirst": {
1067+
"type": "string",
1068+
"enum": [
1069+
"default",
1070+
"upper",
1071+
"lower"
1072+
],
1073+
"default": "default",
1074+
"markdownEnumDescriptions": [
1075+
"Uses TypeScript defaults.",
1076+
"Uppercase imports first.",
1077+
"Lowercase imports first."
1078+
]
1079+
}
1080+
}
1081+
},
8821082
"javascript.preferences.renameShorthandProperties": {
8831083
"type": "boolean",
8841084
"default": true,
@@ -1177,6 +1377,12 @@
11771377
"remove"
11781378
]
11791379
},
1380+
"javascript.format.indentSwitchCase": {
1381+
"type": "boolean",
1382+
"default": true,
1383+
"description": "Defines whether an indent is inserted when a `case` or `default` clause is inside a `switch` statement.",
1384+
"scope": "resource"
1385+
},
11801386
"javascript.preferGoToSourceDefinition": {
11811387
"type": "boolean",
11821388
"default": false,

0 commit comments

Comments
 (0)