(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.
'(column-number-mode t)
'(custom-enabled-themes '(dracula))
'(custom-safe-themes
'("2d74de1cc32d00b20b347f2d0037b945a4158004f99877630afc034a674e3ab7" default))
'(package-selected-packages
'(xcscope clang-format format-all eglot company-quickhelp-terminal company-quickhelp company-box use-package slime-company dracula-theme gnu-elpa-keyring-update slime smex))
'(show-paren-mode t))
(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.
'(default ((t (:family "Fira Code" :foundry "CTDB" :slant normal :weight normal :height 113 :width normal)))))
(require 'use-package)
(setq package-archives '(("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("nongnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/nongnu/")
("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
(package-initialize) ;; You might already have this line
;;关闭启动页面
(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)
;;设置光标为|
(setq-default cursor-type 'bar)
;; 在窗口中显示行号
(global-linum-mode 1) ;; 总是显示行号
;; 显示光标当前所在的行和列
(column-number-mode t)
;; 显示匹配的括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;; 内置的智能自动补全括号
(electric-pair-mode t)
;; 鼠标自动避开光标
(mouse-avoidance-mode 'animate)
;; 将确定时输入的关键字 yes 和 no 替换为单字母 y 和 n
(fset 'yes-or-no-p 'y-or-n-p)
;; 不生成备份文件
(setq make-backup-files nil)
;;检查gnu签名,nil表示不检查
(setq package-check-signature 'allow-unsigned)
;;company
(use-package company
:ensure t
:hook (after-init . global-company-mode) ;; 全局启用 company-mode
:config
(setq company-idle-delay 0.2 ;; 补全弹出延迟
company-minimum-prefix-length 2 ;; 触发补全的最小字符数
company-tooltip-align-annotations t)) ;; 对齐注释
;;company-quickhelp:用来弹出说明文档
(use-package company-quickhelp
:ensure t
:hook (company-mode . company-quickhelp-mode)
:config
(setq company-quickhelp-delay 0.2))
;;clangd:C/C++代码补全
(require 'eglot)
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))
(add-hook 'c-mode-hook 'eglot-ensure)
(add-hook 'c++-mode-hook 'eglot-ensure)
;;cscope:C代码阅读
(require 'xcscope)
(cscope-setup)
;; 打开cscope时不更新,提高索引速度
(setq cscope-do-not-update-database t)
(setq cscope-option "-q")
;;sbcl
(setq inferior-lisp-program "sbcl")
;;slime-company
(slime-setup '(slime-fancy slime-company))
(use-package slime-company
:after (slime company)
:config (setq slime-company-completion 'fuzzy
slime-company-after-completion 'slime-company-just-one-space))
(define-key company-active-map (kbd "\C-n") 'company-select-next)
(define-key company-active-map (kbd "\C-p") 'company-select-previous)
(define-key company-active-map (kbd "\C-d") 'company-show-doc-buffer)
(define-key company-active-map (kbd "M-.") 'company-show-location)
;;clang-format:C/C++脚本格式化
(use-package clang-format
:ensure t ;; 自动从 MELPA 安装
:config
(setq clang-format-executable (executable-find "clang-format")
clang-format-style "file") ;; "file" 表示使用 .clang-format 配置文件
;; C脚本保存时自动格式化
(add-hook 'c-mode-common-hook
(lambda ()
(add-hook 'before-save-hook 'clang-format-buffer nil t)
;; 只在 C/C++ 模式中绑定 C-c f
(local-set-key (kbd "C-c f") 'clang-format-buffer)))
;; lisp脚本保存时自动格式化
(add-hook 'lisp-mode-hook
(lambda ()
(add-hook 'before-save-hook
(lambda ()
(save-excursion
(pp-buffer) ;; 这会自动美化整个缓冲区
(indent-region (point-min) (point-max))))
nil t)
(local-set-key (kbd "C-c f")
(lambda ()
(interactive)
(save-excursion
(pp-buffer)
(indent-region (point-min) (point-max)))))))
;; ========== 全局缩进设置 ==========
;(setq lisp-indent-offset 2) ;; Lisp 缩进 2 空格
(setq indent-tabs-mode nil) ;; 统一使用空格
)