Use built-in solution for indent or complete at point with tab key

Get rid of the work-around code snippet, and use the built-in fuction
from company-mode that does the same thing.
This commit is contained in:
2018-04-16 22:26:29 +01:00
parent a40f272683
commit 0b3155e8b7

View File

@@ -36,29 +36,14 @@
;; is displayed on top (happens near the bottom of windows)
company-tooltip-flip-when-above t)
(defvar completion-at-point-functions-saved nil)
(defun company-indent-for-tab-command (&optional arg)
(interactive "P")
(let ((completion-at-point-functions-saved completion-at-point-functions)
(completion-at-point-functions '(company-complete-common-wrapper)))
(indent-for-tab-command arg)))
(defun company-complete-common-wrapper ()
(let ((completion-at-point-functions completion-at-point-functions-saved))
(company-complete-common)))
;; Trigger completion popup by pressing tab
;; - from: https://github.com/company-mode/company-mode/issues/94#issuecomment-40884387
(define-key company-mode-map [remap indent-for-tab-command]
'company-indent-for-tab-command)
(global-company-mode 1)
;; Customize keybindings for navigating up/down the completion popup list.
(define-key company-active-map (kbd "C-n") #'company-select-next)
(define-key company-active-map (kbd "C-p") #'company-select-previous)
(setq tab-always-indent 'complete)
(global-company-mode 1))
;; Enable indent and complete at point functionality by pressing tab.
(global-set-key (kbd "TAB") #'company-indent-or-complete-common))
(provide 'siren-company)
;;; siren-company.el ends here