emacs.d/init.el

87 lines
3.3 KiB
EmacsLisp
Raw Normal View History

2024-10-14 22:30:10 +07:00
(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
2024-10-25 08:24:44 +07:00
(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 )
)
2024-10-25 08:25:51 +07:00
(use-package multiple-cursors
:ensure t
:config
(global-set-key (kbd "C-c <down>") 'mc/mark-next-like-this)
(global-set-key (kbd "C-c <up>") 'mc/mark-previous-like-this)
)
2024-10-14 22:30:10 +07:00
(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)
2024-10-20 21:55:46 +07:00
;; 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)))
2024-10-14 22:30:10 +07:00
;; 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