dotfiles/emacs.d/init.el

310 lines
10 KiB
EmacsLisp
Raw Permalink Normal View History

2024-03-19 15:23:58 +09:00
;; init.el - part of dotfiles
;; https://git.kinoshita-lab.org/kazbo/dotfiles
2024-03-19 15:48:11 +09:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2024-03-19 16:25:32 +09:00
;; META Setup(setup package system, leaf straight)
2024-03-19 15:48:11 +09:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; configure package
(require 'package)
(eval-and-compile
(when (or load-file-name byte-compile-current-file)
(setq user-emacs-directory
(expand-file-name
(file-name-directory (or load-file-name byte-compile-current-file))))))
(setq package-enable-at-startup nil)
(eval-and-compile
(customize-set-variable
'package-archives '(("org" . "https://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(setq url-http-attempt-keepalives nil)
(package-initialize))
2024-03-19 15:23:58 +09:00
;; setup strait
;; cf. https://github.com/radian-software/straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
2024-03-19 16:25:32 +09:00
(setq straight-vc-git-default-clone-depth 1) ;; shallow clone
;; setup leaf if not
(eval-and-compile
(straight-use-package 'leaf)
(straight-use-package 'leaf-keywords)
(leaf-keywords-init))
(leaf leaf-keywords
:ensure t
:init
;; optional packages if you want to use :hydra, :el-get, :blackout,,,
(leaf hydra :straight t)
(leaf el-get :straight t)
(leaf blackout :straight t)
(leaf leaf
:require t
:init
(leaf leaf-convert
:straight t)
(leaf leaf-tree
:straight t
:blackout t
:custom
(imenu-list-position . 'left))
:config
;; initialize leaf-keywords.el
(leaf-keywords-init)))
2024-03-19 15:23:58 +09:00
2024-06-25 10:37:13 +09:00
(leaf macrostep
:ensure t)
2024-03-19 15:48:11 +09:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Actual Setup
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2024-03-19 16:25:32 +09:00
;; basic settings
(leaf basic-settings
:config
(set-language-environment "Japanese")
(prefer-coding-system 'utf-8)
(setq system-time-locale "C")
(setq inhibit-startup-message t) ;; remove opening screen
(setq initial-scratch-message "") ;; scratchの初期メッセージ消去
(global-display-line-numbers-mode)
2024-03-19 15:48:11 +09:00
2024-03-19 16:25:32 +09:00
;; タイトルバーにファイルのフルパス表示
(setq frame-title-format
(format "%%f - Emacs@%s" (system-name)))
(setq gc-cons-threshold (* 10 gc-cons-threshold))
(setq message-log-max 10000)
(setq enable-recursive-minibuffers t)
(setq use-dialog-box 0)
(defalias 'message-box 'message)
(setq history-length 1000)
(setq echo-keystrokes 0.1)
(setq large-file-warning-threshold (* 25 1024 1024))
(defadvice abort-recursive-edit (before minibuffer-save activate)
(when (eq (selected-window) (active-minibuffer-window))
(add-to-history minibuffer-history-variable (minibuffer-contents))))
(defalias 'yes-or-no-p 'y-or-n-p)
;; スクロールバーいらない
(scroll-bar-mode -1)
;; mode bar の設定
(line-number-mode)
(column-number-mode)
(transient-mark-mode 1)
(blink-cursor-mode 0) ;;; カーソルの点滅を止める
(tool-bar-mode 0) ;;; toolbarいらない
(setq-default tab-width 4 indent-tabs-mode nil) ;; tab = 4 spaces
(ffap-bindings) ;; ffap カーソル位置のファイルを開こうとする
(setq completion-ignore-case t) ;; file名の補完で大文字小文字を区別しない
2024-04-27 12:07:52 +09:00
(global-auto-revert-mode t) ;; バッファ自動再読み
(cd "~/") ;HOMEディレクトリに移動
2024-04-27 19:11:48 +09:00
(setq auto-save-default nil) ; .# とかの謎ファイルを作らない
(setq make-backup-files nil) ; .~ とかの謎ファイルを作らない
)
2024-04-27 12:07:52 +09:00
;; ファイル名がぶつからないようにする (uniquify)
2024-05-06 00:45:22 +09:00
(leaf uniquify
2024-04-27 12:07:52 +09:00
:config
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
(setq uniquify-ignore-buffers-re "*[^*]+*"))
;; recentf
2024-04-27 19:11:48 +09:00
(leaf recentf
2024-04-27 12:07:52 +09:00
:ensure t
:straight t
:init
2024-04-27 19:11:48 +09:00
(leaf counsel :ensure t)
2024-04-27 12:07:52 +09:00
(recentf-mode 1)
:config
(setq recentf-max-saved-items 2000) ;; 2000ファイルまで履歴保存する
(setq recentf-auto-cleanup 'never) ;; 存在しないファイルは消さない
(setq recentf-exclude '(
"/recentf"
"COMMIT_EDITMSG"
"/.?TAGS"
"^/sudo:"
"/\\.emacs\\.d/games/*-scores"
"/\\.emacs\\.d/\\.cask/"
"/\\elpa/*"
"*/share/emacs/*"
))
(setq recentf-auto-save-timer (run-with-idle-timer 30 t 'recentf-save-list))
:bind
("C-c t" . 'counsel-recentf))
2024-03-19 15:48:11 +09:00
2024-03-19 16:25:32 +09:00
;; configure look and feel
(leaf lookandfeel
:if window-system
(leaf color-theme-modern :straight t)
(leaf dracula-theme :straight t)
:config
(load-theme 'dracula t t)
(enable-theme 'dracula)
(set-face-italic-p 'italic nil)
(set-face-attribute 'default nil
;;:font "Noto Sans Mono CJK JP"
:font "kazbo_pragmata_mplus2"
;;:font "Iosevka Fixed SS03"
:weight 'medium
;;:font "Code New Roman"
;;:font "Hack"
;;:font "Rounded M+ 1m regular"
;;:font "xos4 Terminus"
:height 130))
2024-03-19 15:48:11 +09:00
2024-04-27 12:07:52 +09:00
;; markdown
(leaf markdown-mode
:ensure t
:mode ("README\\.md\\'" . gfm-mode)
:init (setq markdown-command "multimarkdown"))
(leaf company-quickhelp :ensure t)
(leaf company-irony :ensure t)
(leaf company-c-headers :ensure t)
(leaf slime-company :ensure t)
;; company
(leaf company
:ensure t
:straight t
:init
(company-quickhelp-mode)
:config
(setq company-minimum-prefix-length 1)
(setq company-selection-wrap-around t)
(setq company-auto-expand t) ;; 1個目を自動的に補完
(setq company-transformers '(company-sort-by-backend-importance)) ;; ソート順
(setq company-idle-delay 0) ; 遅延なしにすぐ表示
(setq company-minimum-prefix-length 2) ; デフォルトは4
(setq company-selection-wrap-around t) ; 候補の最後の次は先頭に戻る
(setq completion-ignore-case t)
(setq company-dabbrev-downcase nil)
(setq company-selection-wrap-around t)
(setq company-tooltip-maximum-width 50)
(setq company-show-numbers t)
2024-06-25 10:37:13 +09:00
2024-04-27 12:07:52 +09:00
(slime-setup '(slime-fancy slime-company))
(add-to-list 'company-backends '(company-bbdb
company-nxml
company-css
company-eclim
company-semantic
company-clang
company-xcode
company-cmake
company-mode/company-capf
company-dabbrev-code
company-gtags
company-etags
company-keywords
company-oddmuse
company-files
company-dabbrev
mapcar
company-mode/backend-with-yas
slime-company
company-irony
company-c-headers
company-elisp))
:hook
(prog-mode-hook . global-company-mode)
:bind
("C-M-i" . 'company-complete)
(company-active-map
("C-n" . 'company-select-next)
("C-p" . 'company-select-previous)
("[tab]" . 'company-complete-selection)
("C-h" . nil)
("C-S-h" . 'company-show-doc-buffer)))
(leaf slime
:ensure t
:straight t
:init
(leaf slime-company :ensure t)
:config
(setq inferior-lisp-program "sbcl")
(setq slime-contribs '(slime-fancy slime-company slime-quicklisp))
(setq slime-net-coding-system 'utf-8-unix)
(setq slime-complete-symbol*-fancy t)
(setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)
(setq slime-fuzzy-completion-in-place t)
(setq slime-fuzzy-explanation "")
(setq slime-kill-without-query-p t))
2024-03-19 15:23:58 +09:00
2024-04-27 19:11:48 +09:00
(leaf rainbow-delimiters
:ensure t
:straight t
:init
(require 'cl-lib)
(require 'color)
(defun rainbow-delimiters-using-stronger-colors ()
(interactive)
(cl-loop
for index from 1 to rainbow-delimiters-max-face-count
do
(let ((face (intern (format "rainbow-delimiters-depth-%d-face" index))))
(cl-callf color-saturate-name (face-foreground face) 100))))
:hook
(after-init . rainbow-delimiters-using-stronger-colors)
(prog-mode-hook . rainbow-delimiters-mode)
:config
(setq rainbow-delimiters-outermost-only-face-count 1)
(set-face-foreground 'rainbow-delimiters-depth-1-face "#c49696")
(set-face-foreground 'rainbow-delimiters-depth-2-face "#ff5e5e")
(set-face-foreground 'rainbow-delimiters-depth-3-face "#ffaa77")
(set-face-foreground 'rainbow-delimiters-depth-4-face "#dddd77")
(set-face-foreground 'rainbow-delimiters-depth-5-face "#80ee80")
(set-face-foreground 'rainbow-delimiters-depth-6-face "#66bbff")
(set-face-foreground 'rainbow-delimiters-depth-7-face "#da6bda")
(set-face-foreground 'rainbow-delimiters-depth-8-face "#afafaf")
(set-face-foreground 'rainbow-delimiters-depth-9-face "#f0f0f0"))
;; smartparens
;; M-x sp-cheat-sheet to shee commands available
;; https://github.com/Fuco1/smartparens
(leaf smartparens
:ensure t
:config
(require 'smartparens-config)
(smartparens-global-mode)
:bind
(("C-<right>" . sp-forward-slurp-sexp)
("C-<left>" . sp-forward-barf-sexp))
)
2024-05-06 00:58:08 +09:00
(leaf bind-key
:ensure t
:config
(bind-key "C-t" 'other-window global-map)
(bind-key "C-h" 'delete-backward-char global-map))
2024-03-19 16:25:32 +09: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.
2024-06-25 10:37:13 +09:00
'(warning-suppress-types '((leaf) (comp) (comp))))
2024-03-19 16:25:32 +09:00
(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.
)