Skip to content

Commit 30f31be

Browse files
authored
Merge pull request #176 from zardoy/develop
2 parents d0388d0 + 00d3fee commit 30f31be

29 files changed

+1291
-81
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ jobs:
3333
# if command with timeout already failed on unix, Windows job will be cancelled
3434
- run: pnpm test-plugin
3535
if: ${{ runner.os == 'Windows' }}
36-
- uses: GabrielBB/xvfb-action@v1.6
37-
with:
38-
run: pnpm integration-test
3936
- run: cd out && npx @vscode/vsce package --out ../extension.vsix
4037
- name: Archive production artifacts
4138
uses: actions/upload-artifact@v3

.vscode/settings.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"tsEssentialPlugins.autoImport.changeToNamespaceImport": {
3-
"typescript": {
3+
"typescript/lib/tsserverlibrary": {
44
"namespace": "ts",
55
"addImport": false
66
}
77
},
8+
"typescript.preferences.autoImportFileExcludePatterns": [
9+
"./typescript/src/ts.d.ts"
10+
],
811
"tsEssentialPlugins.suggestions.ignoreAutoImports": [
912
"typescript-full",
1013
"@volar/language-service/*"
@@ -13,6 +16,13 @@
1316
"develop"
1417
],
1518
"cSpell.words": [
19+
"tsserverlibrary",
1620
"unpatch"
21+
],
22+
"vitest.enable": true,
23+
"vitest.commandLine": "pnpm test-plugin",
24+
"vitest.showFailMessages": true,
25+
"vitest.include": [
26+
"typescript/test/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"
1727
]
1828
}

CONTRIBUTING.MD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ To start the VS Code plugin extension locally for developing:
3131

3232
#### Unit Tests
3333

34+
> Note: currently project doesn't use integration testing so you can ignore `integration` folder
35+
3436
They are in `typescript/test` and using vitest, so they faster than integration. Feel free to add new tests here. But note that most of tests are completion tests, but I do hope to add more types tests in the future.
3537

3638
To launch them run `pnpm test-plugin`.

README.MD

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
Feature-complete TypeScript plugin that improves every single builtin feature such as completions, definitions, references and so on, and also adds even new TypeScript killer features, so you can work with large codebases faster!
44
We make completions more informative. Definitions, references (and sometimes even completions) less noisy. And finally our main goal is to provide most customizable TypeScript experience for IDE features.
55

6-
TOC:
6+
## TOC
77

