Skip to content

Commit fa225e1

Browse files
committed
2 parents a1514d3 + 5d0f697 commit fa225e1

File tree

10 files changed

+265
-58
lines changed

10 files changed

+265
-58
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ out
99
.next
1010
.nuxt
1111
.cache
12+
src/generated.ts
1213

1314
coverage
1415
*.lcov

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"categories": [
1515
"Other"
1616
],
17-
"publisher": "d",
17+
"publisher": "zardoy",
1818
"private": true,
1919
"scripts": {
2020
"start": "vscode-framework start",
@@ -34,8 +34,10 @@
3434
"typescript": "^4.5.4"
3535
},
3636
"dependencies": {
37+
"@types/lodash": "^4.14.182",
3738
"eslint": "^8.7.0",
3839
"eslint-config-zardoy": "^0.2.8",
40+
"lodash": "^4.17.21",
3941
"vscode-framework": "^0.0.18"
4042
}
4143
}

pnpm-lock.yaml

Lines changed: 32 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
packages:
2-
- extension
2+
- .
33
- typescript

src/configurationType.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
type ReplaceRule = {
2+
/** e.g. `readFile`, `^readFile` (global) or `fs.readFile` */
3+
suggestion: string
4+
/** @experimental Additional filter */
5+
package?: string
6+
// action
7+
remove?: boolean
8+
patch?: Partial<{
9+
name: string
10+
kind: string
11+
/** Might be useless when `correntSorting.enable` is true */
12+
sortText: string
13+
/** Generally not recommended */
14+
// kindModifiers: string
15+
insertText: string
16+
}>
17+
/** Works only with `correntSorting.enable` set to true (default) */
18+
movePos?: number
19+
// or
20+
insertAfter?: string
21+
/** Not recommended to use as it would override possible `?` insertion */
22+
// replaceExisting?: string
23+
}
24+
25+
// TODO support scripting
26+
export type Configuration = {
27+
/**
28+
* Removes `Symbol`, `caller`, `prototype`
29+
* @default true
30+
* */
31+
'removeUselessFunctionProps.enable': boolean
32+
/**
33+
* Useful for Number types.
34+
* Patch `toString()`:
35+
* 1. Move it above others to...
36+
* 2. Remove arg tabstop
37+
* @default true
38+
*/
39+
'patchToString.enable': boolean
40+
/**
41+
*
42+
* @default true
43+
*/
44+
'patchArrayMethods.enable': boolean
45+
/**
46+
* Highlight and lift non-function methods. Also applies for static class methods. Uses `bind`, `call`, `caller` detection.
47+
* @default true
48+
* */
49+
'highlightNonFunctionMethods.enable': boolean
50+
/**
51+
* Use originl sorting of suggestions (almost like in WebStorm)
52+
* @default true
53+
* */
54+
'correntSorting.enable': boolean
55+
// TODO
56+
/**
57+
* Mark QuickFixes & refactorings with 🔵
58+
* @default true
59+
* */
60+
'markTsCodeActions.enable': boolean
61+
// TODO
62+
/**
63+
* Reveal import statement as definition instead of real definition
64+
* @default true
65+
* */
66+
'importUpDefinition.enable': boolean
67+
/**
68+
* @default true
69+
* */
70+
'postfixSupport.enable': boolean
71+
/**
72+
* @experimental
73+
* Only tag support
74+
* @default true
75+
* */
76+
'jsxPseudoEmmet.enable': boolean
77+
/**
78+
* Sorting matters
79+
* @default { div: true, span: true, input: "<input $1/>", p:true, form: true, footer: true, section: true, select: true }
80+
*/
81+
'jsxPseudoEmmet.tags': { [tag: string]: true | string }
82+
// 'eventTypePatching.enable': boolean
83+
// 'globalTypedQuerySelector.enable': boolean,
84+
/**
85+
* For DX in JS projects only!
86+
* @default true
87+
*/
88+
// 'wrapDefaultExports.enable': boolean,
89+
// 'wrapDefaultExports.map': {[relativePathGlob: string]: [string, string]},
90+
// 'specialGlobalTypes'
91+
// AS SEPARATE!
92+
// TODO
93+
/** Diagnostics (if not handled by eslint) & completions */
94+
// 'dotImportsMap.enable': boolean,
95+
replaceSuggestions: ReplaceRule[]
96+
}

src/extension.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import vsc from 'vscode'
2-
import { registerActiveDevelopmentCommand } from 'vscode-framework'
1+
import * as vscode from 'vscode'
2+
import { getExtensionId, registerActiveDevelopmentCommand } from 'vscode-framework'
33

44
export const activate = async () => {
5-
const tsExtension = vsc.extensions.getExtension('vscode.typescript-language-features')
5+
const tsExtension = vscode.extensions.getExtension('vscode.typescript-language-features')
66
if (!tsExtension) return
77

88
await tsExtension.activate()
@@ -13,7 +13,12 @@ export const activate = async () => {
1313
const api = tsExtension.exports.getAPI(0)
1414
if (!api) return
1515

16-
api.configurePlugin('my-typescript-plugin-id', {
17-
someValue: 'hey',
16+
const syncConfig = () => {
17+
const config = vscode.workspace.getConfiguration().get(process.env.IDS_PREFIX!)
18+
api.configurePlugin('my-typescript-plugin-id', config)
19+
}
20+
vscode.workspace.onDidChangeConfiguration(({ affectsConfiguration }) => {
21+
if (affectsConfiguration(getExtensionId())) syncConfig()
1822
})
23+
syncConfig()
1924
}

src/generated.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)