From e0f0a4d2a99f675836ea7e10e0574f5bc3afae8c Mon Sep 17 00:00:00 2001 From: Dawid 'daedreth' Eckert Date: Sun, 31 Mar 2019 00:23:32 +0100 Subject: [PATCH] we ac now --- .gitignore | 2 + config.org | 118 ++++++++++++++++++++++------------------------------- init.el | 2 +- 3 files changed, 51 insertions(+), 71 deletions(-) diff --git a/.gitignore b/.gitignore index 6bf7772..f105b48 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ emms auto-save-list elpa transient +auto-complete-love +auto-complete-lua \ No newline at end of file diff --git a/config.org b/config.org index ccfff3a..3abf63f 100644 --- a/config.org +++ b/config.org @@ -1075,31 +1075,23 @@ I prefer =C-n= and =C-p= to move around the items, so I remap those accordingly. ** specific languages Be it for code or prose, completion is a must. -After messing around with =auto-completion= for a while I decided to drop it -in favor of =company=, and it turns out to have been a great decision. +After messing around with =auto-completion= and =company= for a while I decided to .. use both? +AC is for Lua/LÖVE and Company for the rest. Each category also has additional settings. *** c/c++ -**** yasnippet #+BEGIN_SRC emacs-lisp (add-hook 'c++-mode-hook 'yas-minor-mode) (add-hook 'c-mode-hook 'yas-minor-mode) -#+END_SRC -**** flycheck -#+BEGIN_SRC emacs-lisp (use-package flycheck-clang-analyzer :ensure t :config (with-eval-after-load 'flycheck (require 'flycheck-clang-analyzer) (flycheck-clang-analyzer-setup))) -#+END_SRC -**** company -Requires libclang to be installed. -#+BEGIN_SRC emacs-lisp (with-eval-after-load 'company (add-hook 'c++-mode-hook 'company-mode) (add-hook 'c-mode-hook 'company-mode)) @@ -1123,17 +1115,10 @@ Requires libclang to be installed. #+END_SRC *** python -**** yasnippet #+BEGIN_SRC emacs-lisp (add-hook 'python-mode-hook 'yas-minor-mode) -#+END_SRC - -**** flycheck -#+BEGIN_SRC emacs-lisp (add-hook 'python-mode-hook 'flycheck-mode) -#+END_SRC -**** company -#+BEGIN_SRC emacs-lisp + (with-eval-after-load 'company (add-hook 'python-mode-hook 'company-mode)) @@ -1156,18 +1141,9 @@ Requires libclang to be installed. #+END_SRC *** emacs-lisp -**** eldoc #+BEGIN_SRC emacs-lisp (add-hook 'emacs-lisp-mode-hook 'eldoc-mode) -#+END_SRC - -**** yasnippet -#+BEGIN_SRC emacs-lisp (add-hook 'emacs-lisp-mode-hook 'yas-minor-mode) -#+END_SRC - -**** company -#+BEGIN_SRC emacs-lisp (add-hook 'emacs-lisp-mode-hook 'company-mode) (use-package slime @@ -1183,67 +1159,69 @@ Requires libclang to be installed. (slime-setup '(slime-fancy slime-company))) #+END_SRC -*** lua -**** yasnippet -#+BEGIN_SRC emacs-lisp - (add-hook 'lua-mode-hook 'yas-minor-mode) -#+END_SRC - -**** flycheck -#+BEGIN_SRC emacs-lisp - (add-hook 'lua-mode-hook 'flycheck-mode) -#+END_SRC - -**** company +*** bash #+BEGIN_SRC emacs-lisp - (add-hook 'lua-mode-hook 'company-mode) - - (defun custom-lua-repl-bindings () - (local-set-key (kbd "C-c C-s") 'lua-show-process-buffer) - (local-set-key (kbd "C-c C-h") 'lua-hide-process-buffer)) + (add-hook 'shell-mode-hook 'yas-minor-mode) + (add-hook 'shell-mode-hook 'flycheck-mode) + (add-hook 'shell-mode-hook 'company-mode) - (defun lua-mode-company-init () - (setq-local company-backends '((company-lua + (defun shell-mode-company-init () + (setq-local company-backends '((company-shell + company-shell-env company-etags company-dabbrev-code)))) - (use-package company-lua + (use-package company-shell :ensure t :config (require 'company) - (setq lua-indent-level 4) - (setq lua-indent-string-contents t) - (add-hook 'lua-mode-hook 'custom-lua-repl-bindings) - (add-hook 'lua-mode-hook 'lua-mode-company-init)) + (add-hook 'shell-mode-hook 'shell-mode-company-init)) #+END_SRC -*** bash -**** yasnippet +*** lua/löve +I must regrettably admit that =company= sucks with Lua/LÖVE. +Which is also why I have =AC= now. +I needed to do some shenanigans to get great auto-completion but here goes. #+BEGIN_SRC emacs-lisp - (add-hook 'shell-mode-hook 'yas-minor-mode) -#+END_SRC + (add-hook 'lua-mode-hook 'yas-minor-mode) + (add-hook 'lua-mode-hook 'flycheck-mode) -**** flycheck -#+BEGIN_SRC emacs-lisp - (add-hook 'shell-mode-hook 'flycheck-mode) + (let (value) + (dolist (element '("love" "lua") value) + (unless (file-directory-p (concatenate 'string (getenv "HOME") "/.emacs.d/auto-complete-" element)) + (shell-command (format "git clone %s %s" (concatenate 'string + "https://github.com/rolpereira/auto-complete-" element ".el") + (concatenate 'string (getenv "HOME") "/.emacs.d/auto-complete-" element) nil))) + (add-to-list 'load-path (expand-file-name (concatenate 'string "~/.emacs.d/auto-complete-" element))))) -#+END_SRC + (require 'auto-complete-love) + (require 'auto-complete-lua) -**** company -#+BEGIN_SRC emacs-lisp - (add-hook 'shell-mode-hook 'company-mode) + (add-hook 'lua-mode-hook '(lambda () + (local-set-key (kbd "C-c C-s") 'lua-show-process-buffer) + (local-set-key (kbd "C-c C-h") 'lua-hide-process-buffer))) - (defun shell-mode-company-init () - (setq-local company-backends '((company-shell - company-shell-env - company-etags - company-dabbrev-code)))) + (use-package auto-complete + :ensure t + :config + (setq ac-use-menu-map t) + (setq ac-ignore-case nil) + (define-key ac-menu-map "\C-n" 'ac-next) + (define-key ac-menu-map "\C-p" 'ac-previous)) - (use-package company-shell + (add-hook 'lua-mode-hook '(lambda () + (setq ac-sources '(ac-source-love + ac-source-lua + ac-source-abbrev + ac-source-words-in-same-mode-buffers)) + (auto-complete-mode))) + + (add-hook 'lua-mode-hook 'auto-complete-mode) + + (use-package love-minor-mode :ensure t :config - (require 'company) - (add-hook 'shell-mode-hook 'shell-mode-company-init)) + (add-hook 'lua-mode-hook 'love-minor-mode)) #+END_SRC * Git integration diff --git a/init.el b/init.el index bb13631..2746ca9 100644 --- a/init.el +++ b/init.el @@ -54,7 +54,7 @@ ["#0a0814" "#f2241f" "#67b11d" "#b1951d" "#4f97d7" "#a31db1" "#28def0" "#b2b2b2"]) '(package-selected-packages (quote - (slime-company slime company-jedi zzz-to-char rainbow-delimiters avy ivy projectile sunrise-x-modeline sunrise-x-buttons sunrise-commander twittering-mode zerodark-theme pretty-mode flycheck-clang-analyzer flycheck-irony flycheck yasnippet-snippets yasnippet company-c-headers company-shell company-irony irony irony-mode company-lua mark-multiple expand-region swiper popup-kill-ring dmenu ido-vertical-mode ido-vertical ox-html5slide centered-window-mode htmlize ox-twbs diminish erc-hl-nicks symon rainbow-mode switch-window dashboard smex company sudo-edit emms magit org-bullets hungry-delete beacon linum-relative spaceline fancy-battery exwm which-key use-package))) + (love-minor-mode auto-complete slime-company slime company-jedi zzz-to-char rainbow-delimiters avy ivy projectile sunrise-x-modeline sunrise-x-buttons sunrise-commander twittering-mode zerodark-theme pretty-mode flycheck-clang-analyzer flycheck-irony flycheck yasnippet-snippets yasnippet company-c-headers company-shell company-irony irony irony-mode company-lua mark-multiple expand-region swiper popup-kill-ring dmenu ido-vertical-mode ido-vertical ox-html5slide centered-window-mode htmlize ox-twbs diminish erc-hl-nicks symon rainbow-mode switch-window dashboard smex company sudo-edit emms magit org-bullets hungry-delete beacon linum-relative spaceline fancy-battery exwm which-key use-package))) '(pos-tip-background-color "#36473A") '(pos-tip-foreground-color "#FFFFC8")) (custom-set-faces