feat(emacs): implement super tab
This is a port of the original super tab I had in vim. It has a hierarchy of checks for actions when using the tab so I can use tab for snippet expanding, expanding emmet expressions. Currently this dose not support tab for cycling though completions, and I am sure there will be some bugs in some situations.
This commit is contained in:
parent
bb7671734c
commit
589237ea50
1 changed files with 15 additions and 16 deletions
|
|
@ -32,11 +32,16 @@
|
||||||
(let ((yas/fallback-behavior 'return-nil))
|
(let ((yas/fallback-behavior 'return-nil))
|
||||||
(yas/expand)))
|
(yas/expand)))
|
||||||
|
|
||||||
(defun aa/company-tab ()
|
(defun aa/expand ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (or (not yas/minor-mode)
|
(if (or (not yas/minor-mode)
|
||||||
(null (do-yas-expand)))
|
(null (do-yas-expand)))
|
||||||
(company-complete-common-or-cycle)))
|
(if (string-empty-p (thing-at-point 'word 'no-properties))
|
||||||
|
(indent-for-tab-command)
|
||||||
|
(if (fboundp 'emmet-expand-yas)
|
||||||
|
(emmet-expand-yas)))))
|
||||||
|
|
||||||
|
(define-key evil-insert-state-map (kbd "C-e") 'aa/expand)
|
||||||
|
|
||||||
(use-package company
|
(use-package company
|
||||||
:after lsp-mode
|
:after lsp-mode
|
||||||
|
|
@ -44,8 +49,8 @@
|
||||||
(:map company-active-map
|
(:map company-active-map
|
||||||
("RET" . company-complete)
|
("RET" . company-complete)
|
||||||
("C-l" . yas-next-field-or-maybe-expand)
|
("C-l" . yas-next-field-or-maybe-expand)
|
||||||
("<tab>" . aa/company-tab)
|
("<tab>" . aa/expand)
|
||||||
("TAB" . aa/company-tab))
|
("TAB" . aa/expand))
|
||||||
:config
|
:config
|
||||||
(setq company-idle-delay 0)
|
(setq company-idle-delay 0)
|
||||||
(setq company-echo-delay 0)
|
(setq company-echo-delay 0)
|
||||||
|
|
@ -125,18 +130,12 @@
|
||||||
|
|
||||||
(use-package string-inflection :defer t)
|
(use-package string-inflection :defer t)
|
||||||
|
|
||||||
(defun aa/global-tab ()
|
|
||||||
(interactive)
|
|
||||||
(if (or (not yas/minor-mode)
|
|
||||||
(null (do-yas-expand)))
|
|
||||||
(indent-for-tab-command)))
|
|
||||||
|
|
||||||
(define-minor-mode aa-tab-mode
|
(define-minor-mode aa-tab-mode
|
||||||
"Runs fmt on file save when this mode is turned on"
|
"Tab mode by me"
|
||||||
:lighter " aa-tab"
|
:lighter " aa-tab"
|
||||||
:global nil
|
:global nil
|
||||||
(global-set-key (kbd "<tab>") 'aa/global-tab)
|
(global-set-key (kbd "<tab>") 'aa/expand)
|
||||||
(global-set-key (kbd "TAB") 'aa/global-tab))
|
(global-set-key (kbd "TAB") 'aa/expand))
|
||||||
|
|
||||||
(define-globalized-minor-mode global-aa-tab-mode aa-tab-mode
|
(define-globalized-minor-mode global-aa-tab-mode aa-tab-mode
|
||||||
(lambda () (aa-tab-mode 1)))
|
(lambda () (aa-tab-mode 1)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue