varabyte / kobweb-intellij-plugin

An official IntelliJ IDE plugin to include Kobweb-specific enhancements and understanding to your project
Apache License 2.0
10 stars 2 forks source link

Add live templates for Kobweb #19

Open bitspittle opened 5 months ago

bitspittle commented 5 months ago

Live templates autocomplete code AND, if relevant, prompt users to fill out variable names before the completion is considered done.

We'll use VAR to represent things that should be filled out by the user and "$" to represent the cursor position when done.

For now we'll collect everything here because there probably aren't that many Kobweb concepts but we could break this up into multiple bugs if that's better.

Actual live template shortcut names are open for debate!

Frontend

csss/cssstyle = CssStyle

val VAR = CssStyle {
   base { Modifier.$ }
}

csssb/cssstylebase = CssStyle.base

val VAR = CssStyle.base {
   Modifier.$
}

page

@Page
@Composable
fun VAR() {
   $
}

worker

val worker = rememberWorker {
   VAR { output ->
      $
   }
}

initsilk

@InitSilk
fun VAR(ctx: InitSilkContext) {
   $
}

initkobweb

@InitKobweb
fun VAR(ctx: InitKobwebContext) {
   $
}

Backend

api

@Api
fun VAR(ctx: ApiContext) {
   $
}

initapi

@InitApi
fun VAR(ctx: InitApiContext) {
   $
}

objapistream

val VAR = object : ApiStream {
   override suspend fun onTextReceived(ctx: TextReceivedContext) {
      $
   }
}

apistream

val VAR = ApiStream { ctx ->
   $
}