Skip to content

Data-Wise/spacemacs-rstats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

86 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

spacemacs-rstats

Tests Documentation License Platform Emacs R Spacemacs

Professional Spacemacs environment for R package development on macOS

License: MIT GitHub release GitHub stars Documentation CI Emacs Spacemacs R macOS


✨ Features

A complete, integrated development environment for R package development powered by Spacemacs:

  • 🎯 Modal Editing - Vim-style navigation with discoverable keybindings
  • πŸ” ESS Integration - Full Emacs Speaks Statistics support with R console and code evaluation
  • βœ… Flycheck + Linters - Real-time syntax checking with lintr and custom styler integration
  • πŸš€ LSP Mode - Language Server Protocol for intelligent code navigation and refactoring
  • πŸ’‘ Smart Completion - Company mode with context-aware autocompletion
  • πŸ“ Roxygen2 Automation - Automatic documentation skeleton generation with parameter detection
  • 🎨 Auto-Formatting - Styler integration for automatic code formatting on save
  • πŸ”· S7 Support - Built-in snippets and helpers for R's new S7 OOP system
  • πŸ“¦ Usethis Integration - Quick commands for creating R files, tests, and documentation
  • πŸ”— Git Integration - Magit for visual Git operations
  • πŸ“š Quarto/LaTeX - Full support for Quarto documents and LaTeX writing
  • πŸ—οΈ Which-Key - Discoverable keybindings (press SPC and wait!)

πŸš€ Quick Start

Prerequisites

  • macOS 12.0+ (tested on macOS 12+)
  • Emacs 27.1+ (emacs-plus@30 recommended)
  • R 4.0+
  • Git 2.0+
  • Homebrew (recommended)

Installation

## ⚑ Installation (Copy-Paste This)

```bash
git clone https://github.com/Data-Wise/spacemacs-rstats.git
cd spacemacs-rstats
./scripts/install.sh

Done! β˜• Grab coffee (~10 min install time)

πŸ” What's happening?

The installer automatically:

  1. βœ… Checks macOS version, disk space, network
  2. βœ… Installs Homebrew (if needed)
  3. βœ… Installs Emacs with native compilation
  4. βœ… Installs Spacemacs
  5. βœ… Configures for R development
  6. βœ… Installs R packages

First Emacs launch: Takes 10-15 min (packages installing)

βš™οΈ Troubleshooting

Already installed?

./scripts/health-check.sh --pre-flight

Shows 4 options: check health, update, repair, or reinstall.

Something broke?

./scripts/repair.sh  # Interactive menu

Start over?

./scripts/install.sh --force
πŸ€“ Advanced options
./scripts/install.sh --skip-checks  # Skip pre-flight (not recommended)
./scripts/install.sh --yes          # No prompts
./scripts/patch.sh                  # Update only
./scripts/uninstall.sh              # Remove (3 levels)

See Installation Management for details.

πŸ“š Documentation

🎯 Key Keybindings

Key Action Description
SPC f f Find file Open file with fuzzy search
SPC f s Save file Save current buffer
SPC b b Switch buffer Switch to another buffer
SPC SPC Execute Run command (M-x)
SPC p f Project file Find file in project
, s l Send line to R Execute current line in R
, s r Send region to R Execute selected region in R
, h i Insert roxygen Generate documentation
, g g Go to definition Jump to function definition
SPC e l List errors Show Flycheck errors

Note: , is the major mode leader key (equivalent to SPC m). Press , ? in any R file to see all available commands via which-key.

See the complete keybinding reference for more.

πŸ”§ What's Included

Spacemacs Configuration (~/.spacemacs)

  • Package Management - Automatic package installation via MELPA
  • ESS (R Mode) - Full R integration with console and evaluation
  • Flycheck - Syntax checking with lintr and custom styler checker
  • LSP Mode - Language Server Protocol with R languageserver
  • Company - Smart code completion
  • Vertico/Consult - Modern completion framework
  • Magit - Visual Git interface
  • Projectile - Project management
  • Which-Key - Keybinding discovery
  • Yasnippet - Code snippets
  • Quarto/Polymode - Quarto document support
  • AUCTeX - LaTeX integration
  • Org Mode - Enhanced org-mode
  • Citar - Citation management

Helper Scripts (~/.emacs.d/bin/)

  • r-styler-check.R - External Flycheck checker for styler
  • export-gui-path.sh - PATH exporter for macOS GUI Emacs

Documentation

  • guides/TUTORIAL.md - Complete user guide
  • guides/CHEAT-SHEET.md - Quick keybinding reference
  • guides/TROUBLESHOOTING.md - Problem solving guide
  • tests/TEST-CHECKLIST.md - Verification checklist

Test Files

  • tests/test-features.R - Interactive feature testing
  • tests/test-roxygen.R - Roxygen generation testing

🌟 Workflow Integration

spacemacs-rstats integrates seamlessly with:

  • Terminal Workflow - Use with rtest, rdoc, rcheck aliases
  • Claude Code - AI-powered development assistance
  • zsh-environment - Modern shell with development tools
  • r-package-development - Complete R workflow automation

πŸ’» Development Workflow

# 1. Open R package
cd ~/R-packages/active/mypackage
emacs .

# 2. Edit code in Emacs
# - Auto-completion
# - Real-time error checking
# - Roxygen documentation
# - Auto-formatting on save

# 3. Test interactively in R console
# M-x R
# C-RET to send code

# 4. Validate in terminal
rtest          # Run tests
rdoc           # Build documentation
rcheck         # R CMD check

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Ways to Contribute

  • πŸ› Report bugs via GitHub Issues
  • πŸ’‘ Suggest features or improvements
  • πŸ“ Improve documentation
  • πŸ”§ Submit pull requests

πŸ“‹ Requirements

System

  • macOS 12.0+ (Monterey or later)
  • Emacs 27.1+ (30.0+ recommended)
  • R 4.0+
  • Git 2.0+

Required R Packages

install.packages(c(
  "devtools",
  "usethis",
  "roxygen2",
  "testthat",
  "lintr",
  "styler"
))

Optional R Packages

install.packages(c(
  "languageserver",  # LSP support
  "s7",              # S7 OOP system
  "covr",            # Test coverage
  "pkgdown",         # Package websites
  "remotes"          # Remote packages
))

πŸ” Verification

After installation, verify everything works:

# Run automated checks
./scripts/check-dependencies.sh

# Open test file in Emacs
emacs tests/test-features.R

# Follow tests/TEST-CHECKLIST.md for comprehensive testing

πŸ“– Learning Resources

πŸ› Troubleshooting

Having issues? Check:

  1. Troubleshooting Guide - Common problems and solutions
  2. GitHub Issues - Known issues and discussions
  3. Dependency Checker - Run ./scripts/check-dependencies.sh
  4. Messages Buffer - In Emacs: βŒƒ h e

πŸ“„ License

MIT License - see LICENSE for details.

πŸ™ Acknowledgments

Built with:

πŸ“¬ Contact


Made with ❀️ for the R development community

⭐ Star this repo if you find it useful!