From 77022f5278f56b2b7dfe7a587a1378502c5820e3 Mon Sep 17 00:00:00 2001 From: dinesh Date: Sun, 12 Jun 2022 06:54:55 -0700 Subject: [PATCH] extensive highlighting for PHP. --- CHANGELOG.md | 8 +++- README.md | 4 +- .../vscodetheme/annotators/PhpAnnotator.kt | 38 +++++++++++++++++++ .../META-INF/lang-config/dinbtechit-php.xml | 6 +++ src/main/resources/META-INF/plugin.xml | 1 + 5 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 src/main/kotlin/com/github/dinbtechit/vscodetheme/annotators/PhpAnnotator.kt create mode 100644 src/main/resources/META-INF/lang-config/dinbtechit-php.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 6542b59..30bcf56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,16 @@ ## [Unreleased] ### Added -- Added extensive syntax highlighting for Php - Added extensive syntax highlighting for c# +- Added extensive syntax highlighting for php + +### Fixed +- Javascript/Typescript - decorator and local variable color same as VSCode +- Javascript/Typescript - await keyword to be same color as VSCode ## [1.3.0] ### Added -- (Experimental) - Introducing adding Code Editor Theme - VSCode Dark Brighter (5% More brighter than the previous theme). +- (Experimental) - Introducing Code Editor Theme - VSCode Dark Brighter (5% More brighter than the previous theme). With option to switch back to older VSCode Dark theme - Added extensive syntax highlighting for Kotlin. diff --git a/README.md b/README.md index 1495a15..de140f9 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ intuitive. This plugin attempts to make the IDE fairly **close** to VSCode Dark+ ### Supported Languages - Advance Syntax highlighting Support: - - JavaScript, TypeScript, Java, Dart/Flutter, Python, Kotlin + - JavaScript, TypeScript, Java, Dart/Flutter, Python, Kotlin, C#/F#, Php - Basic Syntax highlighting: - - Php, .Net, C++, Go, Ruby and many more. + - C++, Go, Ruby and many more. ### Supported Platforms Webstorm, Intellij, CLion, PhpStorm, Rider, Android Studio, GoLang and many more. diff --git a/src/main/kotlin/com/github/dinbtechit/vscodetheme/annotators/PhpAnnotator.kt b/src/main/kotlin/com/github/dinbtechit/vscodetheme/annotators/PhpAnnotator.kt new file mode 100644 index 0000000..2f365af --- /dev/null +++ b/src/main/kotlin/com/github/dinbtechit/vscodetheme/annotators/PhpAnnotator.kt @@ -0,0 +1,38 @@ +package com.github.dinbtechit.vscodetheme.annotators + +import com.intellij.openapi.editor.DefaultLanguageHighlighterColors +import com.intellij.openapi.editor.colors.TextAttributesKey +import com.intellij.psi.PsiComment +import com.intellij.psi.PsiElement +import com.intellij.util.ObjectUtils +import com.jetbrains.php.lang.psi.elements.* + +class PhpAnnotator : BaseAnnotator() { + companion object { + val DEFAULT_KEYWORD: TextAttributesKey = ObjectUtils.notNull( + TextAttributesKey.find("DEFAULT_KEYWORD"), DefaultLanguageHighlighterColors.KEYWORD + ) + val SECONDARY_KEYWORD: TextAttributesKey = TextAttributesKey.createTextAttributesKey( + "DEFAULT_SECONDARY_KEYWORD", + DEFAULT_KEYWORD + ) + + } + + override fun getKeywordType(element: PsiElement): TextAttributesKey? { + var type: TextAttributesKey? = null + if (element is PsiComment) return null + when(element.text) { + "{", "}", "(", ")", ";", ":" -> return null + } + when (element.context) { + is ControlStatement -> type = SECONDARY_KEYWORD + is PhpSwitch, + is Else, is PhpBreak, is Try, is PhpReturn -> type = SECONDARY_KEYWORD + else -> {} + } + + return type + } + +} diff --git a/src/main/resources/META-INF/lang-config/dinbtechit-php.xml b/src/main/resources/META-INF/lang-config/dinbtechit-php.xml new file mode 100644 index 0000000..25c4309 --- /dev/null +++ b/src/main/resources/META-INF/lang-config/dinbtechit-php.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index fe4beb9..2d78dbd 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -13,6 +13,7 @@ Pythonid org.jetbrains.kotlin com.intellij.modules.rider + com.jetbrains.php