From f1ad9ee4a2e5b9ad230b03044b821c0ef685bbca Mon Sep 17 00:00:00 2001 From: Marc Pohling Date: Sat, 10 Mar 2018 15:43:20 +0100 Subject: [PATCH] backends for elisp configured --- config.org | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/config.org b/config.org index b564d6e..75e379f 100644 --- a/config.org +++ b/config.org @@ -333,7 +333,7 @@ Ivy displays a window with suggestions for hotkeys and M-x (setq ivy-height 20) ;; height of ivy window (setq ivy-count-format "%d/%d") ;; current and total number (setq ivy-re-builders-alist ;; regex replaces spaces with * - '((t . ivy--regex-plus))) + '((t . ivy--regex-plus))) ) #+end_src @@ -445,10 +445,19 @@ Backend configuration for python-mode #+begin_src emacs-lisp (defun company/python-mode-hook() - (lambda () - (set (make-local-variable 'company-backends) - '((company-jedi company-dabbrev) company-capf company-files)) - (company-mode t)) + (set (make-local-variable 'company-backends) + '((company-jedi company-dabbrev) company-capf company-files)) + (company-mode t) + ) +#+end_src + +Backend configuration for lisp-mode + +#+begin_src emacs-lisp + (defun company/elisp-mode-hook() + (set (make-local-variable 'company-backends) + '((company-elisp company-dabbrev) company-capf company-files)) + (company-mode t) ) #+end_src @@ -481,6 +490,11 @@ For the popups the package pos-tip.el is used and automatically installed. Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration. +** Lisp + +#+begin_src emacs-lisp +(add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook) +#+end_src ** Python @@ -515,18 +529,9 @@ Also limit the completion backends to those which make sense in Python. :mode ("\\.py\\'" . python-mode) :interpreter ("python" . python-mode) :init - (add-hook 'python-mode-hook ;;'company/python-mode-hook) - (lambda () - (set (make-local-variable 'company-backends) - '((company-jedi company-dabbrev-code) company-capf company-files)) - (company-mode t))) + (add-hook 'python-mode-hook 'company/python-mode-hook) :config (setq python-shell-completion-native-enable nil) -;; (defun my/run-python () -;; (save-selected-window -;; (switch-to-buffer-other-window (process-buffer (python-shell-get-or-create-process (python-shell-parse-command))))) -;; ) -;; (add-hook 'python-mode-hook 'my/run-python) ) #+end_src @@ -547,21 +552,14 @@ Code checks need to be installed, too: (add-hook 'python-mode-hook 'jedi:setup) (setq jedi:complete-on-dot t) (setq jedi:use-shortcuts t) - (add-hook 'python-mode-hook 'company/python-mode-hook) -;; (defun my/python-mode-hook() -;; (lambda () -;; (set (make-local-variable 'company-backends) -;; '((company-jedi company-dabbrev) company-capf company-files)))) -;; (add-to-list 'company-backends 'company-jedi)) -;; (add-hook 'python-mode-hook 'my/python-mode-hook) -;; (add-hook 'python-mode-hook 'company-mode) +;; (add-hook 'python-mode-hook 'company/python-mode-hook) ) #+end_src A wrapper to handle virtual environments. I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine. -pyvenv might need virtualenvwrapper, I have to test this. -apt install + +TODO: automatically start an inferior python process or switch to it if already created #+begin_src emacs-lisp (use-package pyvenv