A comprehensive Emacs configuration focused on C++ development with modern tooling and productivity enhancements.
This Emacs configuration provides a feature-rich development environment optimized for C++ programming while also supporting a wide range of other languages and workflows. The configuration is modular, well-organized, and designed for productivity.
- Modern C++ tooling: Tree-sitter support (c-ts-mode, c++-ts-mode) for Emacs 29+
- Code navigation: Ggtags integration with GNU Global
- Code style: Google C++ style support with automatic formatting
- Build integration: Compilation and error handling with flymake
- Header/source navigation: Quick switching between
.hand.cppfiles - Code completion: Corfu for in-buffer completion
- Eglot integration: Lightweight LSP client for multiple languages
- Language support: C/C++, Python, JavaScript, TypeScript, Rust, Go, Java, and more
- Tree-sitter: Built-in syntax tree parsing (Emacs 29+)
- Completion: Corfu for popup completion, Ivy/Counsel for fuzzy finding
- Syntax highlighting: Enhanced with symbol-overlay and rainbow-delimiters
- Code navigation: Avy for quick cursor movement, expand-region for text selection
- Multiple cursors: Edit multiple locations simultaneously
- gptel: ChatGPT/OpenAI integration within Emacs
- AI-assisted coding: Code generation and assistance directly in the editor
- Version control: Magit for Git operations, diff-hl for inline diffs
- Project management: Projectile for project navigation
- Debugging: GUD integration for debugging
- Documentation: Eldoc for inline documentation
- Window management: EXWM integration (Linux window manager)
- Session management: Save and restore editor sessions
- Note-taking: Org-mode with extensive customization
- File management: Dired with preview capabilities
- Search tools: Ripgrep integration with counsel
- Theme: Zenburn color theme
- UI enhancements: Smart mode-line, which-key for keybindings
- Fonts: Configurable font settings with variable pitch for prose
.dot-emacs/
├── .emacs.d/
│ ├── init.el # Main entry point
│ ├── elisp/ # Modular configuration files
│ │ ├── init-3rd-party.el # Third-party package configurations
│ │ ├── init-basics.el # Basic Emacs settings
│ │ ├── init-cc.el # C/C++ development settings
│ │ ├── init-eglot.el # LSP configuration
│ │ ├── init-elpa.el # Package management
│ │ ├── init-org.el # Org-mode configuration
│ │ ├── init-gptel.el # AI integration
│ │ └── ... (30+ more config files)
│ ├── site-lisp/ # Local packages
│ ├── treesit-grammars/ # Tree-sitter grammars
│ └── tutorials/ # Learning resources
├── .gnus # Email configuration
└── README.md # This file
-
Clone the repository:
git clone https://github.com/beacoder/dot-emacs.git ~/.emacs.d -
Backup existing configuration (if any):
mv ~/.emacs ~/.emacs.backup # If you have an existing .emacs file mv ~/.emacs.d ~/.emacs.d.backup # If you have an existing .emacs.d directory
-
Create symbolic links:
ln -sf ~/.emacs.d/.emacs.d ~/.emacs.d
-
Start Emacs: The first launch will automatically download and install all required packages.
If you prefer to keep your configuration separate:
- Copy the
.emacs.ddirectory to your preferred location - Add the following to your
~/.emacsfile:(load-file "~/.emacs.d/init.el")
The configuration is organized into modular files:
init.el- Main entry point, sets up load paths and loads modulesinit-basics.el- Fundamental Emacs settings and keybindingsinit-elpa.el- Package management with use-package
init-cc.el- C/C++ development with modern toolinginit-python.el- Python development setupinit-javascript.el- JavaScript/TypeScript configurationinit-ruby.el- Ruby development toolsinit-org.el- Org-mode for notes, tasks, and documentation
init-eglot.el- Language Server Protocol (LSP) clientinit-git.el- Git integration with Magitinit-compile.el- Build and compilation toolsinit-gptel.el- AI assistant integration
init-ui.el- Visual customization and themesinit-ivy.el- Fuzzy finding and completioninit-windows.el- Window management and layoutinit-productivity.el- Productivity tools and workflows
M-.- Find definition (ggtags-find-tag-dwim)M-]- Find referencesC-c o- Switch between header and source filesM-:- Avy goto characterM-8- Expand region
C-s/C-r- Incremental searchM-s- Project search with agC-x q a- Counsel ag (ripgrep)C-x q g- Counsel git grepC-x q f- Counsel git find file
C-c C-c- Compile current projectC-c C-e- Run testsC-x u- Undo tree visualizationC-M-y- Browse kill ring
C-x 2/C-x 3- Split windowsC-x 0/C-x 1- Close window/frameC-x o- Switch between windows
C-x g- Open Magit statuss- Stage changesc- Commitp- PushP- Pull
- Git: For version control and package management
- GNU Global: For C/C++ tag generation (
gtags) - ripgrep: For fast searching (
rg) - fd: Alternative to find command
- clangd: C/C++ language server (recommended)
- C/C++: clangd or ccls
- Python: pylsp or pyright
- JavaScript/TypeScript: typescript-language-server
- Rust: rust-analyzer
- Go: gopls
- Install tree-sitter grammars for enhanced syntax highlighting:
# Example for C/C++ git clone https://github.com/tree-sitter/tree-sitter-c ~/.emacs.d/treesit-grammars/c git clone https://github.com/tree-sitter/tree-sitter-cpp ~/.emacs.d/treesit-grammars/cpp
Create a file ~/.emacs.d/elisp/init-personal.el for your customizations:
;;; init-personal.el --- Personal configurations -*- lexical-binding: t -*-
;; Add your personal settings here
(setq user-full-name "Your Name"
user-mail-address "your.email@example.com")
;; Additional packages
(when (maybe-require-package 'some-package)
(require 'some-package))
;; Custom keybindings
(global-set-key (kbd "C-c p") 'some-command)Change the theme by modifying init-ui.el or adding to your personal config:
(load-theme 'modus-vivendi t) ;; Dark theme
;; or
(load-theme 'modus-operandi t) ;; Light theme-
Package installation fails:
- Check your internet connection
- Ensure ELPA repositories are accessible (may require proxy in some regions)
- Try running
M-x package-refresh-contents
-
Tree-sitter not working:
- Ensure you're using Emacs 29+
- Install tree-sitter grammars in
~/.emacs.d/treesit-grammars/ - Check
(treesit-available-p)returnst
-
Language server not starting:
- Verify the language server is installed and in your PATH
- Check
eglotserver logs withM-x eglot-events-buffer - Ensure project has appropriate configuration files (e.g.,
compile_commands.jsonfor C/C++)
-
Performance issues:
- Disable heavy modes with
M-x profiler-start - Check
init-benchmarking.elfor performance measurement tools - Consider using
so-longmode for large files
- Disable heavy modes with
M-x toggle-debug-on-error- Enable debug on errorM-x view-echo-area-messages- View recent messagesM-x profiler-report- Profile performance- Check
*Messages*buffer for errors and warnings
Feel free to fork this repository and adapt it to your needs. If you have improvements:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This configuration is shared under the MIT License. See the LICENSE file for details.
- Inspired by various Emacs configurations including Purcell's, Doom, and Spacemacs
- Thanks to the Emacs community for countless packages and tutorials
- Special thanks to package maintainers for their work
For questions or suggestions:
- GitHub Issues: https://github.com/beacoder/dot-emacs/issues
- Email: Check the repository for contact information
Happy coding with Emacs!