u
[emacs-helper.git] / eh-complete.el
blob1b54a8a9942128f8ec296dc025a033e4791cbd6e
1 ;;; eh-complete.el --- Tumashu's emacs complete configuation -*- lexical-binding: t; -*-
3 ;; * Header
4 ;; Copyright (c) 2011-2019, Feng Shu
6 ;; Author: Feng Shu <tumashu@163.com>
7 ;; URL: https://github.com/tumashu/emacs-helper
8 ;; Version: 0.0.1
10 ;; This file is not part of GNU Emacs.
12 ;;; License:
14 ;; This program is free software; you can redistribute it and/or
15 ;; modify it under the terms of the GNU General Public License
16 ;; as published by the Free Software Foundation; either version 3
17 ;; of the License, or (at your option) any later version.
19 ;; This program is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
29 ;;; Commentary:
31 ;; * 简介 :README:
32 ;; 这个文件是tumashu个人专用的emacs配置文件,emacs中文用户可以参考。
34 ;;; Code:
36 ;; * 代码 :code:
37 ;; ** company-mode
38 (require 'company)
39 (global-set-key (kbd "M-/") 'company-complete)
40 (define-key company-active-map (kbd "M-i") 'company-complete-selection)
41 (define-key company-active-map (kbd "C-n") 'company-select-next)
42 (define-key company-active-map (kbd "C-p") 'company-select-previous)
43 (define-key company-active-map (kbd "M-n") 'company-select-next)
44 (define-key company-active-map (kbd "M-p") 'company-select-previous)
46 (setq company-idle-delay 0.2)
47 (setq company-minimum-prefix-length 2)
48 (setq company-selection-wrap-around t)
49 (setq company-show-numbers t)
50 (setq company-tooltip-limit 10)
51 (setq company-tooltip-minimum-width 40)
52 (setq company-echo-delay 0)
53 (setq company-global-modes
54 '(not message-mode git-commit-mode eshell-mode))
56 (setq company-dabbrev-char-regexp "[[:word:]_:@.-]+")
57 (setq company-dabbrev-downcase nil)
58 (setq company-dabbrev-ignore-case nil)
59 (setq company-require-match nil)
60 (setq company-dabbrev-minimum-length 2)
62 (setq company-backends
63 '((company-capf company-files) ;company-dabbrev 经常让 emacs 卡死
64 (company-dabbrev-code company-gtags company-etags
65 company-keywords)))
66 (setq company-transformers
67 '(company-sort-by-occurrence))
69 (setq company-frontends
70 '(company-pseudo-tooltip-frontend
71 company-echo-metadata-frontend))
73 (if (and (fboundp 'daemonp) (daemonp))
74 (add-hook 'after-make-frame-functions
75 (lambda (_)
76 (global-company-mode)))
77 (global-company-mode))
79 (defun eh-company-dabbrev--prefix (orig-fun)
80 "取消中文补全"
81 (let ((string (pyim-char-before-to-string 0)))
82 (if (pyim-string-match-p "\\cc" string)
83 nil
84 (funcall orig-fun))))
86 (advice-add 'company-dabbrev--prefix
87 :around #'eh-company-dabbrev--prefix)
89 ;; ** company-posframe
90 (require 'company-posframe)
91 (setq company-posframe-show-indicator nil)
92 (setq company-posframe-show-metadata nil)
93 (setq company-posframe-quickhelp-delay 1)
94 (company-posframe-mode 1)
96 ;; * Footer
97 (provide 'eh-complete)
99 ;; Local Variables:
100 ;; coding: utf-8-unix
101 ;; End:
103 ;;; eh-complete.el ends here