DuckDB R Editor (Positron)
February 10, 2026 ยท View on GitHub
Warning
Beta version. Report issues on GitHub.
Note
Positron IDE Only - Requires Positron. Will not work in VS Code.
SQL syntax highlighting and intelligent autocomplete for DuckDB in R files.
Write DuckDB SQL with full IDE support right inside R strings. Take full advantage of expressive SQL expressions within your R scripts!
Demo

Key Features
- ๐จ SQL Syntax Highlighting - Context-aware highlighting in R strings
- ๐ง Smart Autocomplete - 900+ DuckDB functions + live schema from R session
- ๐ R Connection Picker - Select specific connection objects (supports
:memory:) - ๐ Auto-Refresh - Detects schema changes automatically
- ๐ Visual Distinction - Themed background colors for SQL strings
- โจ SQL Auto-Format - Format SQL with glue interpolation support
- โ๏ธ Air Formatter Support - Works with multi-line SQL
Quick Start
1. Install
Download Release (Recommended)
- Download
.vsixfrom Releases - Positron: Extensions โ ... โ Install from VSIX
Or Build from Source
git clone https://github.com/belian-earth/duckdb-r-editor.git
cd duckdb-r-editor
npm install
With Make (Linux/Mac/WSL - recommended):
make # Build and package
make quick # Quick build (skip linting)
make help # See all commands
Without Make (universal):
npm run compile # Compile TypeScript
npm run lint # Run linter
npm run vsce:package # Create .vsix file
The .vsix file will be created in the project root. Install it via Positron: Extensions โ ... โ Install from VSIX
Note: Windows users can install Make via Chocolatey (choco install make) or use WSL
2. Connect in R
library(DBI)
library(duckdb)
con <- dbConnect(duckdb(), "mydata.duckdb")
# Or in-memory: dbConnect(duckdb(), ":memory:")
3. Connect the extension to the database
- Command Palette (
Cmd/Ctrl + Shift + P) - "DuckDB R Editor: Connect to DuckDB Database"
- Select your R connection (e.g., "con")
- Write SQL with autocomplete!
4. Write SQL
Autocomplete works in:
dbGetQuery(con, "SELECT * FROM ...")
dbExecute(con, "CREATE TABLE ...")
sql("SELECT ...") # dbplyr
glue_sql("...", .con = con) # glue
read_sql_duckdb("SELECT ...") # duckplyr
db_exec("SET threads TO 2") # duckplyr
Tip
Completions appear as you type. Use Ctrl+Space (Cmd+Space on Mac) to manually trigger suggestions at any position inside a SQL string.
Configuration
Optional settings (.vscode/settings.json):
{
"duckdb-r-editor.enableAutoComplete": true,
"duckdb-r-editor.enableSQLHighlighting": true,
"duckdb-r-editor.enableSQLBackgroundColor": true,
"duckdb-r-editor.autoRefreshSchema": true,
"duckdb-r-editor.sqlFormattingStyle": "standard",
"duckdb-r-editor.sqlKeywordCase": "upper"
}
Available Settings:
enableAutoComplete- Enable autocomplete (default: true)enableSQLHighlighting- SQL keyword/function highlighting in R strings (default: true)enableSQLBackgroundColor- Background color for SQL strings (default: true)autoRefreshSchema- Auto-detect schema changes (default: true)sqlFormattingStyle- Format style:standard,tabularLeft,tabularRight(default: standard)sqlKeywordCase- Keyword case:preserve,upper,lower(default: preserve)
Commands
Access via Command Palette (Cmd/Ctrl + Shift + P):
- Connect to DuckDB Database - Select R connection for schema
- Disconnect from Database - Clear connection
- Refresh DuckDB Schema - Manually update schema
- Format SQL in R String - Format SQL at cursor (preserves glue interpolations)
- Debug SQL Detection at Cursor - Diagnose autocomplete issues at cursor position (logs to Output panel)
Extension Loading
Load DuckDB extensions in your R session โ the extension picks up new functions automatically via auto-refresh:
dbExecute(con, "INSTALL spatial; LOAD spatial;")
# -> Functions automatically available for autocomplete
Auto-Refresh
Schema and functions refresh automatically when:
- Creating/dropping tables:
CREATE TABLE,DROP TABLE - Modifying data:
INSERT,UPDATE,DELETE - Loading extensions:
INSTALL,LOAD
Notifications show what changed:
โ 2 new tables added to 'con' (Total: 5 tables)
โ 45 new functions loaded in 'con' (Total: 945 functions)
* Disable in settings: "autoRefreshSchema": false
Why This Extension?
Writing SQL in R strings without IDE support means:
- Guessing table/column names
- No syntax validation until runtime
- Constant context switching to check schema
This extension provides:
- โ Real-time autocomplete from your active R session
- โ Syntax highlighting and validation
- โ Seamless workflow - stay in your code
Acknowledgments
- DuckDB - Analytical database
- Positron - Data science IDE
- Air formatter - R code formatting
- R packages:
DBI,duckdb,dbplyr,duckplyr,glue
Contributing
Contributions welcome! See DEVELOPMENT.md for build instructions and development workflow.
To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and test thoroughly
- Ensure code passes linting:
make buildornpm run lint - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Open an issue on GitHub for bug reports or feature requests.