Skip to content

Commit

Permalink
[WIP] change theme effective mechanism, remove notice message
Browse files Browse the repository at this point in the history
  • Loading branch information
Binaryify committed Nov 29, 2019
1 parent 3d6f45f commit ab89fef
Showing 6 changed files with 882 additions and 902 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# CHANGELOG
## 3.2.0 | 2019.11.29
-

## 3.1.2 | 2019.11.25
- Fixed template expression highlight error [#358](https://github.com/Binaryify/OneDark-Pro/issues/358)

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "material-theme",
"displayName": "One Dark Pro",
"description": "Atom's iconic One Dark theme for Visual Studio Code",
"version": "3.1.2",
"version": "3.2.0",
"publisher": "zhuangtongfa",
"bugs": {
"url": "https://github.com/Binaryify/OneDark-Pro/issues"
18 changes: 11 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -2,9 +2,10 @@ import { join } from 'path'
import * as fs from 'fs'
import { workspace, commands as Commands, ConfigurationTarget } from 'vscode'
import { generateTheme } from './themes'
import { detectConfigChanges, promptToReload, writeFile } from './utils'
import { detectConfigChanges, writeFile } from './utils'
import { ChangelogWebview } from './webviews/Changelog'
import { changelogMessage } from './helpers/message'
// import { changelogMessage } from './helpers/message'
import rewriteUserConfig from './utils/rewriteUserConfig'
const THEME_PATH = join(__dirname, '..', 'themes', 'OneDark-Pro.json')

export async function regenerateTheme() {
@@ -26,18 +27,21 @@ export async function regenerateTheme() {
export async function activate() {
const flagPath = join(__dirname, '../temp', 'flag.txt')
const changelogView = new ChangelogWebview()

if (!fs.existsSync(flagPath)) {
if (await changelogMessage()) {
changelogView.show()
}
rewriteUserConfig()
// if (await changelogMessage()) {
// changelogView.show()
// }
writeFile(flagPath, '')
regenerateTheme().then(promptToReload)
// regenerateTheme().then(promptToReload)
}
// Observe changes in the config
workspace.onDidChangeConfiguration(event => {
detectConfigChanges(event, () => {
rewriteUserConfig()
// update theme json file with new options
regenerateTheme().then(promptToReload)
// regenerateTheme().then(promptToReload)
})
})
Commands.registerCommand('oneDarkPro.showChangelog', () => {
50 changes: 0 additions & 50 deletions src/themes/syntax.ts
Original file line number Diff line number Diff line change
@@ -100,14 +100,6 @@ const configFactory = configuration => {
fontStyle: 'italic'
}
},
{
name: '[VSCODE-CUSTOM] Markdown Quote',
scope: 'markup.quote.markdown',
settings: {
fontStyle: 'italic',
foreground: colorObj.dark
}
},
{
name: 'markup.italic.markdown',
scope: 'markup.italic.markdown',
@@ -495,13 +487,6 @@ const configFactory = configuration => {
foreground: colorObj.malibu
}
},
{
name: 'operator',
scope: 'keyword.operator',
settings: {
foreground: colorObj.fountainBlue
}
},
{
name: 'keyword.operator.misc.rust',
scope: 'keyword.operator.misc.rust',
@@ -625,13 +610,6 @@ const configFactory = configuration => {
foreground: colorObj.whiskey
}
},
{
name: 'Delimiters',
scope: 'none',
settings: {
foreground: colorObj.lightWhite
}
},
{
name: 'Operators',
scope: 'keyword.operator',
@@ -868,20 +846,6 @@ const configFactory = configuration => {
foreground: colorObj.whiskey
}
},
{
name: 'Floats',
scope: 'none',
settings: {
foreground: colorObj.whiskey
}
},
{
name: 'Boolean',
scope: 'none',
settings: {
foreground: colorObj.whiskey
}
},
{
name: 'Constants',
scope: 'constant',
@@ -933,13 +897,6 @@ const configFactory = configuration => {
foreground: colorObj.purple
}
},
{
name: 'Values',
scope: 'none',
settings: {
foreground: colorObj.whiskey
}
},
{
name: 'Headings',
scope: 'markup.heading',
@@ -1350,13 +1307,6 @@ const configFactory = configuration => {
foreground: colorObj.fountainBlue
}
},
{
name: 'parameter function',
scope: 'function.parameter',
settings: {
foreground: colorObj.whiskey
}
},
{
name: 'parameter function js/ts',
scope: 'function.parameter',
53 changes: 53 additions & 0 deletions src/utils/rewriteUserConfig.ts
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
Loading

0 comments on commit ab89fef

Please sign in to comment.