Skip to content

Commit

Permalink
Initial Implementation of BacktickFoldingBuilder and PrettyFoldingBui…
Browse files Browse the repository at this point in the history
…lder
  • Loading branch information
kyay10 committed Nov 24, 2023
1 parent 8e6818f commit a4b8076
Show file tree
Hide file tree
Showing 26 changed files with 618 additions and 179 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
# prettify-kotlin Changelog

## [Unreleased]

## [0.0.1] - 2023-11-23

### Added

- Initial scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template)

[Unreleased]: https://github.com/kyay10/prettify-kotlin/compare/v0.0.1...HEAD
[0.0.1]: https://github.com/kyay10/prettify-kotlin/commits/v0.0.1
37 changes: 16 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,36 @@
[![Version](https://img.shields.io/jetbrains/plugin/v/PLUGIN_ID.svg)](https://plugins.jetbrains.com/plugin/PLUGIN_ID)
[![Downloads](https://img.shields.io/jetbrains/plugin/d/PLUGIN_ID.svg)](https://plugins.jetbrains.com/plugin/PLUGIN_ID)

## Template ToDo list
- [x] Create a new [IntelliJ Platform Plugin Template][template] project.
- [ ] Get familiar with the [template documentation][template].
- [ ] Adjust the [pluginGroup](./gradle.properties), [plugin ID](./src/main/resources/META-INF/plugin.xml) and [sources package](./src/main/kotlin).
- [ ] Adjust the plugin description in `README` (see [Tips][docs:plugin-description])
- [ ] Review the [Legal Agreements](https://plugins.jetbrains.com/docs/marketplace/legal-agreements.html?from=IJPluginTemplate).
- [ ] [Publish a plugin manually](https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html?from=IJPluginTemplate) for the first time.
- [ ] Set the `PLUGIN_ID` in the above README badges.
- [ ] Set the [Plugin Signing](https://plugins.jetbrains.com/docs/intellij/plugin-signing.html?from=IJPluginTemplate) related [secrets](https://github.com/JetBrains/intellij-platform-plugin-template#environment-variables).
- [ ] Set the [Deployment Token](https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html?from=IJPluginTemplate).
- [ ] Click the <kbd>Watch</kbd> button on the top of the [IntelliJ Platform Plugin Template][template] to be notified about releases containing new features and fixes.

<!-- Plugin description -->
This Fancy IntelliJ Platform Plugin is going to be your implementation of the brilliant ideas that you have.
Prettify Kotlin is a plugin that uses Idea's code folding to display backticked function calls without backticks. This
is useful for Kotlin DSLs that define custom "operators" (e.g. ``` `<-` ```) or use illegal characters (e.g.
sigma ``` `Σ` ```).

This specific section is a source for the [plugin.xml](/src/main/resources/META-INF/plugin.xml) file which will be extracted by the [Gradle](/build.gradle.kts) during the build process.
It also supports providing a "pretty" name for a function with the `@Pretty`
annotation. (`"io.github.kyay10:prettify-kotlin-annotation:1.0"`)

To keep everything working, do not remove `<!-- ... -->` sections.
It's recommended that you turn off the foreground and background colors for folded text in the IDE
<kbd>Settings/Preferences</kbd> > <kbd>Editor</kbd> > <kbd>Color Scheme</kbd> > <kbd>General</kbd> > <kbd>
Text</kbd> > <kbd>Folded text</kbd>
<!-- Plugin description end -->

This plugin is inspired
by [zjhmale/intellij-closure-pretty-symbol](https://github.com/zjhmale/intellij-clojure-pretty-symbol)

## Installation

- Using the IDE built-in plugin system:

<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "prettify-kotlin"</kbd> >

<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "Prettify
Kotlin"</kbd> >
<kbd>Install</kbd>

- Manually:

Download the [latest release](https://github.com/kyay10/prettify-kotlin/releases/latest) and install it manually using
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd>


---
Plugin based on the [IntelliJ Platform Plugin Template][template].

[template]: https://github.com/JetBrains/intellij-platform-plugin-template
[docs:plugin-description]: https://plugins.jetbrains.com/docs/intellij/plugin-user-experience.html#plugin-description-and-presentation
[template]: https://github.com/JetBrains/intellij-platform-plugin-template
5 changes: 0 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ repositories {
mavenCentral()
}

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
// implementation(libs.annotations)
}

// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
kotlin {
@Suppress("UnstableApiUsage")
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html

pluginGroup = com.github.kyay10.prettifykotlin
pluginGroup = io.github.kyay10
pluginName = prettify-kotlin
pluginRepositoryUrl = https://github.com/kyay10/prettify-kotlin
# SemVer format -> https://semver.org
Expand All @@ -16,7 +16,7 @@ platformVersion = 2022.3.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins =
platformPlugins = org.jetbrains.kotlin

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.4
Expand Down
44 changes: 44 additions & 0 deletions prettify-kotlin-annotation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
/secret_key_ring_file.gpg
/local.properties
122 changes: 122 additions & 0 deletions prettify-kotlin-annotation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import java.util.*
plugins {
kotlin("multiplatform") version "1.9.20"
id("org.jetbrains.dokka") version "1.9.10"
`maven-publish`
signing
}

group = "io.github.kyay10"
version = "1.0"

repositories {
mavenCentral()
}
val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)

val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
dependsOn(dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaHtml.outputDirectory)
}

kotlin {
jvm()
js(IR)
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
when {
hostOs == "Mac OS X" -> macosX64()
hostOs == "Linux" -> linuxX64()
isMingwX64 -> mingwX64()
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
}

publishing {
publications {
publications.withType<MavenPublication> {
artifact(javadocJar)
}
}
}

// Stub secrets to let the project sync and build without the publication values set up
ext["signing.keyId"] = null
ext["signing.password"] = null
ext["signing.secretKeyRingFile"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null

// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
secretPropsFile.reader().use {
Properties().apply {
load(it)
}
}.onEach { (name, value) ->
ext[name.toString()] = value
}
} else {
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}


fun getExtraString(name: String) = ext[name]?.toString()

publishing {
// Configure maven central repository
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}

// Configure all publications
publications.withType<MavenPublication> {
// Provide artifacts information requited by Maven Central
pom {
name.set("Prettify Kotlin Annotation")
description.set("Provides a @Pretty annotation for Kotlin")
url.set("https://github.com/kyay10/prettify-kotlin")

licenses {
license {
name.set("Apache-2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set("kyay10")
name.set("Youssef Shoaib")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/kyay10/prettify-kotlin.git")
}
}
}
}

// Signing artifacts. Signing.* extra properties values will be used

signing {
sign(publishing.publications)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
1 change: 1 addition & 0 deletions prettify-kotlin-annotation/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.code.style=official
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit a4b8076

Please sign in to comment.