How to prevent VS code from adding brackets after auto completing?
Closed this issue · 4 comments
When I use the ctheorems
package and type #theo
, vscode autocomplete it to #theorem()
, but what I need is #theorem[]
.
When I use the official web app, it autocomplete it to #theorem
without brackets, and it still autocomplete other functions like #bibliography()
with brackets. I think the autocompletion of the web app is better for me. Anyone know how to modify the settings?
Thanks!
It doesn't support to check content arguments yet. webapp may be doing some magic things inside.
The Typst webapp behaves much more stupid and inconsistent than Tinymist, from my experiment, the webapp will always try to complete the parens for u, the reason why it is not doing so is simply it fails to detect that #theorem
is indeed a function.
Examples of the inconsistency:
- When
#theorem
is defined in same file with the calling:
// main.typ
#import "@preview/ctheorems:1.1.3": *
#let theorem = thmbox("theorem", "Theorem", fill: rgb("#eeffee"))
// does not know theorem is a function, considered as a constant. (from the completion symbol is a: c I know this)
#theorem
- When
#theorem
is defined in another file but import directly:
// lib.typ
#import "@preview/ctheorems:1.1.3": *
#let theorem = thmbox("theorem", "Theorem", fill: rgb("#eeffee"))
// main.typ
import "lib.typ": *
// know this is a function, but does not complete the parens
#theorem
- When
#theorem
is defined in another file but imported with module variable:
// lib.typ
#import "@preview/ctheorems:1.1.3": *
#let theorem = thmbox("theorem", "Theorem", fill: rgb("#eeffee"))
// main.typ
import "lib.typ" as lib
// know this is a function, and complete a paren
#lib.theorem
Even though the completion is webapp is inconsistent for customized functions, it does hard coded some functions with some completion patterns: https://github.com/typst/typst/blob/5672cc2a29379f7743f66c46a7192d698a733047/crates/typst-ide/src/complete.rs#L1316
The bracket mode in complete.rs control the behavior
It will be fixed by #848, which completes bracket after functions that accepts an only positional argument having content type. We still don't have finished the type checking, but we have already supported type annotations in docstring to tell lsp to reliably complete brackets at suitable timings.
/// - body (content): The content of the theorem.
#let theorem(body) = thmbox("theorem", "Theorem", fill: rgb("#eeffee"), body)