company的激活后默认使用M-n, M-p选项, 想添加 C-n C-p的键绑定.代码如下:
(use-package company
:ensure t
:bind (
:map company-active-map
(("C-n" . company-select-next)
("C-p" . company-select-previous)
("C-d" . company-show-doc-buffer)
("<tab>" . company-complete))
)
:config
(progn
(global-company-mode t)
(setq company-backends
'((company-dabbrev
company-abbrev
company-yasnippet
)
(company-capf )))
)
)
启动后, 发现company-mode没加载上, 需要输入两次M-x company-mode , 才行.
解决办法也有. 就是键绑定的代码不要写到第一个 use-package里去.
第一种, 在(use-package company …), 里面不要写键绑定的代码, 之后再单独写一个键绑定的:
(use-package company
:bind (
:map company-active-map
(("C-n" . company-select-next)
("C-p" . company-select-previous)
("C-d" . company-show-doc-buffer)
("<tab>" . company-complete))
)
)
第二种, 其实和第一种一样, 在use-package之后, 用with-eval-after-load也行
(with-eval-after-load 'company
(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 "<tab>") #'company-complete)
;; (define-key company-active-map (kbd "M-n") nil)
;; (define-key company-active-map (kbd "M-p") nil))
)
只是不明白为何把键绑定的代码写进同一个(use-package …), 就会造成company-mode加载不上呢?