81 lines
3.1 KiB
EmacsLisp
81 lines
3.1 KiB
EmacsLisp
(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 )
|
|
)
|
|
|
|
(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)))
|
|
|
|
;; 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
|