Skip to content

Commit

Permalink
we ac now
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyKoyle committed Mar 31, 2019
1 parent ceca8e6 commit e0f0a4d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 71 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ emms
auto-save-list
elpa
transient
auto-complete-love
auto-complete-lua
118 changes: 48 additions & 70 deletions config.org
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))

Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e0f0a4d

Please sign in to comment.