(require 'package) (package-initialize) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) (unless (package-installed-p 'use-package) (package-install 'use-package)) (require 'use-package) (use-package rainbow-mode :ensure t) (use-package treemacs :ensure t :config (treemacs-follow-mode t) ;; Enable follow mode (setq treemacs-show-hidden-files t) ;; Show hidden files (optional) (treemacs-fringe-indicator-mode t) ;; Show fringe indicators (treemacs-git-mode 'deferred) ;; Enable Git integration (global-set-key (kbd "C-c \\" ) 'treemacs ) ;; Tree Toggle (global-set-key (kbd "C-c C-\\" ) 'treemacs-select-window ) ;; Tree Focus (global-set-key (kbd "C-c M-`" ) 'treemacs-edit-workspaces ) (global-set-key (kbd "C-c TAB" ) 'treemacs-next-workspace ) ) (use-package multiple-cursors :ensure t :config (global-set-key (kbd "C-c ") 'mc/mark-next-like-this) (global-set-key (kbd "C-c ") 'mc/mark-previous-like-this) ) (use-package highlight-indent-guides :ensure t :hook ((prog-mode . highlight-indent-guides-mode) ; Enable in programming modes (treemacs-mode . (lambda () (highlight-indent-guides-mode -1)))) ; Disable in Treemacs :config (setq highlight-indent-guides-method 'character) ; Choose method: 'character', 'fill', or 'column' (setq highlight-indent-guides-auto-enabled t) (setq highlight-indent-guides-responsive 'top) (setq highlight-indent-guides-character ?\|)) ; Character to display as indent guide (use-package company :ensure t :config (global-company-mode t)) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ;; '(custom-enabled-themes '(tango-dark)) ;; Use a themes that available by emacs '(package-selected-packages nil) ) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ; Custom themes that I download from internet (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") (load-theme 'dracula t) (add-to-list 'default-frame-alist '(background-color . "unspecified-bg")) ; make backup to a designated dir, mirroring the full path (defun xah-backup-nested-dir-file-path (Fpath) "Return a new file path and create dirs. If the new path's directories does not exist, create them. version 2022-06-09" (let* ($backupRoot $backupFilePath) (setq $backupRoot "~/.emacs.d/backup/") ;; remove Windows driver letter in path, e.g. C: (setq $backupFilePath (format "%s%s~" $backupRoot (replace-regexp-in-string "^[A-Za-z]:/" "" Fpath))) (make-directory (file-name-directory $backupFilePath) (file-name-directory $backupFilePath)) $backupFilePath )) (setq make-backup-file-name-function 'xah-backup-nested-dir-file-path) ; disable backup ; (setq backup-inhibited t) ; disable auto save (setq auto-save-default nil) ;; Enable line numbers globally (global-display-line-numbers-mode t) ;; Disable line numbers for Treemacs (add-hook 'treemacs-mode-hook (lambda () (display-line-numbers-mode 0))) ;; Clipboard integration (Not work in terminal) (setq select-enable-clipboard t) (setq select-enable-primary t) ;; Clipboard integration for terminal (Need xclip) (when (not (display-graphic-p)) ;; Check if Emacs is running in the terminal (defun my-copy-to-clipboard () "Copy region to clipboard using xclip." (interactive) (if (use-region-p) (let ((text (buffer-substring-no-properties (region-beginning) (region-end)))) (with-temp-buffer (insert text) (call-process-region (point-min) (point-max) "xclip" nil 0 nil "-selection" "clipboard")) (message "Copied to clipboard")) (message "No region selected."))) (global-set-key (kbd "C-c M-w") 'my-copy-to-clipboard)) ;; For example, set the default tab width to 4 spaces (setq-default tab-width 4) ;; For Python mode, set the indentation style (add-hook 'python-mode-hook (lambda () (setq indent-tabs-mode nil) ; Use spaces instead of tabs (setq python-indent-offset 4) )) ; Set the indentation offset ;; For JavaScript mode, set the indentation style (add-hook 'js-mode-hook (lambda () (setq indent-tabs-mode nil) ; Use spaces instead of tabs (setq js-indent-level 4))) ; Set the indentation offset