SLY: Bind TAB and M-TAB to "indent and complete".

master
Pierre Neidhardt 2020-11-17 15:03:05 +01:00
parent 79b872b88c
commit 9ed566d6fe
1 changed files with 12 additions and 5 deletions

View File

@ -288,6 +288,13 @@ returns a string."
(ansi-color-apply str))
(add-hook 'sly-mrepl-output-filter-functions 'ambrevar/sly-colorize-buffer)
(defun ambrevar/indent-and-helm-company (arg)
"Indent then call `helm-company'.
Good substitute for `sly-mrepl-indent-and-complete-symbol'."
(interactive "P")
(indent-for-tab-command arg)
(helm-company))
(setq sly-command-switch-to-existing-lisp 'always)
(add-hook 'sly-mrepl-hook #'ambrevar/init-lispy)
(add-hook 'sly-mrepl-hook #'rainbow-delimiters-mode)
@ -296,14 +303,14 @@ returns a string."
;; (add-to-list 'completion-styles 'backend)
(when (require 'helm-sly nil 'noerror)
;; (add-hook 'sly-mrepl-hook #'helm-sly-disable-internal-completion)
;; TODO: The above hangs Emacs 27, why?
;; REVIEW: Company completion has the benefit of having annotations.
(when (require 'helm-company nil :noerror)
(add-hook 'lisp-mode-hook #'company-mode)
(define-key lisp-mode-map (kbd "<tab>") 'helm-company)
(define-key lisp-mode-map (kbd "M-<tab>") 'helm-company)
(define-key lisp-mode-map (kbd "<tab>") 'ambrevar/indent-and-helm-company)
(define-key lisp-mode-map (kbd "M-<tab>") 'ambrevar/indent-and-helm-company)
(defun ambrevar/sly-set-keys ()
(define-key sly-mrepl-mode-map (kbd "<tab>") 'helm-company)
(define-key sly-mrepl-mode-map (kbd "M-<tab>") 'helm-company))
(define-key sly-mrepl-mode-map (kbd "<tab>") 'ambrevar/indent-and-helm-company)
(define-key sly-mrepl-mode-map (kbd "M-<tab>") 'ambrevar/indent-and-helm-company))
(add-hook 'sly-mrepl-hook #'ambrevar/sly-set-keys)
(add-hook 'sly-mrepl-hook #'company-mode))))