Skip to content

Polars code completion

Source code

Description

[Experimental] This only works in RStudio.

Usage

polars_code_completion_activate(..., verbose = TRUE)

polars_code_completion_deactivate(..., verbose = TRUE)

Arguments

These dots are for future extensions and must be empty.
verbose Inform whether code completion is active or not.

Details

This intercepts Rstudio internal functions .rs.getCompletionsFunction & .rs.getCompletionsDollar in the loaded session environment tools:rstudio.

Pressing tab will literally evaluate the left-hand-side in order to compute possible suggestions. Therefore, it may be slow on large data or large queries.

Examples

library("polars")

if (interactive()) {
  # Activate completion
  polars_code_completion_activate()

  # Add a "$" and press tab to see functions for LazyFrame
  pl$LazyFrame(x = 1)

  # Add a "$" after pl$col("x") and press tab to see functions for expressions
  pl$LazyFrame(x = 1)$select(pl$col("x"))

  # Add a "$" in count_matches() and press tab to see possible arguments
  pl$LazyFrame(x = 1)$select(pl$col("x")$str$count_matches())

  # Deactivate (restarting the R session also deactivates code completion)
  polars_code_completion_deactivate()
}