From 34656171c50063a4e77e42e3db55be89329f8b71 Mon Sep 17 00:00:00 2001 From: gak Date: Mon, 17 Jun 2024 08:57:45 +1000 Subject: [PATCH] docs(lsp): remove trivial completions, ftl:, add fsm --- lsp/completion.go | 24 ++++++++---------------- lsp/markdown/completion/configDeclare.md | 4 ++-- lsp/markdown/completion/configGet.md | 9 --------- lsp/markdown/completion/fsmDeclare.md | 20 ++++++++++++++++++++ lsp/markdown/completion/pubSubPublish.md | 10 ---------- lsp/markdown/completion/secretDeclare.md | 2 +- lsp/markdown/completion/secretGet.md | 9 --------- 7 files changed, 31 insertions(+), 47 deletions(-) delete mode 100644 lsp/markdown/completion/configGet.md create mode 100644 lsp/markdown/completion/fsmDeclare.md delete mode 100644 lsp/markdown/completion/pubSubPublish.md delete mode 100644 lsp/markdown/completion/secretGet.md diff --git a/lsp/completion.go b/lsp/completion.go index 561d8f01d9..c9e827ac37 100644 --- a/lsp/completion.go +++ b/lsp/completion.go @@ -34,15 +34,9 @@ var retryCompletionDocs string //go:embed markdown/completion/configDeclare.md var declareConfigCompletionDocs string -//go:embed markdown/completion/configGet.md -var getConfigCompletionDocs string - //go:embed markdown/completion/secretDeclare.md var declareSecretCompletionDocs string -//go:embed markdown/completion/secretGet.md -var getSecretCompletionDocs string - //go:embed markdown/completion/pubSubTopic.md var declarePubSubTopicCompletionDocs string @@ -52,8 +46,8 @@ var declarePubSubSubscriptionCompletionDocs string //go:embed markdown/completion/pubSubSink.md var definePubSubSinkCompletionDocs string -//go:embed markdown/completion/pubSubPublish.md -var publishPubSubEventCompletionDocs string +//go:embed markdown/completion/fsmDeclare.md +var fsmCompletionDocs string // Markdown is split by "---". First half is completion docs, second half is insert text. var completionItems = []protocol.CompletionItem{ @@ -64,14 +58,12 @@ var completionItems = []protocol.CompletionItem{ completionItem("ftl:ingress", "FTL Ingress", ingressCompletionDocs), completionItem("ftl:cron", "FTL Cron", cronCompletionDocs), completionItem("ftl:retry", "FTL Retry", retryCompletionDocs), - completionItem("config:declare", "Declare config", declareConfigCompletionDocs), - completionItem("config:get", "Get config", getConfigCompletionDocs), - completionItem("secret:declare", "Declare secret", declareSecretCompletionDocs), - completionItem("secret:get", "Get secret", getSecretCompletionDocs), - completionItem("pubsub:topic", "Declare PubSub topic", declarePubSubTopicCompletionDocs), - completionItem("pubsub:subscription", "Declare a PubSub subscription", declarePubSubSubscriptionCompletionDocs), - completionItem("pubsub:sink", "Define a PubSub sink", definePubSubSinkCompletionDocs), - completionItem("pubsub:publish", "Publish a PubSub event", publishPubSubEventCompletionDocs), + completionItem("ftl:config:declare", "Declare config", declareConfigCompletionDocs), + completionItem("ftl:secret:declare", "Declare secret", declareSecretCompletionDocs), + completionItem("ftl:pubsub:topic", "Declare PubSub topic", declarePubSubTopicCompletionDocs), + completionItem("ftl:pubsub:subscription", "Declare a PubSub subscription", declarePubSubSubscriptionCompletionDocs), + completionItem("ftl:pubsub:sink", "Define a PubSub sink", definePubSubSinkCompletionDocs), + completionItem("ftl:fsm", "Model a FSM", fsmCompletionDocs), } func completionItem(label, detail, markdown string) protocol.CompletionItem { diff --git a/lsp/markdown/completion/configDeclare.md b/lsp/markdown/completion/configDeclare.md index 96720edd68..c8138fe5d8 100644 --- a/lsp/markdown/completion/configDeclare.md +++ b/lsp/markdown/completion/configDeclare.md @@ -1,9 +1,9 @@ Snippet for declaring a config variable. ```go -var defaultUser = ftl.Config[string]("default") +var defaultUser = ftl.Config[string]("defaultUser") ``` See https://tbd54566975.github.io/ftl/docs/reference/secretsconfig/ --- -var ${1:configVar} = ftl.Config[${2:Type}](${3:default}) +var ${1:configVar} = ftl.Config[${2:Type}](${1:configVar}) diff --git a/lsp/markdown/completion/configGet.md b/lsp/markdown/completion/configGet.md deleted file mode 100644 index 73d36ea899..0000000000 --- a/lsp/markdown/completion/configGet.md +++ /dev/null @@ -1,9 +0,0 @@ -Snippet for getting a config variable. - -```go -username = defaultUser.Get(ctx) -``` - -See https://tbd54566975.github.io/ftl/docs/reference/secretsconfig/ ---- -${1:value} := ${2:configVar}.Get(ctx) diff --git a/lsp/markdown/completion/fsmDeclare.md b/lsp/markdown/completion/fsmDeclare.md new file mode 100644 index 0000000000..dba67dba27 --- /dev/null +++ b/lsp/markdown/completion/fsmDeclare.md @@ -0,0 +1,20 @@ +Snippet for declaring a FSM model. + +```go +var payment = ftl.FSM( + "payment", + ftl.Start(Invoiced), + ftl.Start(Paid), + ftl.Transition(Invoiced, Paid), + ftl.Transition(Invoiced, Defaulted), +) +``` + +See https://tbd54566975.github.io/ftl/docs/reference/fsm/ +--- +var ${1:FSM} = ftl.FSM( + "${1:FSM}", + ftl.Start(${2:verbState}), + ftl.Transition(${2:fromVerbState}, ${3:toVerbState}), +) +``` \ No newline at end of file diff --git a/lsp/markdown/completion/pubSubPublish.md b/lsp/markdown/completion/pubSubPublish.md deleted file mode 100644 index dea92486f8..0000000000 --- a/lsp/markdown/completion/pubSubPublish.md +++ /dev/null @@ -1,10 +0,0 @@ -Snippet for publishing an event to a topic. - -```go -invoicesTopic.Publish(ctx, Invoice{...}) -``` - -See https://tbd54566975.github.io/ftl/docs/reference/pubsub/ ---- -${1:topicVar}.Publish(ctx, ${2:Type}{${3:...}}) -``` \ No newline at end of file diff --git a/lsp/markdown/completion/secretDeclare.md b/lsp/markdown/completion/secretDeclare.md index 9a46ab3486..1ecb2af6ee 100644 --- a/lsp/markdown/completion/secretDeclare.md +++ b/lsp/markdown/completion/secretDeclare.md @@ -6,4 +6,4 @@ var apiKey = ftl.Secret[string]("apiKey") See https://tbd54566975.github.io/ftl/docs/reference/secretsconfig/ --- -var ${1:secretVar} = ftl.Secret[${2:Type}](${3:default}) +var ${1:secretVar} = ftl.Secret[${2:Type}](${3:secretVar}) diff --git a/lsp/markdown/completion/secretGet.md b/lsp/markdown/completion/secretGet.md deleted file mode 100644 index 904d8207c6..0000000000 --- a/lsp/markdown/completion/secretGet.md +++ /dev/null @@ -1,9 +0,0 @@ -Snippet for getting a secret. - -```go -apiValue := apiKey.Get(ctx) -``` - -See https://tbd54566975.github.io/ftl/docs/reference/secretsconfig/ ---- -${1:value} := ${2:secretVar}.Get(ctx)