88
- [Top Features](#top-features)
99
- [Minor Useful Features](#minor-useful-features)
1010
- [Method Snippets](#method-snippets)
11-
- [Volar (Vue) support](#vue-support)
11+
- [Volar (Vue) Support](#vue-support)
1212
- [Auto Imports](#auto-imports)
1313
- [Type Driven Completions](#type-driven-completions)
14-
- [Rename Features](#rename-features)
1514
- [Special Commands List](#special-commands-list)
1615
- [Contributed Code Actions](#contributed-code-actions)
16+
- [Rename Features](#rename-features)
1717
- [Even Even More](#even-even-more)
1818

1919
> *Note*: You can disable all optional features with `> Disable All Optional Features` command right after install.
@@ -133,6 +133,8 @@ This also makes plugin work in Volar's takeover mode!
133133
134134
There is web-only feature: fix clicking on relative `import` paths.
135135

136+
Alternative you can try to use [vscode-typescript-web extension](https://github.com/volarjs/vscode-typescript-web/) for better web intellisense.
137+
136138
### `in` Keyword Suggestions
137139

138140
[Demo](https://github.com/zardoy/typescript-vscode-plugins/pull/19)
@@ -319,7 +321,7 @@ function Foo() {
319321
}
320322
```
321323

322-
`tsEssentialPlugins.methodSnippetsInsertText`:
324+
`tsEssentialPlugins.methodSnippets.previewSignature`:
323325

324326
Optionally resolve insertText of all completion at suggest trigger:
325327

@@ -448,9 +450,7 @@ You can add this to `keybindings.json` to disable previewing before renaming:
448450
}
449451
```
450452

451-
Another options that is accepted is
452-
453-
> Note: VS Code has builtin setting to disable introducing aliases (e.g. for imports & object properties)
453+
> Note: VS Code has builtin setting to disable introducing aliases (e.g. for imports & object properties): `typescript.preferences.useAliasesForRenames`
454454
455455
## Special Commands List
456456

buildTsPlugin.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ts-check
22
import buildTsPlugin from '@zardoy/vscode-utils/build/buildTypescriptPlugin.js'
33
import { build, analyzeMetafile } from 'esbuild'
4+
import fs from 'fs'
45

56
const enableWatch = process.argv.includes('--watch')
67
await build({
@@ -29,6 +30,22 @@ const result = await buildTsPlugin('typescript', undefined, undefined, {
2930
js: 'let ts, tsFull;',
3031
// js: 'const log = (...args) => console.log(...args.map(a => JSON.stringify(a)))',
3132
},
33+
plugins: [
34+
{
35+
name: 'watch-notifier',
36+
setup(build) {
37+
const writeStatus = (/** @type {number} */ signal) => {
38+
fs.writeFileSync('./out/build_plugin_result', signal.toString())
39+
}
40+
build.onStart(() => {
41+
writeStatus(0)
42+
})
43+
build.onEnd(({ errors }) => {
44+
writeStatus(errors.length ? 2 : 1)
45+
})
46+
},
47+
},
48+
],
3249
})
3350

3451
// @ts-ignore

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
{
6767
"command": "getArgumentReferencesFromCurrentParameter",
6868
"title": "Get Argument References from Current Parameter"
69+
},
70+
{
71+
"command": "printPerformanceMemoryInfo",
72+
"title": "Print Performance & Memory Info"
6973
}
7074
],
7175
"keybindings": [

src/autoPluginReload.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as vscode from 'vscode'
2+
import fs from 'fs'
3+
import { extensionCtx } from 'vscode-framework'
4+
5+
export default () => {
6+
const status = vscode.window.createStatusBarItem('plugin-auto-reload', vscode.StatusBarAlignment.Left, 1000)
7+
status.show()
8+
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(extensionCtx.extensionUri, 'build_plugin_result'))
9+
const updateStatus = uri => {
10+
const newStatus = fs.readFileSync(uri.fsPath, 'utf8')
11+
if (newStatus === '1') {
12+
void vscode.commands.executeCommand('typescript.restartTsServer')
13+
status.text = 'Latest'
14+
}
15+
16+
if (newStatus === '0') {
17+
status.text = 'Rebuilding'
18+
}
19+
20+
if (newStatus === '2') {
21+
status.text = 'Build errored'
22+
}
23+
}
24+
25+
watcher.onDidChange(updateStatus)
26+
watcher.onDidCreate(updateStatus)
27+
}

src/configurationType.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export type Configuration = {
8787
* Format of this setting is very close to `jsxCompletionsMap` setting:
8888
* `path#symbol` (exact) or `path/*#symbol` (`#symbol` part can be omitted)
8989
*
90-
* Note: Please use `javascript`/`typescript.preferences.autoImportFileExcludePatterns` when possible, to achieve better performance!
90+
* **Note**: Please use builtin `javascript`/`typescript.preferences.autoImportFileExcludePatterns` when possible, to achieve better performance!
91+
* The builtin function expects relative paths to .d.ts / .ts files that contains declarations.
9192
*
9293
* e.g. instead of declaring `@mui/icons-material` here, declare `node_modules/@mui/icons-material` in aforementioned setting.
9394
*
@@ -99,7 +100,7 @@ export type Configuration = {
99100
* - `path/*#join` - ignore path, path/posix and path/win32, but only join symbol
100101
* - `path/*#join,resolve` - ignore path, path/posix and path/win32, but only join and resolve symbol
101102
*
102-
* - jquery/* - ignore absolutely all auto imports from jquery, even if it was declared virtually (declare module)
103+
* - jquery/* - ignore absolutely all auto imports from jquery, even if it was declared using ambient declaration (`declare module`)
103104
* @default []
104105
*/
105106
'suggestions.ignoreAutoImports': string[]
@@ -384,7 +385,7 @@ export type Configuration = {
384385
* Recommended to try!
385386
* @default disable
386387
*/
387-
methodSnippetsInsertText: 'disable' | 'only-local' | 'all'
388+
'methodSnippets.previewSignature': 'disable' | 'only-local' | 'all'
388389
/**
389390
* ```ts
390391
* const example = ({ a }, b?, c = 5, ...d) => { }
@@ -571,7 +572,7 @@ export type Configuration = {
571572
'experiments.excludeNonJsxCompletions': boolean
572573
/**
573574
* Wether to change function completions to function kind
574-
* @deprecated Use `methodSnippetsInsertText` instead
575+
* @deprecated Use `methodSnippets.previewSignature` instead
575576
* @default false
576577
*/
577578
'experiments.changeKindToFunction': boolean

src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
9696

9797
figIntegration()
9898
vueVolarSupport()
99+
100+
if (process.env.PLATFORM === 'node' && process.env.NODE_ENV === 'development') {
101+
require('./autoPluginReload').default()
102+
}
99103
}
100104

101105
export const activate = async () => {

src/migrateSettings.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export default () => {
3333
mustBePrimitive: false,
3434
},
3535
},
36+
{
37+
rename: {
38+
old: 'methodSnippetsInsertText',
39+
new: 'methodSnippets.previewSignature',
40+
mustBePrimitive: false,
41+
},
42+
},
3643
{
3744
async detect(configuration) {
3845
return !!(await migrateSettingValues(configuration, true))

0 commit comments

Comments
 (0)