KCL: Customizable per-arg and per-fn snippet values (#7156)

Before, the LSP snippet for `startProfile` was 

```
startProfile(%, at = [3.14, 3.14])
```

Now it's 

```
startProfile(%, at = [0, 0])
```

This is configured by adding a `snippet_value=` field to the stdlib macro. For example:


```diff
#[stdlib {
    name = "startProfile",
    keywords = true,
    unlabeled_first = true,
    args = {
        sketch_surface = { docs = "What to start the profile on" },
-       at = { docs = "Where to start the profile. An absolute point." },
+       at = { docs = "Where to start the profile. An absolute point.", snippet_value = "[0, 0]" },        tag = { docs = "Tag this first starting point" },
    },
    tags = ["sketch"]
}]
```

## Work for follow-up PRs

 - Make this work for KCL functions defined in KCL, e.g. [`fn circle`](36c8ad439d/rust/kcl-lib/std/sketch.kcl (L31-L32)) -- something like `@(snippet_value = "[0, 0]")` perhaps
 - Go through the stdlib and change defaults where appropriate
This commit is contained in:
Adam Chalmers
2025-05-21 15:18:20 -05:00
committed by GitHub
parent a36530d6df
commit 0ea1e9a6da
19 changed files with 140 additions and 101 deletions

View File

@ -1322,7 +1322,7 @@ pub async fn start_profile(exec_state: &mut ExecState, args: Args) -> Result<Kcl
unlabeled_first = true,
args = {
sketch_surface = { docs = "What to start the profile on" },
at = { docs = "Where to start the profile. An absolute point." },
at = { docs = "Where to start the profile. An absolute point.", snippet_value_array = ["0", "0"] },
tag = { docs = "Tag this first starting point" },
},
tags = ["sketch"]