Skip to content

Commit

Permalink
1.0.83
Browse files Browse the repository at this point in the history
  • Loading branch information
nabato committed May 9, 2024
1 parent 7a1a4db commit d58931f
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## [Unreleased]

## [1.0.83]
- Strings' content background color in BG heme stays the same when the line is highlighted by IDE, previously background changed to line highlight color.
- String's quotation marks' background color in dynamic now and changes to a line highlight color, previously it was always of a default background color.
- String quotations marks rendering speed improvement.
- Better Scala support: strings, constants.

## [1.0.82]
- Updated changelog for previous versions.

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.vlnabatov.alabaster
pluginName = Alabaster Themes
pluginRepositoryUrl = https://github.com/nabato/alabaster-themes
# SemVer format -> https://semver.org
pluginVersion = 1.0.82
pluginVersion = 1.0.83

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 223.3
Expand All @@ -19,7 +19,7 @@ platformVersion = 2024.1.1

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = org.jetbrains.kotlin, com.intellij.java, JavaScript, PsiViewer:241.14494.158-EAP-SNAPSHOT, com.cursiveclojure.cursive:1.13.3-2024.1
platformPlugins = org.jetbrains.kotlin, com.intellij.java, JavaScript, PsiViewer:241.14494.158-EAP-SNAPSHOT, com.cursiveclojure.cursive:1.13.3-2024.1, org.intellij.scala:2024.1.20

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.4
Expand All @@ -28,7 +28,7 @@ gradleVersion = 8.4
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false

org.gradle.caching=false
org.gradle.caching = false

# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.unsafe.configuration-cache = false
15 changes: 9 additions & 6 deletions src/main/kotlin/com/vlnabatov/alabaster/Util.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.vlnabatov.alabaster

import com.intellij.codeInspection.InspectionsBundle
import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.openapi.editor.colors.EditorColorsManager
Expand All @@ -12,8 +11,12 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import com.intellij.refactoring.suggested.endOffset
import com.intellij.refactoring.suggested.startOffset
import com.intellij.ui.Gray
import java.awt.Color
import java.awt.Font

val transparentColor: Color = Gray.TRANSPARENT

