Tumashu's emacs complete configuation
1 简介
这个文件是tumashu个人专用的emacs配置文件,emacs中文用户可以参考。
2 代码
2.1 设置 smex
(use-package smex :config (smex-initialize))
2.2 设置 swiper 和 ivy-mode
(use-package swiper :config (use-package counsel :config (setq counsel-yank-pop-separator (concat "\n\n" (make-string 70 ?-) "\n")) (setq counsel-git-log-cmd "GIT_PAGER=cat git log --pretty='TUMASHU%%s%%n%%n%%b' --grep '%s'") (setq counsel-git-log-split-string-re "TUMASHU") (use-package git-commit :bind (("C-c i" . counsel-git-log))) :bind (("C-c C-r" . ivy-resume) ("M-x" . counsel-M-x) ("C-x b" . ivy-switch-buffer) ("C-x f" . counsel-recentf) ("C-x C-b" . ivy-switch-buffer) ("C-x C-f" . counsel-find-file) ("C-h f" . counsel-describe-function) ("C-h v" . counsel-describe-variable) ("C-c y" . counsel-yank-pop))) (ivy-mode 1) (setq ivy-count-format "" ivy-use-virtual-buffers t ivy-format-function #'ivy-format-function-arrow ivy-display-style 'fancy) (push '(counsel-M-x . "") ivy-initial-inputs-alist) (push '(counsel-describe-function . "") ivy-initial-inputs-alist) (push '(counsel-describe-variable . "") ivy-initial-inputs-alist) ;; I use "C-x C-f" to open file, so bind "C-f" to ;; `ivy-immediate-done' is very useful. (define-key ivy-minibuffer-map (kbd "C-f") #'ivy-immediate-done))
2.3 设置 company-mode
(use-package company :config (setq company-idle-delay 0.2) (setq company-minimum-prefix-length 2) (setq company-selection-wrap-around t) (setq company-show-numbers t) (setq company-tooltip-limit 10) (setq company-echo-delay 0) (setq company-global-modes '(not message-mode git-commit-mode eshell-mode)) ;; company-dabbrev (setq company-dabbrev-char-regexp "[[:word:]_:@.-]+") (setq company-dabbrev-downcase nil) (setq company-dabbrev-ignore-case nil) (setq company-require-match nil) (setq company-dabbrev-minimum-length 2) (setq company-backends '((company-capf company-dabbrev company-files) (company-dabbrev-code company-gtags company-etags company-keywords))) (setq company-transformers '(company-sort-by-occurrence)) (setq company-frontends '(company-pseudo-tooltip-frontend company-echo-metadata-frontend)) (global-set-key (kbd "M-/") #'company-complete) (define-key company-active-map (kbd "M-i") #'company-complete-selection) (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 "M-n") #'company-select-next) (define-key company-active-map (kbd "M-p") #'company-select-previous) (if (and (fboundp 'daemonp) (daemonp)) (add-hook 'after-make-frame-functions (lambda (x) (global-company-mode))) (global-company-mode)) (use-package pyim :config (defun eh-company-dabbrev--prefix (orig-fun) "取消中文补全" (let ((string (pyim-char-before-to-string 0))) (if (pyim-string-match-p "\\cc" string) nil (funcall orig-fun)))) (advice-add 'company-dabbrev--prefix :around #'eh-company-dabbrev--prefix)))