;;; package --- 配置文件
;;; Comme
;;;
;;; 关闭菜单栏
(menu-bar-mode 0)
;;; 关闭工具栏
(tool-bar-mode 0)
;; 字体
(set-frame-font "JetBrains Mono NL 10" nil t)
;; 设置编码
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
;; 设置垃圾回收阈值, 加速启动速度
(setq gc-cons-threshold most-positive-fixnum)
;;; 显示行号
(require 'linum)
(setq linum-format "%3d ")
;;; 对所有文件生效
(add-hook 'find-file-hooks (lambda () (linum-mode 1)))
;; 显示列号
(setq column-number-mode t)
(setq line-number-mode t)
;; 语法高亮
;;(global-font-lock-mode t)
;;------------显示时间设置------------------------------
(display-time-mode 1);;启用时间显示设置,在minibuffer上面的那个杠上
(setq display-time-24hr-format t);;时间使用24小时制
(setq display-time-day-and-date t);;时间显示包括日期和具体时间
;(setq display-time-use-mail-icon t);;时间栏旁边启用邮件设置
(setq display-time-interval 10);;时间的变化频率,单位多少来着?
;; 禁用备份
(setq make-backup-files nil)
;; 不生成临时文件
(setq-default make-backup-files nil)
;;;---防止页面滚动时跳动,
;;scroll-margin 3 可以在靠近屏幕边沿3行时就开始滚动
;;scroll-step 1 设置为每次翻滚一行,可以使页面更连续
(setq scroll-step 1 scroll-margin 3 scroll-conservatively 10000)
;;-------- 改变Emacs要你回答yes的行为,按y或空格键表示yes,n表示no。
(fset 'yes-or-no-p 'y-or-n-p)
;;--------------- ido
;;ido的配置,这个可以使你在用C-x C-f打开文件的时候在后面有提示;
;;这里是直接打开了ido的支持,在emacs23中这个是自带的.
(ido-mode t)
;;ido模式中不保存目录列表,解决退出Emacs时ido要询问编码的问题。
(setq ido-save-directory-list-file nil)
;;--- 括号匹配
;;打开括号匹配显示模式
(show-paren-mode t)
;;括号匹配时可以高亮显示另外一边的括号,但光标不会烦人的跳到另一个括号处
(setq show-paren-style 'parenthesis)
;;---- 在行首 C-k 时,同时删除该行
(setq-default kill-whole-line t)
;;; 清华源
(setq package-archives '(("gnu" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
(setq package-check-signature nil) ; 不检查签名
(require 'package)
;; 初始化包管理器
(unless (bound-and-true-p package--initialized)
(package-initialize))
;; 刷新软件索引
(unless package-archive-contents
(package-refresh-contents))
;; use-package 包管理
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;; use-package 配置
(eval-and-compile
(setq use-package-always-ensure t) ;; 不用每个包都手动添加 ensure t 关键字
(setq use-package-always-defer t) ;; 全部延迟加载
(setq use-package-always-demand nil)
(setq use-packag-expand-minimally t)
(setq use-package-verbose t)
)
(require 'use-package)
;; 重启 emacs
;; M-x restart
(use-package restart-emacs)
;; emacs 三剑客
(use-package ivy
:defer 1
:demand
:hook (after-init . ivy-mode)
:config
(ivy-mode 1)
(setq ivy-use-virtual-buffers t
ivy-initial-inputs-alist nil
ivy-count-format "%d/%d "
enable-recursive-minibuffers t
ivy-re-builders-alist '((t . ivy--regex-ignore-order))))
(use-package counsel
:after (ivy)
:bind (("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file)
("C-c f" . counsel-recentf)
("C-c g" . counsel-git)))
(use-package swiper
:after ivy
:bind (("C-s" . swiper)
("C-r" . swiper-isearch-backward))
:config (setq swiper-action-recenter t
swiper-include-line-number-in-search t))
;; 语法检查
(use-package flycheck
:hook (after-init . global-flycheck-mode))
;; 窗口跳转
(use-package ace-window
:bind (("M-o" . 'ace-window)))
(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.
'(package-selected-packages
'(ace-window flycheck counsel ivy gruvbox-theme restart-emacs use-package)))
(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.
)
emacs 配置
于 2023-01-30 12:44:26 首次发布