forked from Binaryify/OneDark-Pro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] change theme effective mechanism, remove notice message
- Loading branch information
Showing
6 changed files
with
882 additions
and
902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { workspace, ConfigurationTarget } from 'vscode' | ||
import { generateTheme } from '../themes' | ||
|
||
function getDiffConfig() { | ||
const configuration = workspace.getConfiguration('oneDarkPro') | ||
const defaultTheme = generateTheme({ italic: true }) | ||
const newTheme = generateTheme({ | ||
bold: configuration.get<boolean>('bold'), | ||
editorTheme: configuration.get<string>('editorTheme'), | ||
italic: configuration.get<boolean>('italic'), | ||
vivid: configuration.get<boolean>('vivid') | ||
}) | ||
const colorsDiffObj = {} | ||
const tokenDiffArr = [] | ||
for (const key in defaultTheme.colors) { | ||
if (defaultTheme.colors[key] !== newTheme.colors[key]) { | ||
colorsDiffObj[key] = newTheme.colors[key] | ||
} | ||
} | ||
|
||
defaultTheme.tokenColors.forEach(item => { | ||
newTheme.tokenColors.forEach(cell => { | ||
if (item.scope === cell.scope) { | ||
if (JSON.stringify(item.settings) !== JSON.stringify(cell.settings)) { | ||
tokenDiffArr.push(cell) | ||
} | ||
} | ||
}) | ||
}) | ||
return { | ||
colorsDiffObj, | ||
tokenDiffArr | ||
} | ||
} | ||
function rewriteUserConfig() { | ||
workspace | ||
.getConfiguration() | ||
.update( | ||
`workbench.colorCustomizations`, | ||
getDiffConfig().colorsDiffObj, | ||
ConfigurationTarget.Global | ||
) | ||
workspace.getConfiguration().update( | ||
`editor.tokenColorCustomizations`, | ||
{ | ||
'[One Dark Pro]': { | ||
textMateRules: getDiffConfig().tokenDiffArr | ||
} | ||
}, | ||
ConfigurationTarget.Global | ||
) | ||
} | ||
export default rewriteUserConfig |
Oops, something went wrong.