generated from JetBrains/intellij-platform-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from dinbtechit/feature/rust-highligting
feature: syntax highlighting for rust
- Loading branch information
Showing
6 changed files
with
91 additions
and
2 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
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/com/github/dinbtechit/vscodetheme/annotators/DefaultAnnotator.kt
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,35 @@ | ||
package com.github.dinbtechit.vscodetheme.annotators | ||
|
||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors | ||
import com.intellij.openapi.editor.colors.TextAttributesKey | ||
import com.intellij.psi.PsiElement | ||
|
||
|
||
class DefaultAnnotator : BaseAnnotator() { | ||
companion object { | ||
private val DEFAULT_KEYWORD: TextAttributesKey = DefaultLanguageHighlighterColors.KEYWORD | ||
val TYPE_KEYWORD: TextAttributesKey = DefaultLanguageHighlighterColors.CLASS_NAME | ||
val SECONDARY_KEYWORD: TextAttributesKey = TextAttributesKey.createTextAttributesKey( | ||
"DEFAULT_SECONDARY_KEYWORD", | ||
DEFAULT_KEYWORD | ||
) | ||
val SECONDARY_KEYWORD_BG: TextAttributesKey = TextAttributesKey.createTextAttributesKey( | ||
"DEFAULT_SECONDARY_KEYWORD_WITH_BG", | ||
DEFAULT_KEYWORD | ||
) | ||
} | ||
|
||
override fun getKeywordType(element: PsiElement): TextAttributesKey? { | ||
var type: TextAttributesKey? = null | ||
when (element.text) { | ||
"new", "return" -> type = SECONDARY_KEYWORD | ||
"if", "else", "switch", "case", "default", "break", "continue", "assert" -> type = SECONDARY_KEYWORD | ||
"try", "catch", "finally", "throw" -> type = SECONDARY_KEYWORD | ||
"for", "while", "do", "in" -> type = SECONDARY_KEYWORD | ||
else -> {} | ||
} | ||
|
||
return type | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/kotlin/com/github/dinbtechit/vscodetheme/annotators/RustAnnotator.kt
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,41 @@ | ||
package com.github.dinbtechit.vscodetheme.annotators | ||
|
||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors | ||
import com.intellij.openapi.editor.colors.TextAttributesKey | ||
import com.intellij.psi.PsiElement | ||
|
||
|
||
class RustAnnotator : BaseAnnotator() { | ||
companion object { | ||
private val DEFAULT_KEYWORD: TextAttributesKey = DefaultLanguageHighlighterColors.KEYWORD | ||
val TYPE_KEYWORD: TextAttributesKey = DefaultLanguageHighlighterColors.CLASS_NAME | ||
val SECONDARY_KEYWORD: TextAttributesKey = TextAttributesKey.createTextAttributesKey( | ||
"DEFAULT_SECONDARY_KEYWORD", | ||
DEFAULT_KEYWORD | ||
) | ||
val SECONDARY_KEYWORD_BG: TextAttributesKey = TextAttributesKey.createTextAttributesKey( | ||
"DEFAULT_SECONDARY_KEYWORD_WITH_BG", | ||
DEFAULT_KEYWORD | ||
) | ||
} | ||
|
||
override fun getKeywordType(element: PsiElement): TextAttributesKey? { | ||
var type: TextAttributesKey? = null | ||
when (element.text) { | ||
"mut", "match","return" -> type = SECONDARY_KEYWORD | ||
"if", "else", "switch", "case", "default", "break", "continue", "as" -> type = SECONDARY_KEYWORD | ||
"try", "catch", "finally", "throw" -> type = SECONDARY_KEYWORD | ||
"for", "while", "loop", "in" -> type = SECONDARY_KEYWORD | ||
"await", "async", "yield", "on" -> type = SECONDARY_KEYWORD_BG | ||
"*" -> if (element.prevSibling != null) { | ||
when (element.prevSibling.text) { | ||
"await", "sync", "async", "yield" -> type = SECONDARY_KEYWORD_BG | ||
} | ||
} | ||
else -> {} | ||
} | ||
|
||
return type | ||
} | ||
|
||
} |
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,7 @@ | ||
<idea-plugin> | ||
<extensions defaultExtensionNs="com.intellij"> | ||
<annotator language="Rust" order="last" | ||
implementationClass="com.github.dinbtechit.vscodetheme.annotators.RustAnnotator"/> | ||
<!--<colorSettingsPage order="last" implementation="com.github.dinbtechit.vscodetheme.annotators.settings.DartColorSettingsPage"/>--> | ||
</extensions> | ||
</idea-plugin> |
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