Language Server
Documentation for Roughly's R language server
Roughly provides a full Language Server Protocol (LSP) implementation for R that integrates with modern code editors.
Usage
The easiest way to use Roughly is through its VS Code extension.
If you want to integrate Roughly with another editor that supports the Language Server Protocol (LSP), you can start the language server directly:
roughly server
VS Code Extension
Installation
- Download the latest
roughly.vsix
from GitHub Releases - Install the extension in VS Code:
Terminal window code --install-extension roughly.vsix - Configure the extension by setting the path to the Roughly binary in
settings.json
:{"roughly.path": "/path/to/roughly"}
Building from Source
If you prefer to build the extension yourself:
# From the repository rootbun run packagecode --install-extension roughly.vsix
VS Code specific commands
Roughly’s VS Code extension provides several commands to manage the language server:
- Start Language Server: Manually start the language server if it’s not running
- Stop Language Server: Manually stop the language server
- Restart Language Server: Restart the language server (useful after configuration changes)
- Open Logs: View the language server logs for troubleshooting
- Status Bar Integration: Shows the current status of the language server and allows quick access to commands by clicking on the status indicator
Features
Based on the LSP implementation in lsp.rs
, Roughly’s language server provides:
Document Features
- Diagnostics: Real-time error and warning detection as you type
- Formatting: Code formatting through the editor’s format command
- Document Symbols: Navigate to functions, classes, and variables in the current file
Navigation
- Workspace Symbols: Search for symbols across all R files in your project
- Hover Information: Coming soon
Code Intelligence
- Completion:
- Code completion for workspace symbols
- Keywords and reserved words (
if
,else
,function
, etc.) - Special values (
TRUE
,FALSE
,NULL
,NA
, etc.) - Trigger characters:
$
,@
(for accessing object fields)
Editor Integration
- Incremental Document Syncing: Efficiently updates as you type
- Save Actions: Automatically reindexes files on save
Configuration
The language server uses the same configuration as the formatter and linter via roughly.toml
:
case = "snake_case" # or camelCasespaces = 2
Roadmap
Future language server improvements will include:
- Go to Definition: Navigate to function and variable definitions
- Find References: Find all references to a symbol
- Rename Symbol: Safely rename variables and functions
- Type Information: Show type information in tooltips
- Semantic Highlighting: Enhanced syntax highlighting
- Code Actions: Quick fixes for common issues
Supported Editors
While Roughly is designed as a standard LSP implementation that should work with any editor supporting LSP:
- VS Code: Full support via dedicated extension
- Other Editors: May be configured to use Roughly’s LSP implementation directly