Environment Using Windows Terminal + WSL2
Configuration Windows Terminal Open Windows Terminal settings, select “Open JSON file”, and add the following color scheme under "schemes"
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 "schemes" : [ { "background" : "#0D1117" , "black" : "#484F58" , "blue" : "#58A6FF" , "brightBlack" : "#6E7681" , "brightBlue" : "#79C0FF" , "brightCyan" : "#56D4DD" , "brightGreen" : "#56D364" , "brightPurple" : "#D2A8FF" , "brightRed" : "#FFA198" , "brightWhite" : "#FFFFFF" , "brightYellow" : "#E3B341" , "cursorColor" : "#2F81F7" , "cyan" : "#39C5CF" , "foreground" : "#E6EDF3" , "green" : "#3FB950" , "name" : "GitHub-Dark-Default" , "purple" : "#BC8CFF" , "red" : "#FF7B72" , "selectionBackground" : "#E6EDF3" , "white" : "#B1BAC4" , "yellow" : "#D29922" } ] , - In your Arch Linux profile under Appearance: - Set the color scheme to GitHub-Dark-Default - Use the FiraCode Nerd Font - Set background opacity to 86 % and enable Acrylic effect - In the Advanced tab: - Disable sound notifications, enable window flash and taskbar flash instead ## Arch Linux Install necessary packages: ```bash # Install emacs-nox sudo pacman -Sy emacs-nox pacman -Sy emacs-nox pacman -Sy clang clangd clang-format rust-analyzer # After installing Rust: rm ~/.cargo/bin/rust-analyzer ln -s /usr/bin/rust-analyzer ~/.cargo/bin/rust-analyzer cargo install --git https: # Generate asm-lsp config file (optional) asm-lsp gen-config
Emacs Configuration Below is my .emacs configuration file. It includes support for:
C/C++, Rust, and Assembly (asm-lsp) LSP integration
Tree-sitter highlighting
Common development plugins (magit, projectile, goto-line-preview, neotree, etc.)
Clipboard sharing between WSL and Windows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 (menu-bar-mode -1 ) (global-display-line-numbers-mode t ) (add-hook 'prog-mode-hook 'column-number-mode) (add-hook 'prog-mode-hook 'hs-minor-mode) (global-auto-revert-mode 1 ) (setq-default window-combination-resize t x-stretch-cursor t ) (setq ring-bell-function 'ignore initial-scratch-message nil inhibit-startup-message t auto-save-file-name-transforms '((".*" "~/.emacs.d/data/backup/" t )) backup-directory-alist '(("." . "~/.emacs.d/data/backup/" )) create-lockfiles nil scroll-conservatively 10000 undo-limit 80000000 display-time-default-load-average nil ) (setq display-time-24hr-format t display-time-day-and-date t display-time-interval 10 display-time-format "%Y-%m-%d %A %H:%M" ) (display-time-mode 1 ) (display-time-update ) (set-face-attribute 'default nil :font "FiraCode Nerd Font" :height 120 ) (defun my/clipboard-to-windows (text &optional push) (let ((process-connection-type nil )) (with-temp-buffer (insert text) (call-process-region (point-min ) (point-max ) "win32yank.exe" nil nil nil "-i" )))) (defun my/clipboard-from-windows () (string-trim-right (with-output-to-string (call-process "win32yank.exe" nil standard-output nil "-o" )))) (setq interprogram-cut-function 'my/clipboard-to-windows) (setq interprogram-paste-function 'my/clipboard-from-windows) (defalias 'yes-or-no-p 'y-or-n-p) (setq make-backup-files nil ) (setq create-lockfiles nil ) (setq-default indent-tabs-mode nil ) (setq-default tab-width 4 ) (setq scroll-step 1 ) (global-visual-line-mode 1 ) (electric-pair-mode 1 ) (add-hook 'prog-mode-hook 'hs-minor-mode) (global-set-key (kbd "C-/" ) 'undo-only) (global-set-key (kbd "C-?" ) 'undo-redo) (global-set-key (kbd "M-<up>" ) 'enlarge-window) (global-set-key (kbd "M-<down>" ) 'shrink-window) (global-set-key (kbd "M-<left>" ) 'shrink-window-horizontally) (global-set-key (kbd "M-<right>" ) 'enlarge-window-horizontally) (set-language-environment "utf-8" ) (set-buffer-file-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (set-clipboard-coding-system 'utf-8) (modify-coding-system-alist 'process "*" 'utf-8) (prefer-coding-system 'utf-8) (setq-default pathname-coding-system 'utf-8) (setq default-process-coding-system '(utf-8 . utf-8) locale-coding-system 'utf-8 file-name-coding-system 'utf-8 default-buffer-file-coding-system 'utf-8 slime-net-coding-system 'utf-8-unix) (setenv "LC_CTYPE" "UTF-8" ) (setenv "LC_ALL" "en_US.UTF-8" ) (setenv "LANG" "en_US.UTF-8" ) (setq find-file-encoding 'auto) (setq-default coding-system-for-read 'utf-8) (setq-default coding-system-for-write 'utf-8) (setq package-archives '(("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/" ) ("nongnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/nongnu/" ) ("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/" ))) (use-package package :config (unless (bound-and-true-p package--initialized) (package-initialize ))) (setq use-package-always-ensure t ) (use-package doom-themes :ensure t :init :config (setq doom-themes-enable-bold t doom-themes-enable-italic t ) (load-theme 'doom-tomorrow-night t ) (doom-themes-visual-bell-config ) (doom-themes-org-config )) (defun my/kill-scratch-buffer () "在 Emacs 启动时关闭 *scratch* buffer." (when (get-buffer "*scratch*" ) (kill-buffer "*scratch*" ))) (add-hook 'emacs-startup-hook #'my/kill-scratch-buffer) (use-package centaur-tabs :ensure t :demand :init :config (defun centaur-tabs-hide-tab (x ) "自定义隐藏规则:隐藏特殊或无文件 buffer." (let ((name (format "%s" x))) (or (not (buffer-file-name x)) (window-dedicated-p (selected-window )) (string-prefix-p "*" name) (string-prefix-p " " name) (and (string-prefix-p "magit" name) (not (file-name-extension name)))))) (setq centaur-tabs-style "bar" centaur-tabs-set-bar 'over centaur-tabs-modified-marker "*" centaur-tabs-enable-key-bindings nil centaur-tabs-set-icons t centaur-tabs-icon-type 'nerd-icons centaur-tabs-set-close-button nil centaur-tabs-show-new-tab-button nil centaur-tabs-cycle-scope 'tabs) (centaur-tabs-mode t ) :bind ("C-<left>" . centaur-tabs-backward) ("C-<right>" . centaur-tabs-forward)) (use-package doom-modeline :ensure t :after nyan-mode :custom (doom-modeline-buffer-file-name-style 'truncate-all) :init (doom-modeline-mode 1 )) (use-package nyan-mode :ensure t :init (nyan-mode 1 )) (use-package goto-line-preview :ensure t :bind (("M-g g" . goto-line-preview))) (use-package neotree :ensure t :bind (("C-x t" . neotree-toggle)) :config (setq neo-theme 'arrow) (setq neo-smart-open t ) (setq neo-show-hidden-files t ) ) (use-package move-dup :bind (("M-p" . move-dup-move-lines-up) ("M-n" . move-dup-move-lines-down) )) (use-package exec-path-from-shell :ensure t :config (when (memq window-system '(mac ns x)) (exec-path-from-shell-initialize ))) (use-package magit :ensure t :defer t :bind (("C-x g" . magit-status)) ) (use-package tree-sitter :when (and (fboundp 'treesit-available-p) (treesit-available-p )) :config (setq treesit-font-lock-level 4 ) :init (setq treesit-language-source-alist '((bash . ("https://github.com/tree-sitter/tree-sitter-bash" )) (c . ("https://github.com/tree-sitter/tree-sitter-c" )) (cpp . ("https://github.com/tree-sitter/tree-sitter-cpp" )) (python . ("https://github.com/tree-sitter/tree-sitter-python" )) (rust . ("https://github.com/tree-sitter/tree-sitter-rust" )) (toml . ("https://github.com/tree-sitter/tree-sitter-toml" )) (elisp . ("https://github.com/Wilfred/tree-sitter-elisp" )) (cmake . ("https://github.com/uyha/tree-sitter-cmake" )) (dockerfile . ("https://github.com/camdencheek/tree-sitter-dockerfile" )) (make . ("https://github.com/alemuller/tree-sitter-make" )) (yaml . ("https://github.com/ikatyang/tree-sitter-yaml" )) (json . ("https://github.com/tree-sitter/tree-sitter-json" )) (java . ("https://github.com/tree-sitter/tree-sitter-java.git" )) (markdown . ("https://github.com/MDeiml/tree-sitter-markdown" nil "tree-sitter-markdown/src" )) )) (add-to-list 'auto-mode-alist '("\\.y[a]?ml\\'" . yaml-mode)) (add-to-list 'auto-mode-alist '("\\(?:Dockerfile\\(?:\\..*\\)?\\|\\.[Dd]ockerfile\\)\\'" . dockerfile-mode)) ) (dolist (lang '(bash c cpp python rust toml elisp cmake dockerfile make yaml json java markdown)) (unless (treesit-language-available-p lang) (treesit-install-language-grammar lang))) (setq major-mode-remap-alist '((bash-mode . bash-ts-mode) (c-mode . c-ts-mode) (c++-mode . c++-ts-mode) (python-mode . python-ts-mode) (rust-mode . rust-ts-mode) (conf-toml-mode . toml-ts-mode) (elisp-mode . elisp-ts-mode) (cmake-mode . cmake-ts-mode) (dockerfile-mode . dockerfile-ts-mode) (json-mode . json-ts-mode) (java-mode . java-ts-mode) (yaml-mode . yaml-ts-mode) (makefile-mode . make-ts-mode)) ) (require 'eglot) (setq eglot-server-programs '(((c++-mode c-mode c++-ts-mode c-ts-mode) . ("clangd" )) ((rust-mode rust-ts-mode) . ("rust-analyzer" )) ((asm-mode nasm-mode) . ("asm-lsp" )) ;;((markdown-mode) . ("ltex-ls" )) )) (global-set-key (kbd "M-," ) 'xref-find-definitions) (global-set-key (kbd "M-." ) 'xref-pop-marker-stack) (global-set-key (kbd "M-?" ) 'xref-find-references) (add-hook 'c-mode-hook 'eglot-ensure) (add-hook 'c-ts-mode-hook 'eglot-ensure) (add-hook 'c++-mode-hook 'eglot-ensure) (add-hook 'c++-ts-mode-hook 'eglot-ensure) (add-hook 'rust-mode-hook 'eglot-ensure) (add-hook 'rust-ts-mode-hook 'eglot-ensure) (add-hook 'asm-mode-hook 'eglot-ensure) (add-hook 'nasm-mode-hook 'eglot-ensure) (defun my-cpp-line-comments () "Use // comments instead of /* */ in C/C++." (setq-local comment-start "// " comment-end "" comment-start-skip "//+\\s-*" )) (add-hook 'c-mode-hook #'my-cpp-line-comments) (add-hook 'c++-mode-hook #'my-cpp-line-comments) (add-hook 'c-ts-mode-hook #'my-cpp-line-comments) (add-hook 'c++-ts-mode-hook #'my-cpp-line-comments) (add-hook 'rust-mode-hook #'my-cpp-line-comments) (add-hook 'rust-ts-mode-hook #'my-cpp-line-comments) (use-package company :ensure t :defer t :hook (after-init . global-company-mode)) (use-package format-all :ensure t :commands format-all-mode :hook (prog-mode . format-all-mode) :config (setq-default format-all-formatters '(("C" (clang-format)) ("C++" (clang-format)) ("rust" (rustfmt)) ))) (global-set-key (kbd "C-x f" ) 'format-all-buffer) (use-package which-key :ensure t :config (which-key-mode )) (use-package ace-window :ensure t :bind (("M-o" . ace-window))) (use-package buffer-move :ensure t :bind (("C-c <up>" . buf-move-up) ("C-c <down>" . buf-move-down) ("C-c <left>" . buf-move-left) ("C-c <right>" . buf-move-right))) (use-package crux :bind (("C-a" . 'crux-move-beginning-of-line) ("C-c k" . 'crux-smart-kill-line))) (use-package projectile :ensure t :init (projectile-mode +1 ) :bind-keymap ("C-c p" . projectile-command-map) :config (setq projectile-project-search-path '("~/repository" )) (setq projectile-completion-system 'auto)) (custom-set-variables '(package-selected-packages nil)) (custom-set-faces )
Preview
Keybindings Overview
Shortcut
Description
Source
C-/
Undo (undo-only)
Custom
C-?
Redo (undo-redo)
Custom
M-↑
Increase window height
Custom
M-↓
Decrease window height
Custom
M-←
Decrease window width
Custom
M-→
Increase window width
Custom
C-←
Switch to previous tab (Centaur Tabs)
centaur-tabs
C-→
Switch to next tab
centaur-tabs
M-g g
Preview go-to-line
goto-line-preview
M-p
Move current line up
move-dup
M-n
Move current line down
move-dup
C-x t
Toggle file tree sidebar (neotree)
neotree
C-x g
Open Git status (magit-status)
magit
M-x magit-log-all
View all Git commits in the current repository
magit
C-x f
Format current buffer (clang-format / rustfmt)
format-all
M-,
Jump to definition (xref-find-definitions, LSP)
Custom
M-.
Jump back to previous location (xref-pop-marker)
Custom
M-?
Find references (xref-find-references, LSP)
Custom
M-o
Switch between windows
ace-window
C-c ↑
Move current buffer up to another window
buffer-move
C-c ↓
Move current buffer down to another window
buffer-move
C-c ←
Move current buffer left to another window
buffer-move
C-c →
Move current buffer right to another window
buffer-move
C-a
Smart move to beginning of line
crux
C-c k
Smart kill line
crux
C-c p
Projectile command prefix
projectile