const val theme = "Alabaster"
const val BGTheme = "$theme BG"
const val darkTheme = "$theme Dark"
Expand All @@ -32,30 +35,30 @@ fun annotateSeparationMarks(element: PsiElement, holder: AnnotationHolder, textA
fun annotateSeparationMarks(element: PsiElement, holder: AnnotationHolder, textAttributesKey: TextAttributesKey = BRACES, numberOfOpeningQuotationMarks: Int = 1, numberOfClosingQuotationMarks: Int = 1) {
// Standard annotations for non-Alabaster editor themes
holder
.newSilentAnnotation(HighlightSeverity.TEXT_ATTRIBUTES)
.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(TextRange(element.startOffset, element.startOffset + numberOfOpeningQuotationMarks))
.textAttributes(textAttributesKey)
.create()

holder
.newSilentAnnotation(HighlightSeverity.TEXT_ATTRIBUTES)
.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(TextRange(element.endOffset - numberOfClosingQuotationMarks, element.endOffset))
.textAttributes(textAttributesKey)
.create()


if (isAlabasterTheme()) {
val foreground = EditorColorsManager.getInstance().schemeForCurrentUITheme.defaultForeground
val background = if (isBGTheme()) EditorColorsManager.getInstance().schemeForCurrentUITheme.defaultBackground else null
val background = transparentColor
// Differently colored quotation marks for Alabaster themes
holder
.newSilentAnnotation(HighlightSeverity.TEXT_ATTRIBUTES)
.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(TextRange(element.startOffset, element.startOffset + numberOfOpeningQuotationMarks))
.enforcedTextAttributes(TextAttributes(foreground, background, null, null, Font.PLAIN))
.create()

holder
.newSilentAnnotation(HighlightSeverity.TEXT_ATTRIBUTES)
.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(TextRange(element.endOffset - numberOfClosingQuotationMarks, element.endOffset))
.enforcedTextAttributes(TextAttributes(foreground, background, null, null, Font.PLAIN))
.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ClojureAnnotator : Annotator {
.create()
}
}

// constants
in ALL_LITERALS -> holder.newSilentAnnotation(TEXT_ATTRIBUTES).textAttributes(MARKUP_ENTITY).create()
// highlight keywords' special characters differently
KEYWORD_TOKEN -> keywordSpecialCharactersRegex.findAll(element.text).forEach { f ->
Expand Down Expand Up @@ -112,9 +112,7 @@ class ClojureAnnotator : Annotator {
in symbolPrefixPunctuationMarks ->
if (isBGTheme()) holder.newSilentAnnotation(TEXT_ATTRIBUTES).textAttributes(BRACES).create()
// highlight quotation marks differently
STRING_LITERAL -> {
annotateSeparationMarks(element, holder)
}
STRING_LITERAL -> annotateSeparationMarks(element, holder)
}
} catch (e: Exception) { /* Should not happen */ }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.intellij.psi.util.elementType
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.*


private val valTokens = setOf(NULL,BOOLEAN_CONSTANT, FLOAT_CONSTANT, CHARACTER_CONSTANT, INTEGER_CONSTANT)
private val valTokens = setOf(NULL, BOOLEAN_CONSTANT, FLOAT_CONSTANT, CHARACTER_CONSTANT, INTEGER_CONSTANT)


class KotlinAnnotator : Annotator {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.vlnabatov.alabaster.extensions.annotation

import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity.INFORMATION
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors.*
import com.intellij.psi.PsiElement
import com.intellij.psi.util.elementType
import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes.*

import com.vlnabatov.alabaster.annotateSeparationMarks

private val valTokens = setOf(*BOOLEAN_TOKEN_SET.types, *NUMBER_TOKEN_SET.types, kNULL)


// Search in org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes
class ScalaAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
try {
when (element.elementType) {
// constants
in valTokens -> holder.newSilentAnnotation(INFORMATION).textAttributes(MARKUP_ENTITY).create()
// strings
in STRING_LITERAL_TOKEN_SET -> annotateSeparationMarks(element, holder, BRACES)
}
} catch (e: Exception) {
/* Should not happen */
}
}
}
13 changes: 8 additions & 5 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
<!-- <depends>com.intellij.laf.macos</depends>-->
<depends
optional="true"
config-file="com.vlanabatov.alabaster-withClojure.xml">com.cursiveclojure.cursive</depends>
config-file="withClojure.xml">com.cursiveclojure.cursive</depends>
<depends
optional="true"
config-file="com.vlanabatov.alabaster-withJS.xml">JavaScript</depends>
config-file="withJS.xml">JavaScript</depends>
<depends
optional="true"
config-file="com.vlanabatov.alabaster-withJava.xml">com.intellij.java</depends>
config-file="withJava.xml">com.intellij.java</depends>
<depends
optional="true"
config-file="com.vlanabatov.alabaster-withKotlin.xml">org.jetbrains.kotlin</depends>
config-file="withKotlin.xml">org.jetbrains.kotlin</depends>
<depends
optional="true"
config-file="com.vlanabatov.alabaster-withXML.xml">com.intellij.modules.xml</depends>
config-file="withScala.xml">org.intellij.scala</depends>
<depends
optional="true"
config-file="withXML.xml">com.intellij.modules.xml</depends>

<extensions defaultExtensionNs="com.intellij">
<!-- <lafProvider implementation="com.vlnabatov.alabaster.laf.macos.MacLafProvider" os="mac"/>-->
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions src/main/resources/META-INF/withScala.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<annotator
language="Scala"
implementationClass="com.vlnabatov.alabaster.extensions.annotation.ScalaAnnotator"/>
</extensions>
</idea-plugin>
File renamed without changes.
27 changes: 27 additions & 0 deletions src/main/resources/test-files/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script type="application/javascript">
import { onMount } from "svelte"

export let foo

const bar = 42
let state = ""


onMount(() => {
state = "mounted"
})

const handleClick = () => {
state = "clicked"
}

handleClick();

const hello = () => {}
</script>
<style>
body {
font-size: 24px;
display: flex;
}
</style>
3 changes: 3 additions & 0 deletions test.js → src/main/resources/test-files/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const str = "hello"

alert(str)

const num = 5
const constt = true

// Выделяются синим имена всех callable переменных во время объявления. Но не во время вызова.
// В TS добавлен слегка зеленоватый для типов. Это противоречит концепции, но с ним лучше.

Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/test-files/test.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var arr = Array(
"Hello",
"Done")

val nulll = null
val truee = true
val num = 3

object add {
def addInt( a:Int, b:Int ) : Int = {
var sum:Int = 0
sum = a + b
return sum
}
}
16 changes: 16 additions & 0 deletions src/main/resources/test-files/test.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script>
import { onMount } from "svelte"
export let foo
const bar = 42
let state = ""
onMount(() => {
state = "mounted"
})
const handleClick = () => {
state = "clicked"
}
</script>

0 comments on commit d58931f

Please sign in to comment.